NASM PROGRAM FOLLOWING THE CODE BELOW, modify it Write an assembly program for the family propcessor x86 in order to transform a temperature from the Celsius scale to the Fahrenheit scale according the transformation below; F=1.8*C +32 Use arithmetic of real numbers for the evaluation of the formula and get the result with two digit of precision in the decimal part. Insert the input by using the keyboard and show the output on the console. section .text global main extern printf extern scanf section .data message: db "The temperture in Fahrenheits: %d.", 0 msg2: db "%d", 10, 0 request: db "Enter a temperature in Celsius: ", 0 celsius: times 4 db 0 ; 32-bits integer = 4 bytes reminder: times 4 db 0 formatin: db "%d", 0 main: ; Ask for an integer push request call printf add esp, 4 ; remove the parameter push celsius ; address of integer1, where the input is going to be stored (second parameter) push formatin ; arguments are right to left (first parameter) call scanf add esp, 8 ; remove the parameters ; Move temperature in Celsius under the address integer1 to EAX mov eax, [celsius] call c2f ; jump to function to Transform temperature C2F ; Print out the content of eax register with the temperature in Fahremheits push eax push message call printf add esp, 8 ; Get fractional part. We use the relationship d1=2*r mov eax, [reminder] imul eax, 2 ;mov ebx, 2 ;imul ebx; ; Syntax imul r/m32 ; Print fractional part push eax push msg2 call printf add esp, 8 ; Linux terminate the app mov al, 1 mov ebx, 0 int 80h ; Transform temperature C2F c2f: mov edx, 0 imul eax,9 add eax,160 mov ebx, 5 idiv ebx mov [reminder], edx ret
Use arithmetic of real numbers for the evaluation of the formula and get the result with two digit of precision in the decimal part. Insert the input by using the keyboard and show the output on the console.
section .text
global main
extern printf
extern scanf
section .data
message: db "The temperture in Fahrenheits: %d.", 0
msg2: db "%d", 10, 0
request: db "Enter a temperature in Celsius: ", 0
celsius: times 4 db 0 ; 32-bits integer = 4 bytes
reminder: times 4 db 0
formatin: db "%d", 0
main:
; Ask for an integer
push request
call printf
add esp, 4 ; remove the parameter
push celsius ; address of integer1, where the input is going to be stored (second parameter)
push formatin ; arguments are right to left (first parameter)
call scanf
add esp, 8 ; remove the parameters
; Move temperature in Celsius under the address integer1 to EAX
mov eax, [celsius]
call c2f ; jump to function to Transform temperature C2F
; Print out the content of eax register with the temperature in Fahremheits
push eax
push message
call printf
add esp, 8
; Get fractional part. We use the relationship d1=2*r
mov eax, [reminder]
imul eax, 2
;mov ebx, 2
;imul ebx; ; Syntax imul r/m32
; Print fractional part
push eax
push msg2
call printf
add esp, 8
; Linux terminate the app
mov al, 1
mov ebx, 0
int 80h
; Transform temperature C2F
c2f:
mov edx, 0
imul eax,9
add eax,160
mov ebx, 5
idiv ebx
mov [reminder], edx
ret
Trending now
This is a popular solution!
Step by step
Solved in 2 steps