我对组装还很陌生,我正在尝试打印出给定数字的素数分解。经过数小时的网上搜索,我发现了一些关于 DIV 指令的有用花絮,但我无法让我的代码做我想做的事。
我做了一些非常错误的事情,但我无法发现它。请哪位好心人帮我看一下?
.data
myMessage BYTE "Please enter a number to be evaluated:",0dh,0ah,0
factor DWORD 2
hold DWORD ?
.code
main PROC
call Clrscr
mov edx,offset myMessage
call WriteString ;Displays myMessage
call ReadDec ;Puts value into EAX register
mov edi, factor
call prime
exit
main ENDP
prime PROC
step1: xor edx, edx
div edi
cmp edx, 1
jz step2
add factor, 1
mov edi, factor
jmp step1
step2: mov hold, eax
mov eax, edi
call WriteDec
mov eax, hold
CMP eax, 1
jz step3
jmp step1
step3:
exit
prime ENDP
END main