Centigrade (Celsius) to Fahrenheit convertion and vice-versa.

; Centigrade (Celsius) to Fahrenheit
; calculation and vice-versa.
; (not very accurate, since using
; integer divide).

ORG 100h

JMP start

tc DB 10 ; t celsius.
tf DB 0 ; t fahrenheit.

result1 DB ? ; result in fahrenheit.
result2 DB ? ; result in celsius.

start:

; convert celsius to fahrenheit according
; to this formula: f = c * 9 / 5 + 32

MOV CL, tc
MOV AL, 9
IMUL CL
MOV CL, 5
IDIV CL
ADD AL, 32
MOV result1, AL

; convert fahrenheit to celsius according
; to this formula: c = (f - 32) * 5 / 9

MOV CL, tf
SUB CL, 32
MOV AL, 5
IMUL CL
MOV CL, 9
IDIV CL
MOV result2, AL

RET
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories