21,458
社区成员
发帖
与我相关
我的任务
分享
mov ecx, DWORD PTR i
cmp ecx, DWORD PTR n
invoke crt_printf, SADD("here ecx(i): %d",13,10), ecx
invoke crt_printf, SADD("here n: %d",13,10), n
jg $2
.486
.model flat, stdcall
option casemap :none
include \masm32\macros\macros.asm
include \masm32\include\msvcrt.inc
includelib \masm32\lib\msvcrt.lib
main PROTO
WaitKeyCrt PROTO
.data
newline BYTE 13, 10, 0
n DWORD ?
f DWORD ?
i DWORD ?
.code
start:
invoke main
invoke WaitKeyCrt
invoke crt__exit, 0
main PROC uses edi
invoke crt_printf, SADD("Please input a number: ")
invoke crt_scanf, SADD("%d",0), addr n
invoke crt_printf, SADD("n: %d",13,10), n
; Line 7
mov DWORD PTR i,2
; Line 8
mov DWORD PTR f,1
$1:
; Line 9
mov ecx, DWORD PTR i
cmp ecx, DWORD PTR n
invoke crt_printf, SADD("here ecx(i): %d",13,10), ecx
invoke crt_printf, SADD("here n: %d",13,10), n
jg $2
; Line 10
mov edx,f
imul edx,i
mov f,edx
; Line 11
mov eax,i
add eax,1
mov i,eax
; Line 12
jmp $1
$2:
invoke crt_printf, SADD("Result: %d",13,10), n
ret
main ENDP
WaitKeyCrt PROC
invoke crt_printf, SADD(13,10,"Press any key to continue...")
invoke crt__getch
.if (eax == 0) || (eax == 0E0h)
invoke crt__getch
.endif
invoke crt_printf, OFFSET newline
ret
WaitKeyCrt ENDP
END start