In: Computer Science
**Add comments to existing ARM code to explain steps**
Write an ARM assembly program to convert temperatures from Celsius to Fahrenheit or from Fahrenheit to Celsius. Here are the two formulas for your reference. Use variable to read and store values.
C= 5* (F - 32) / 9
F = (9 * C / 5 ) + 32
My code below:
TempConvert.s
LDR R8,=temperature
LDR R1,[R8]
LDR R8,=unit
LDRB R2,[R8]
LDR R8,=celsius
LDRB R3,[R8]
LDR R8,=fahrenheit
LDRB R4,[R8]
MOV R6,#9
MOV R7,#5
;----C = 5 * (F - 32) / 9
SUB R5,R1,#32
MUL R5,R5,R7
UDIV R5,R5,R6
;------F = (9 * C / 5) + 32
MUL R5,R1,R6
UDIV R5,R5,R7
ADD R5,R5,#32
stop B stop
temperature DCD 50
unit DCB "F",0
celsius DCB "C",0
fahrenheit DCB "F",0
END
Given that,
C= 5* (F - 32) / 9
F = (9 * C / 5 ) + 32
if you have any other doubts u can comment so that ill solve it for you thanks for giving me this opportunity.