gordon sung
gordon sung

Reputation: 605

x86 Assembly Input a set of Integers

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

Upvotes: 1

Views: 1059

Answers (1)

Michael
Michael

Reputation: 58507

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.

Upvotes: 2

Related Questions