Modify the following program so it can add two numbers between the values 0 and 9. The current program only handles one digit as the sum. Your program must handle up to 9 + 9 as input and output up to 18. Here is the starter program:
.ORIG x3000 ; begin at x3000; input two numbersIN ;input an integer character (ascii) {TRAP 23}LD R3, HEXN30 ;subtract x30 to get integerADD R0, R0, R3ADD R1, R0, x0 ;move the first integer to register 1IN ;input another integer {TRAP 23}ADD R0, R0, R3 ;convert it to an integer; add the numbersADD R2, R0, R1 ;add the two integers; print the resultsLEA R0, MESG ;load the address of the message stringPUTS ;"PUTS" outputs a string {TRAP 22}ADD R0, R2, x0 ;move the sum to R0, to be outputLD R3, HEX30 ;add 30 to integer to get integer characterADD R0, R0, R3OUT ;display the sum {TRAP 21}; stopHALT ;{TRAP 25}; dataMESG .STRINGZ "The sum of those two numbers is: "HEXN30 .FILL xFFD0 ; -30 HEXHEX30 .FILL x0030 ; 30 HEX.END
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here