CSEG segment assume CS CSEG DS CSEG ES CSEG SS CSEG org 100h _start ca

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
CSEG segment
assume CS:CSEG, DS:CSEG, ES:CSEG, SS:CSEG
org 100h
_start:
call CLEAR_SCREEN
mov cx, 2000
_cin:
mov ah, 10h
int 16h
call PRINT_KEY
loop _cin
PRINT_KEY proc
cmp al, 0 ; if (al == 0) ah != 0
jz _start
cmp al, 1Bh ; if(<ESC>) (<esc> code = 27)
jz _esc ; <ESC> = <SPACE>
push es
push ax
mov ax, 0B800h ; videobuffer segment
mov es, ax
mov ax, 2000
push cx
sub cx, ax
mov ax, cx
pop cx
mov di, ax
pop ax
mov es:[di], ax
pop es
ret
PRINT_KEY endp
CLEAR_SCREEN proc
mov cx, 2000
loop _print_space
ret
CLEAR_SCREEN endp
_esc:
mov al, 20h ; <SPACE> code = 32
call PRINT_KEY
_print_space:
mov al, 20h
call PRINT_KEY
CSEG ends
end _start