x86 Assembly Input a set of Integers

非 Y 不嫁゛ 提交于 2021-01-28 06:31:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!