# CSE 322 Fall 2018 Lab 4

### Problem #1 (Example 6.6) [AND condition]

Read a character, and if it’s an uppercase letter, display it.

//Solution
mov ah, 1
int 21h

cmp al, 'A'
jl not_print
cmp al, 'Z'
jg not_print

print:
mov ah, 2
mov dl, al
int 21h
not_print:

//Alternative COde
mov ah, 1
int 21h

cmp al, 'A'
jge next
jmp not_print
next:
cmp al, 'Z'
jle print
jmp not_print

print:
mov ah, 2
mov dl, al
int 21h
not_print:

### Problem #2 (Example 6.7) [OR condition]

Read a character. If it’s “y” or “Y”, display it; otherwise, terminate the program.

//SOlution
mov ah, 1
int 21h

cmp al, 'y'
je exit
cmp al, 'Y'
je exit
jmp label2
Exit:
mov ah, 4ch
int 21h
label2:
mov ah, 2
mov dl, 'H'
int 21h

### Problem #3 (Example 6.9) [While structure]

Write some code to count the number of characters In an input line.

//Solution
mov cx, 0
mov ah, 1
while_:
int 21h
cmp al, 0dh
je end_while
inc cx
jmp while_
end_while:
mov ah, 4ch
int 21h

### Problem #4 (Example 6.10) [Repeat Structure]

Write some code to read characters until a blank is read.

//Solution
mov ah, 1
top:
int 21h
cmp al, ' '
jne top

### Problem #5 (Chapter 6 Exercise 9)

Write a program to display the extended ASCII characters (ASCII codes 80h to FFh). Display 10 characters per line, separated by blanks. Stop after the extended characters have been displayed once.

//Solution
To be done by students

### Problem #6(Chapter 6 Exercise 10)

Write a program that will prompt the user to enter a hex digit character (“0″·… “9” or “A” … “F”), display it on in decimal. If the user enters an illegal character, display ‘i’ to indicate invalid input and allow to enter new hex number.

Sample execution
0-0
1-1
2-2
A-10
B-11
C-12
D-13
X-i
z-i
a-i
E-14
F-15
8-8

//Solution
To be done by students

### Problem #7 (Chapter 6 Exercise 11)

Do problem no 6 but if three invalid input is given, terminate the program

//Solution
To be done by students