
8-22
x86 MICROPROCESSORS
Example 8.7
Next, let us write a simple program to make the screen green in color on pressing the
‘G’ key.
Solution
.MODEL TINY
.CODE
.STARTUP
MOV AH, 01 ;DOS interrupt for keyboard entry
INT 21H ;the code of the key pressed is in AL
CMP AL, ‘G’ ;compare AL with the code of ‘G’ key
JNE LAST ;if not equal, jump to LAST
MOV AH, 0 ;set video mode
MOV AL, 02 ;mode = 2
INT 10H ;clear screen after setting the mode
MOV AH, 09 ;display function
MOV BH, 0 ;page 0
MOV BL, 22H ;green background with green foreground
MOV CX, 2000 ;number of characters = 2000
INT 10H
LAST:
.EXIT
END
In Example 8.7, ...