Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Make a flowchart for this set instructions. I would recommend that you develop a

ID: 3807810 • Letter: M

Question

Make a flowchart for this set instructions. I would recommend that you develop a flowchart for the add/print step before continuing. You can then modify this chart to handle subtraction. You are to modify this program to subtract these two numbers and display their difference. The desired output for the program is shown below. The desired output text is circled in the bottom left of the figure. You can assume that both inputs will be integers 0 to 9 and that the first input is greater than the second input. Thus, you can display only the positive results, such as 7 - 4 = 3.

Explanation / Answer

Following is the flowchart for this set of instructions.

Basically, This Program strips off the ascii value entered by user by adding xFFD0(which is -48).

In assembly, if user enters a value from the keyboard, what you get in register is the ascii value.

Suppose user enters 5, r0 will contain 53.To get the intended value , 48 (ascii val of 0) must be subtracted from it. after subtraction we will get 5.

similarly to display the correct result(ascii value of addition),48(x30) must be added to it.

Following is the program to subtract two numbers in lc3 assembly.

.Orig      x3000

LD           R6,ASCII

LD           R5,MEGASCII

TRAP     x23

Add        R1,R0,x0

Add        R1,R1,R5

TRAP     x23

Add        R0,R0,R5

Not        R0,R0

Add R0,R0,#1

Add        R0,R0,R1

Add        R0,R0,R6

TRAP     x22

HALT

ASCII     .FILL       x30

MEGASCII           .FILL       xFFD0

.END

Suppose user enters 2 values a and b. Above program outputs a-b.

Please let me know in case of any doubt.

Thanks

Basically, This Program strips off the ascii value entered by user by adding xFFD0(which is -48).

In assembly, if user enters a value from the keyboard, what you get in register is the ascii value.

Suppose user enters 5, r0 will contain 53.To get the intended value , 48 (ascii val of 0) must be subtracted from it. after subtraction we will get 5.

similarly to display the correct result(ascii value of addition),48(x30) must be added to it.

Following is the program to subtract two numbers in lc3 assembly.

.Orig      x3000

LD           R6,ASCII

LD           R5,MEGASCII

TRAP     x23

Add        R1,R0,x0

Add        R1,R1,R5

TRAP     x23

Add        R0,R0,R5

Not        R0,R0

Add R0,R0,#1

Add        R0,R0,R1

Add        R0,R0,R6

TRAP     x22

HALT

ASCII     .FILL       x30

MEGASCII           .FILL       xFFD0

.END

Suppose user enters 2 values a and b. Above program outputs a-b.

Please let me know in case of any doubt.

Thanks

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote