;// vs15-17IO.inc declarations for standard I/O ,console I/O Function prototypes
;// Copyright (c) FCL 2010. All rights reserved.
;// 2018-04-08
.686
.MODEL flat, stdcall
option casemap : none
;//========================================
includelib ucrt.lib
includelib legacy_stdio_definitions.lib
;//========================================
;// Function prototypes
printf PROTO C : dword,:vararg ;vararg参数:变参,参数个数不确定
scanf PROTO C : dword,:vararg ;dword参数 :格式描述串的有效地址。
_getch PROTO C : vararg ;注意:所有的参数都是dword型!
_kbhit PROTO C : vararg
puts PROTO C : dword,:vararg ;vararg参数:变参,参数个数不确定
gets PROTO C : dword,:vararg
.data
Hello byte "hello, gensokyo",10, 0
format byte '%d',0,10
.code
digui proc
push ebp
mov ebp,esp
mov ecx,dword ptr[ebp + 8]
cmp ecx,1;if(n>1)
jne next;return digui(n-1)
mov eax,0
jmp enddigui
next:
dec ecx
push ecx
call digui
pop ebx
add eax,ebx
enddigui:
add eax,ecx
pop ebp
ret
digui endp
main proc
pushad
push 7
call digui
invoke printf,offset format,eax
pop eax
popad
ret
main endp
end main
结果: