下面展示 汇编语言实现scanf函数的全部代码
。
include vcIO.inc
GetStdHandle proto,:DWORD
ReadConsoleA proto,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
ReadConsole equ <ReadConsoleA>
STD_INPUT_HANDLE=-10
.data
_insize dword ?
; 设置输入缓冲区最大255个字符
_inbuffer byte 255 dup(0)
msg1 byte "请输入字符:" , 0ah, 0
msg2 byte "请输入字符串:" , 0ah, 0
msg3 byte "请输入整型:" , 0ah, 0
msg4 byte "请输入短整型:" , 0ah, 0
msg_error byte "非法字符!" , 0ah, 0