Sunday, December 20, 2009

8086 PROGRAM TO CONVERT THE TEMPERATURE IN DEGREE CELCIUS TO FAHRENHEIT AND KELVIN SCALE

;Q.Given a temperature in Centigrade(<100°C), WAP to convert it 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 99degree 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 segment
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
end start

8086 MASM PROGRAM TO Read in a binary string through keyboard and Display it in the reverse order.Also display its Parity.

assume ds:data1,cs:code1
data1 segment
msg db 0ah,0dh,'enter the binary number$'
number db 20,0,20 dup('$')
msg2 db 0ah,0dh,'the number in reversed order is$',0ah,0dh
odd db 0ah,0dh,'the number has odd parity$'
evenpar db 0ah,0dh,'the number has even parity$'
data1 ends

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

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

lea dx,number
mov ah,0ah
int 21h

mov bx,0000h
mov cx,bx
mov cl,number+1
lea si,number+2
again:mov ax,0001h
and al,[si]
jz skip
inc bx
skip:inc si
loop again

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

mov cx,0000h
mov cl,number+1
dec si
do:
mov dl,[si]
mov ah,02h
int 21h
dec si
loop do

mov ax,bx
mov bl,02h
div bl
and ah,01h
jnz oddpar
lea dx,evenpar
mov ah,09h
int 21h
jmp down
oddpar:
lea dx,odd
mov ah,09h
int 21h
down: mov ah,4ch
int 21h
code1 ends
end start






Saturday, December 5, 2009

8086 MASM PROGRAM TO FIND OUT WHETHER THE GIVEN YEAR IS A LEAP YEAR OR NOT

assume ds:data1,cs:code1
data1 segment
msg db 0ah,0dh,'enter the year$'
number db 6,0,6 dup('$')
ys db 0ah,0dh,'yes,it is a leap year$'
n db 0ah,0dh,'no,it is not a leap year$'
data1 ends
code1 segment
start:mov ax,seg data1
mov ds,ax
lea dx,msg

mov ah,09h
int 21h

lea dx,number
mov ah,0ah
int 21h
lea bx,number+4
mov ah,[bx]
mov al,[bx+1]
aad
mov bl,04h
div bl
and ah,0ffh
jz yes
lea dx,n
mov ah,09h
int 21h
jmp down
yes:lea dx,ys
mov ah,09h
int 21h
down: mov ah,4ch
int 21h
code1 ends
end start