问题
The code below asks a user to input integers and the code will spit the same set of integers back to the user.
include irvine32.inc
.data
input dword ?
prompt1 byte "Input your numbers: ",0
.code
mWriteNum Macro input
push ecx
push eax
mov eax, offset input
call writedec
pop eax
push ecx
endM
mReadInput MACRO input
push ecx
push eax
mov eax, offset input
mov ecx, sizeof input
call Readint
mov input, eax
pop eax
pop ecx
endM
main proc
call clrscr
mov edx, offset prompt1
call writeString
mReadInput input
call crlf
mWriteNum input
exit
main ENDP
end main
However, this is what resulted:
Input your numbers: 123
4210688
What am I doing here? Please help. Thanks
回答1:
As you can see in the documentation for WriteDec, you're supposed to provide the value to print in eax
, not the address of the value to print.
来源:https://stackoverflow.com/questions/43021863/x86-assembly-input-a-set-of-integers