Question: i need help with my masm x 8 6 program, its not returning prime for prime numbers, it returns not prime for prime numbers this
i need help with my masm x program, its not returning prime for prime numbers, it returns not prime for prime numbers
this is the logic:
int prime int n
int i c ;
for i ; i n; i
if n i
c;
if c
n is a Prime number.
else
n is not a Prime number.
code:
model flat,stdcall
stack
ExitProcess PROTO, dwExitCode:DWORD
INCLUDE C:UserscopyaOneDriveDocumentssourceIrvineIrvineinc
includelib C:UserscopyaOneDriveDocumentssourceIrvineirvinelib
data
prompt BYTE "PRIME",
prompt BYTE "Not PRIME",
n DWORD
code
main PROC
mov eax, n
mov ecx,
mov esi,
CheckFactors:
mov edx,
div esi
test edx, edx
jnz NotPrime
inc ecx
cmp ecx,
jg NotPrime
inc esi
cmp esi, eax
jle CheckFactors
Prime:
mov edx, OFFSET prompt
jmp PrintResult
NotPrime:
mov edx, OFFSET prompt
PrintResult:
call WriteString
call Crlf
invoke ExitProcess,
main ENDP
END main
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
