I am a student and need help learning assembly language. I simply want to print out 3 the values that I entered to the console. The goal of the program is to get 3 positive integers, A, B and C, in descending order from the console. When I run the program and enter 20 for the first value, 10 for the second value, and 5 for the third value, the expectation is that those values will each be printed out. However, 20 is the only value that seems to be printed out.
I expected to see 20105 but instead I saw 202020.
Here is the current code:
.data
promptFirstNum BYTE "First number: ", 0
promptSecondNum BYTE "Second number: ", 0
promptThirdNum BYTE "Third number: ", 0
; Declare all of the values for what the user will enter
valueA DWORD ?
valueB DWORD ?
valueC DWORD ?
.code
main PROC
; Ask for first number and set it to valueA
MOV EDX, OFFSET promptFirstNum
call WriteString
call ReadDec
MOV valueA, EAX
; Ask for second number and set it to valueB
MOV EDX, OFFSET promptSecondNum
call WriteString
call ReadDec
MOV valueB, EBX
; Ask for third number and set it to valueC
MOV EDX, OFFSET promptThirdNum
call WriteString
call ReadDec
MOV valueC, ECX
call CrLf
call CrLf
; This section will be for testing, it should pring out 20105 if it works correctly
MOV EAX, valueA
call WriteDec
MOV EBX, valueB
call WriteDec
MOV ECX, valueC
call WriteDec
call CrLf
Invoke ExitProcess,0; exit to operating system
main ENDP
END main.data
Kneemo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1