Task #1 (Example 6.6) [AND condition]
Read a character, and if it’s an uppercase letter, display it.
//Code .MODEL small .STACK 100H .DATA .CODE MAIN Proc mov ax, @data mov ds, ax mov ah, 1 int 21h cmp al, 'A' jl noPrint cmp al, 'Z' jg noPrint mov ah, 2 mov dl, al int 21h noPrint: ;Exit code mov ah, 4ch int 21h endp MAIN end MAIN
Task #2 (Example 6.7) [OR condition]
Read a character. If it’s “y” or “Y”, display it; otherwise, terminate the program.
//Code .MODEL small .STACK 100H .DATA .CODE MAIN Proc mov ax, @data mov ds, ax mov ah, 1 int 21h cmp al, 'Y' je print cmp al, 'y' je print jmp exit print: mov ah, 2 mov dl, al int 21h exit: ;Exit code mov ah, 4ch int 21h endp MAIN end MAIN
Task #3 (Example 6.9) [While structure]
Write some code to count the number of characters In an input line.
//Code .MODEL small .STACK 100H .DATA .CODE MAIN Proc mov ax, @data mov ds, ax mov cx, 0 mov ah, 1 abc: int 21h cmp al, 0dh je exit inc cx jmp abc exit: ;Exit code mov ah, 4ch int 21h endp MAIN end MAIN
Task #4 (Example 6.10) [Repeat Structure]
Write some code to read characters until a blank is read.
//Code .MODEL small .STACK 100H .DATA .CODE MAIN Proc mov ax, @data mov ds, ax mov ah, 1 abc: int 21h cmp al, ' ' jne abc exit: ;Exit code mov ah, 4ch int 21h endp MAIN end MAIN
Task #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
Task #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
Task #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
Homework
- Section 6.5: Programming with High-Level Structures
- Chapter 6 Exercise 8