number of 1s and parity
TRANSCRIPT
-
7/30/2019 Number Of 1s and Parity
1/6
data segment
msg db "Enter no: $"
maxl db 20
actl db ?
num db 5 dup(0)
msg1 db " Partiy bit 0$"
maxl1 db 20
actl1 db ?
msg2 db " Parity bit 1$"
maxl2 db 20
actl2 db ?
msg3 db " Odd Partiy $"
maxl3 db 20
actl3 db ?
msg4 db " Number of 1s : $"
maxl4 db 5
actl4 db ?
n1 db 10 dup('$')
data ends
-
7/30/2019 Number Of 1s and Parity
2/6
mystack segment
db 40 dup(0)
tos label word
mystack ends
code segment
assume cs:code , ds:data , ss:mystack
start:
mov ax,data
mov ds,ax
mov ah,09h
lea dx,msg
int 21h
mov ah,0ah
lea dx,maxl
int 21h
push dx
push ax
-
7/30/2019 Number Of 1s and Parity
3/6
lea bx,num
mov cl,[bx]
mov dl,[bx+1]
sub cl,30h
sub dl,30h
mov ah,00h
mov al,cl
mov dh,0ah
mul dh
add al,dl
mov cl,al
pop ax
pop dx
call number
mov ah,09h
lea dx,msg3
int 21h
mov bx,offset n1
add ch,30h
-
7/30/2019 Number Of 1s and Parity
4/6
mov [bx],ch
inc bx
mov ah,09h
lea dx,msg4
int 21h
mov ah,09h
lea dx,n1
int 21h
mov ah,4ch
int 21h
number proc near
mov ch,00h
again:
rcr cl,01h
jnc go
inc ch
-
7/30/2019 Number Of 1s and Parity
5/6
go:
cmp cl,00h
jnz again
mov ah,00h
mov al,ch
mov bh,02h
div bh
cmp ah,00h
jnz go1
mov ah,09h
lea dx,msg2
int 21h
jmp end1
go1:
mov ah,09h
lea dx,msg1
int 21h
end1:
ret
-
7/30/2019 Number Of 1s and Parity
6/6
endp number
code ends
end start
; [SOURCE]: C:\emu8086\MySource\Numberof 1s.asm