# CSE 322 Lab 6

March 6, 2018

#### Problem#1 (Chapter 7 problem 8) [Previous days hometask]

Write a program that 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.
Sample execution:
TYPE A CHARACTER: A
THE ASCII CODE OF A IN BINARY IS 01000001
THE NUMBER OF l BITS IS 2

//Solution

```mov ah, 1
int 21h
mov bl, al

mov bh, 0
mov cx, 8

mov ah, 2
mov dl, 0Ah
int 21h
mov dl, 0Dh
int 21h

start:
ROL BL, 1
Jc one

zero:
mov dl, '0'
int 21h
jmp end_

one:
inc bh
mov dl, '1'
int 21h

end_:

loop start

mov dl, 0ah
int 21h
mov dl, 0dh
int 21h

mov dl, bh
int 21h```

#### Problem#2 (Chapter 8)

Reversing Inputs

//Solution

```mov cx, 0

mov ah, 1
int 21h

while:
cmp al, 0dh
je end_while
push ax
inc cx
int 21h
jmp while

end_while:

mov ah, 2
mov dl, 0dh
int 21h
mov dl, 0ah
int 21h
print:
pop dx
int 21h
loop print```

#### Problem#3 (Chapter 7 problem 12)

Write a program that prompts the user to enter two binary numbers of up to 8 digits each, and prints their sum on the next line in binary. If the user enters an illegal character, he or she should be prompted to begin again. Each input ends with a carriage return.
Sample execution:
TYPE A BINARY NUMBER, UP TO 8 DIGITS: 11001010
TYPE A BINARY NUMBER, UP TO 8 DIGITS: 10011100
THE BINARY SUM IS 101100110

//Solution

`To be Done by students`