Question: 1. Modify this add program so that the user can input two numbers and then subtract the two integers. Displays the difference on the screen.

1. Modify this add program so that the user can input two numbers and then subtract the two integers. Displays the difference on the screen.

2. Further, modify the program to display negative results.

3. Create a flowchart for your algorithm, illustrating each register and their meaning.

ORIG x3000 LD R6, ASCII LD R5, NEGASCII TRAP x23 ;the trap instruction which is also known as "IN" ADD R1,R0,x0 ;move the first integer to register 1 ADD R1,R1,R5 ;convert first ASCII number to numerical value TRAP x23 ;another "IN" ADD R0,R0,R5 ;convert next ASCII number to numerical value ADD R2,R0,R1 ;add the two integers ADD R2,R2,R6 ;convert the sum to its ASCII representation LEA R0,MESG ;load the address of the message string TRAP x22 ;"PUTS" outputs a string ADD R0,R2,x0 ;move the sum to R0, to be output TRAP x21 ;display the sum HALT ASCII .FILL x30 ;the mask to add to a digit to convert it to ASCII NEGASCII .FILL xFFD0 ;the negative version of the ASCII mask MESG .STRINGZ "The sum of those two numbers is " .END

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!