Question

.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 numbers IN input an integer character (ascii) TRAP 231 LD R3, HEXN30subtract x30 to get integer ADD RO, RO, R3 ADD R1, RO, x0move the first integer to register 1 IN input another integer [TRAP 23) ADD RO, RO, R3convert it to an integer add the numbers ADD R2, RO, R1 ;add the two integers ; print the results LEA RO, MESGload the address of the message string PUTS ADD RO, R2, x0 move the sum to RO, to be output LD R3, HEX30add 30 to integer to get integer character ADD RO, RO, R3 OUT PUTS outputs a string TRAP 221 ;display the sum TRAP 21) ;stop HALT. TRAP 25) ; data MESG .STRINGZ The sum of those two numbers is: HEXN30 FILL XFFDO-30 HEX HEX30 FILL x0030; 30 HEX END

; original codes provided as following

.ORIG x3000        ; begin at x3000

; input two numbers

IN                               ; input an integer character (ascii) {TRAP 23}

LD R3, HEXN30 ; subtract x30 to get integer

ADD R0, R0, R3

ADD R1, R0, x0 ; move the first integer to register 1

IN                               ; input another integer {TRAP 23}

ADD R0, R0, R3 ; convert it to an integer

; add the numbers

ADD R2, R0, R1 ; add the two integers

; print the results

LEA R0, MESG      ; load the address of the message string

PUTS                         ; "PUTS" outputs a string {TRAP 22}

ADD R0, R2, x0   ; move the sum to R0, to be output

LD R3, HEX30      ; add 30 to integer to get integer character

ADD R0, R0, R3

OUT                           ; display the sum {TRAP 21}

; stop

HALT       ; {TRAP 25}

; data

MESG .STRINGZ "The sum of those two numbers is: "

HEXN30 .FILL xFFD0 ; -30 HEX

HEX30 .FILL x0030 ; 30 HEX

.END

0 0
Add a comment Improve this question Transcribed image text
Answer #1

solution:

-------------------------------------------------------------------------------------------------------------------------------

Program : Program to add two double digit numbers .oria x3600 LEA RO, MESSAGE ;message PUTS ; Read first number LD R0, NEWLINE ;PROMPT! OUT OUT LEA R0, PROMPT! PUTS GETC OUT LD R6, M30 ADD RO, RO, R6 ADD RI, R0 , R0 ; R1 = 2xR0 ADD R2, R1, #0 ; copy R1 Into R2 ADD R2, R2, R2 ADD R2, R2, R2 ADD R2, R2, R1 GETC OUT ADD R0, RO, R6; convert to hex ADD R3, R2, R0 ; R3 = first decimal number ; Read input1 : convert char to hex ; Read input2 ; Read second number LEA RO, PROMPT2 :aet character one PUTS GETC OUT ADD RO, RO, R6 convert char to hex ADD R1, RO, R0R12xR0 ADD R2, R1, #0 ;copy R1 Into R2 ADD R2, R2, R2R2 4xRO ADD R2, R2, R2R28xRO GETC get character two

Add a comment
Know the answer?
Add Answer to:
; original codes provided as following .ORIG x3000        ; begin at x3000 ; input two numbers...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT