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

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

ID: 654886 • Letter: 1

Question

1- 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''.

Explanation / Answer

## Ask user for temperature in Celsius,
## convert to Fahrenheit, print the result.
##
## v0 - reads in celsius
## t0 - holds Fahrenheit result
## a0 - points to output strings
##

.text
.globl __start
__start:
la $a0,prompt # print prompt on terminal
li $v0,4
syscall

li $v0,5 # syscall 5 reads an integer
syscall

# We use here two pseudo-instructions - mul and div
mul $t0,$v0,9 # to convert,multiply by 9,
div $t0,$t0,5 # divide by 5,then
add $t0,$t0,32 # add 32

la $a0,ans1 # print string before result
li $v0,4
syscall

move $a0,$t0 # print result
li $v0,1
syscall

la $a0,endl # system call to print
li $v0,4 # out a newline
syscall

li $v0,10
syscall # au revoir...