fork(1) download
  1. TITLE Homework 6
  2.  
  3. ; Kurtis
  4. ; YOUR SECTION
  5. ; CPSC 232 Introduction to Assembler Programming
  6. ; Prof. James W. Emert
  7. ; Assignment: NAME AND NUMBER OF ASSIGNMENT
  8. ; Description: DESCRIPTION OF YOUR PROGRAM
  9.  
  10. INCLUDE Irvine32.inc
  11. .data
  12.  
  13. list REAL8 100 dup(0.0) ; list of numbers, size = 8 bytes
  14. ;***** This is supposed to be an array of REAL8
  15. len DWORD LENGTHOF list ; size of list
  16. lenMult DWORD ?
  17. number DWORD ?
  18.  
  19.  
  20.  
  21. ptrArray DWORD list
  22.  
  23.  
  24.  
  25. InsertionSort PROTO arr:PTR DWORD
  26. .code
  27. main PROC
  28.  
  29. mov esi,OFFSET list
  30. mov eax, 0
  31.  
  32.  
  33.  
  34.  
  35.  
  36. ;Populate Array With 100 Random Numbers
  37.  
  38. xor ebx, ebx; initialize counter to 0
  39. ;mov edi, [len] ;put length in register for comparison if not a constant
  40.  
  41.  
  42. mov edx,OFFSET list ;Move what's pointing to list into edx
  43.  
  44.  
  45. call fill
  46. call print
  47. invoke INSERTIONSORT, OFFSET list
  48. call print
  49.  
  50.  
  51. xor ebx, ebx
  52.  
  53. call DumpRegs
  54. call WaitMsg
  55. exit
  56. main ENDP
  57. ; PLACE ADDITIONAL PROCEDURES HERE
  58. fill PROC uses edx ebx eax
  59.  
  60. loophead:
  61. call Random32
  62. mov number, eax
  63. fld number
  64. fstp REAL8 PTR[edx+ebx*TYPE REAL8]
  65. inc ebx
  66. cmp ebx,len ; compare with array length
  67. jnz loophead
  68.  
  69. ret
  70.  
  71. fill ENDP
  72. print PROC uses ebx edx
  73.  
  74. print_start:
  75.  
  76. fld REAL8 PTR[edx+ebx*TYPE REAL8]
  77. call WriteFloat
  78. call CrLF
  79. fstp REAL8 PTR[edx+ebx*TYPE REAL8]
  80. inc ebx
  81. cmp ebx, len
  82. jnz print_start
  83.  
  84. ret
  85. print ENDP
  86. INSERTIONSORT PROC USES eax ecx esi, arr:PTR DWORD
  87. ; fld REAL8 PTR[edx+ebx*TYPE REAL8]
  88. ;fstp REAL8 PTR[edx+ebx*TYPE REAL8]
  89.  
  90.  
  91.  
  92. mov ecx,1 ;sort initializes counter at 1
  93. mov eax,0
  94. Outer_loop:
  95. push ecx
  96. mov ecx, 100
  97. mov esi, arr
  98. Inner_Loop:
  99. mov eax,[esi]
  100. FCOMPI [esi+TYPE REAL8], eax
  101. jae Inner_Loop_2
  102. xchg eax, [esi+TYPE REAL8] ;Works for 32 bits
  103.  
  104. mov [esi], eax ;
  105. Inner_Loop_2:
  106. add esi,TYPE REAL8
  107. loop Inner_Loop
  108. pop ecx ;clear memory
  109. loop Outer_loop
  110. Loop_End:
  111. ret
  112.  
  113.  
  114. INSERTIONSORT ENDP
  115.  
  116. END main
  117.  
  118. ;***** Will not work on REAL8. And why did you make it worse by using a WORD? It is only 2 bytes long instead of 8.
  119. ;***** I said this morning that you cannot ues CMP. You should be using FCOMPI. And you need to use UNSIGNED branch instructions. Not a signed branch
  120. ;***** li;***** I said this morning that you cannot use CMP. You should be using FCOMPI. And you need to use UNSIGNED branch instructions. Not a signed branch
  121. ;***** like JGE. ke JGE.
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.asm:1: error: parser: instruction expected
prog.asm:10: error: parser: instruction expected
prog.asm:13: error: parser: instruction expected
prog.asm:15: error: parser: instruction expected
prog.asm:16: error: parser: instruction expected
prog.asm:17: error: parser: instruction expected
prog.asm:21: error: parser: instruction expected
prog.asm:25: error: parser: instruction expected
prog.asm:27: error: parser: instruction expected
prog.asm:29: error: comma, colon or end of line expected
prog.asm:42: error: comma, colon or end of line expected
prog.asm:47: error: parser: instruction expected
prog.asm:56: error: symbol `main' redefined
prog.asm:56: error: parser: instruction expected
prog.asm:58: error: parser: instruction expected
prog.asm:64: error: comma, colon or end of line expected
prog.asm:71: error: symbol `fill' redefined
prog.asm:71: error: parser: instruction expected
prog.asm:72: error: parser: instruction expected
prog.asm:76: error: comma, colon or end of line expected
prog.asm:79: error: comma, colon or end of line expected
prog.asm:85: error: symbol `print' redefined
prog.asm:85: error: parser: instruction expected
prog.asm:86: error: parser: instruction expected
prog.asm:100: error: parser: instruction expected
prog.asm:102: error: parser: expecting ]
prog.asm:106: error: comma, colon or end of line expected
prog.asm:114: error: symbol `INSERTIONSORT' redefined
prog.asm:114: error: parser: instruction expected
prog.asm:116: error: parser: instruction expected
stdout
Standard output is empty