You are on page 1of 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

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

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

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

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

endp number

code ends end start

; [SOURCE]: C:\emu8086\MySource\Numberof 1s.asm

You might also like