Assembly Introduction To Screen and Keyboard Processing
Assembly Introduction To Screen and Keyboard Processing
The Screen
A typical video monitor has 25 rows (numbered 0 to 24) and 80 columns (numbered 0 to 79). The rows
and columns provide a grid of addressable locations at any one of which the cursor can be set.
Examples:
Screen Location Decimal Hexadecimal
Row Col Row Col
Upper left corner 00 00 00h 00h
Upper right cornet 00 79 00h 4fh
Center of screen 12 34/40 0ch 27h/28h
Lower left corner 24 00 18h 00h
Lower right corner 24 79 18h 4fh
Ex.
mov ah,02h ;Request set cursor
mov bh,00 ;Page number 0
mov dh,08 ;Row 8
mov dl,15 ;Column 15
int 10h ; Call interrupt service
Ex.
mov ah,0600h ;Ah=06 (scroll), Al = 00 (full screen)
mov bh,71h ;White background (7), blue foreground (1)
mov cx,0000h ;Upper left row: column
mov dx,184fh ;Lower right row: column
int 10h
Ex.
Paralst Label Byte
Maxlen db 20
Actlen db ?
Kbdata db 20 DUP (‘ ‘)
Request input :
Mov ah,0ah ;request keyboard input
Lea dx,paralst ;load address of parameter list
Int 21h ;call interrupt service
2
Ex. ACTLEN contains 11, then the enter character is at KBNAME+11.
Mov bx, actlen
Mov kbname[bx],20h
Ex.
Mov cx,20
Mov si, 00
Again:
Mov kbname[si],20h
Inc si
Loop again
Ex.
Using EQU to redefine the control characters may make a program more readable:
Ex.
CR EQU 13
LF EQU 10
3
TAB EQU 09
Reptitle db TAB,’Xpdotnet Annual Report’,CR,LF,’$’
Ex.
Cotitle db ‘xpdotnet Computer Services’, 13, 10, ‘S’
…….
Mov ah,02h
Mov cx,28
Lea di,Cotitle
Again:
Mov dl,[di]
Int 21h
Inc di
Loop again
FILE HANDLES
A file handle is simply a number that refers to a specific device.
o File Handle Presets:
Handle Device
00 Input, normally keyboard, but may be redirected
01 Output, normally display, but may be redirected
02 Error output, display, may not be redirected
03 Auxiliary device (AUX)
04 Printer (LPT1 or PRN)
Ex.
Cotitle db ‘xpdotnet Computer Services’, 13, 10, ‘S’
…….
Mov ah,40h
Mov bx,01
Mov cx,28
Lea dx,Cotitle
4
Int 21h
Mov ah,40
Mov bx,0a
Mov cx,xx (length of your name)
Mov dx,10e
Int 21
Nop
Db ‘x-----------------x’ (insert your name here)
Ex.
Kbinput db 20 dup(‘ ‘)
………….
Mov ah,3fh
Mov bx,00
Mov cx,20
Lea dx,kbinput
Int 21h
Mov ah,3fh
Mov bx,00
Mov cx,0C
Mov dx,10f
Int 21h
Jmp 100
Db 20 20 20 20 20 20 20 20 20 20 20 20