Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Code Screenshot

include irvine32.inc

.data?
tmp DWORD ?
.data
msg1 byte "The First Prime Number is:
",0

.code
main PROC
mov ecx, 1500
mov eax, 1500

L1 :
mov esi, 0
mov tmp, eax

mov ebx, 1
mov EDI, ecx
mov ecx, eax
L2 :
mov eax, tmp
mov edx, 0
div EBX

.IF EDX == 0
add esi, 1
.EndIF

.IF ESI > 2


jmp L4
.EndIf

inc EBX
Loop L2

CMP ESI, 2
JE L3

L4:
mov eax, tmp
inc eax
mov ecx, EDI

Loop L1

L3 :
mov edx, OFFSET msg1
call writeString
mov eax, tmp
call writeDec

exit
main endp
end main
Flow Chart

Loop through numbers


1500 to 3000

Divide each number by all


the numbers less than the
number

Increment counter Exit the loop


If counter exceeds 2
everytime remainder is 0
Counter==2
After full loop

Print the current value

You might also like