Thursday, January 21, 2010

8086 OR MASM PROGRAM TO CONVERT THE Given temperature in Centigrade(<100°C) to Fahrenheit and Kelvin and display it (i/p and o/p as Decimal numbers)

assume ds:data1,cs:code1
data1 segment
msg db 0ah,0dh,'enter the temperature in degree celsius',0ah,'$'
msg1 db 0ah,0dh,'error! enter a temperature less than 99 degree C$'
msg2 db 0ah,0dh,'the temperature in kelvin scale is=$'
msg3 db 0ah,0dh,'the temperature in farenheit scale is approximately=$'
msg4 db 0ah,0dh,'the temperature in celsius scale is=$'
temp db 6,0,6 dup('$')
result db 20,0,20 dup('$')

data1 ends
code1 seg
start:mov ax,seg data1
mov ds,ax

lea dx,msg
mov ah,09h
int 21h

mov ch,02h

ask:
lea dx,temp
mov ah,0ah
int 21h

lea dx,msg4
mov ah,09h
int 21h

lea dx,temp+2
mov ah,09h
int 21h

do:
lea bx,temp+1
mov cl,[bx]
inc bx
mov ah,[bx]
dec cl
jz down
mov al,[bx+1]
dec cl
jz down1
lea dx,msg1
mov ah,09h
int 21h
jmp ask

down:
mov al,ah
mov ah,00h
down1:
and ax,0f0fh
aad
dec ch
jz second
add ax,0111h;273 addition
call display
lea dx,msg2
call show
jmp do
second:
mov cl,09h
mul cl
mov cl,05h
div cl
mov ah,00h
add al,20h;hex equivalent of 32
call display
lea dx,msg3
call show
jmp over

display:lea bx,result+4
mov dl,03h
mov cl,0ah
again:
div cl
add ah,30h
mov [bx],ah
dec bx
mov ah,00h
dec dl
jnz again
ret

show:
mov ah,09h
int 21h
lea dx,result+2
mov ah,09h
int 21h
ret
over:
mov ah,4ch
int 21h
code1 ends

2 comments: