Write a program that's prompts the user to enter a character, and on subsequent lines prints its ASCII code in binary, and the number of 1 bits In Its ASCII code
Write a program that's prompts the user to enter a character, and on subsequent lines prints its ASCII code in binary, and the number of 1 bits In Its ASCII code
Solution:
.model small.stack 100h
.data
msg1 DB 'TYPE A CHARACTER:$'
msg2 DB 0DH,0AH,'THE ASCII CODE OF :$'
msg3 DB ' IN BINARY IS :$'
msg4 DB 0DH,0AH,'THE NUMBER OF 1 BITS IS: $'
.code
main proc
mov ax,@data
mov ds,ax
lea dx,msg1
mov ah,9
int 21h
mov ah,1
int 21h
xor bx,bx
mov bl,al
lea dx,msg2
mov ah,9
int 21h
mov dl,bl
mov ah,2
int 21h
lea dx,msg3
mov ah,9
int 21
mov cx,8
mov bh,0
binary:
shl bl,1
jnc zero
inc bh
mov dl,31h
jmp display
zero:
mov dl,30h
display:
mov ah,2
int 21h
loop binary
ADD bh,30h
lea dx,msg4
mov ah,9
int 21h
mov dl,bh
mov ah,2
int 21h
mov ah,4ch
int 21h
No comments