Sunday, December 20, 2009

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






No comments:

Post a Comment