Professional Documents
Culture Documents
inc
.data
array1 dd arraySize dup(0) ; initialize array.
.code
start:
call main
inkey
exit
main proc
cls
fillArrayLoop:
mov eax, ecx ; Move counter value to eax
add eax, 2 ; The sieve starts at 2, therefor
add 2 to the loop counter
mov [array1+4*ecx], eax ; Insert value into array
inc ecx ; Increment counter
cmp ecx, arraySize ;
jb fillArrayLoop ; Jump to loop start is we are not
finished
nukeIt:
mov [array1+4*ebx], -1 ; Not a prime, set it to -1
jmp resume3 ; Jump to resume point
printArray:
cmp [array1+4*ecx], -1 ; Check if we have a prime.
jne printArrayElement ; If we have jump to printArrayElement.
resumePrintArray: ; Resume point
inc ecx ; Incrementing
cmp ecx, arraySize ; Are we done?
jb printArray ; If not jump to printArray...
ret
main endp
end start