Integer to float convesion: // make sure code is in mips assembly ! thanks. Reme
ID: 3799507 • Letter: I
Question
Integer to float convesion:
// make sure code is in mips assembly ! thanks.
Remember: Grading will be on program correctness and comment completeness. (Every line of code should be commented. Also be sure to fill out the template comments.)
1. Write a program in MIPS assembly that prompt the user for a temperature in Celsius and then display the result in Fahrenheit.
Sample Output:
Please input a temperature in Celsius
=> 39
The temperature in Fahrenheit is: =>
102.19999695
Explanation / Answer
Answer:
DATA SEGMENT
T DB ?
RES DB 10 DUP ('$')
MSG1 DB "Please input a temprature in Celsius : $"
MSG2 DB 10,13,"The temperature in Fahrenhite is : $"
DATA ENDS
CODE SEGMENT
ASSUME
DS:DATA,CS:CODE
START:
MOV AX,
DATA MOV DS,
AX LEA DX,
MSG1 MOV AH,9
INT 21H
MOV AH,1
INT 21H
SUB AL,30H
MOV AH,0
MOV BL,10
MUL BL
MOV BL,AL
MOV AH,1
INT 21H
SUB AL,30H
MOV AH,0
ADD AL,BL
MOV T,AL
MOV DL,9
MUL DL
MOV BL,5
DIV BL
MOV AH,0
ADD AL,32
LEA SI,RES
CALL HEX2DEC
LEA DX,MSG2
MOV AH,9
INT 21H
LEA DX,RES
MOV AH,9
INT 21H
MOV AH,4CH
INT 21H
CODE ENDS
HEX2DEC PROC NEAR
MOV CX,0
MOV BX,10
LOOP1: MOV DX,0
DIV BX
ADD DL,30H
PUSH DX
INC CX
CMP AX,9
JG LOOP1
ADD AL,30H
MOV [SI],AL
LOOP2:
POP AX
INC SI
MOV [SI],AL
LOOP LOOP2
RET
HEX2DEC ENDP
END
START
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.