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

LC-3 Assembly Program Write a program in LC-3 assembly language. This program co

ID: 655234 • Letter: L

Question

LC-3 Assembly Program

Write a program in LC-3 assembly language. This program converts temperature to Fahrenheit. Use single digit (0-9) for the temperature.

The following message will be displayed first:

LC-3 Assembly Program Write a program in LC-3 assembly language. This program converts temperature to Fahrenheit. Use single digit (0-9) for the temperature. The following message will be displayed first: ??Enter 1 for converting to the Fahrenheit, or 2 for no conversion, or 3 for exit. Depends on which number you enter the program displays the next messages: For input 1 or 2 it displays: ??Enter the temperature in Celsius?? For input 3 it displays: ??Have a nice day?? After entering the temperature, the program saves the temperature according to the requested operations at the location x3100. This process continues in a loop until you enter 3 for the exit. Example: If the user types 1, and then 5, the program stores 41 in the memory location x3100, since 5*9/5+32=41 and then it displays ??Enter 1 for converting to the Fahrenheit, or 2 for no conversion, or 3 for exit. If the user enters 2, the program displays 5, and then it displays ??Enter 1 for converting to the Fahrenheit, or 2 for no conversion, or 3 for exit. If the user enters 3 the program exits and displays ??have a nice day??. I started the multipcation part which is... ..ORIG x 4000 HERE AND R2,R2,ftO AND R3,R3,UO AND R4,Ra,UO LEA RO, LABEL1 TRAP x22 ; GETTING FIRST INPUT TRAP X23 ADD R2,R2,RO LEA RO, LABEL2 TRAP x22 ; GETTING SECOND INPUT TRAP X23 ADD R3,R3,RO ; CONUERTING THE ASCII TO NUMBERS ADD R2,R2,U-16 ADD R2,R2,U-16 ADD R2,R2,U-16 ADD R3,R3,fl?16 ADD R3,R3,4?16 ADD R3,R3,U?16 BRz ZERO ; STARTING THE MULTIPLICATION AGAIN ADD R4,R4,R2 ADD R3,R3,U?1 BRP AGAIN BRZ FINISH ZERO AND Rb,R4,flO LEA RO, LABEL3 TRAP x22 TRAP x25 LABEL1 .STRINGZ PLEASE ENTER FIRST NUMBER n LABEL2 .STRINGZ PLEASE ENTER SECOND NUHBER n LABEL3 .STRINGZ DONE . END

Explanation / Answer

.ORIG X3000
DO_TOP
LEA   R0,Menu   ;load the address of the 'Menu' string
PUTS   ;display the menu

;store input temperature in celcius
GETC
ADD R1, R0, #0
ADD R1, R1, R5

AGAIN   ADD R4,R1,A
   ADD R3,R3,#-1
   BRP AGAIN
  
DIVIDE ADD R4, R2, #1
   ADD R3, R2, R1

ADD R4,R4,C

LEA   R0,Result   ;load the address of the 'Result' string
PUTS   ;display temperature in farenhite
HALT

BRn DO_TOP

Menu   .STRINGZ   "Enter 1 for converting to the Fahrenheit, or 2 for no conversion, or 3 for exit"
Result   .STRINGZ   "Tempratue in Farenhite: "
A   .FILL 9
B   .FILL 5
C   .FILL 32
.END