CSEG segment assume CS CSEG DS CSEG ES CSEG SS CSEG org 100h _zapuskat

 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
53
54
55
56
57
58
59
60
CSEG segment
assume CS:CSEG, DS:CSEG, ES:CSEG, SS:CSEG
org 100h
_zapuskator:
mov di, 0 ; start position
mov ax, 20h ; <SPACE>
mov cx, 2000 ; console space = 2000 symbols
_clear_screen:
call PRINT_LETTER
loop _clear_screen
mov di, 0 ; reset position
jmp _printer
_printer:
call INPUT_LETTER
call CHECK_LETTER
call PRINT_LETTER
jmp _printer
PRINT_LETTER proc
;push sp ; save address
push ax ; save key
mov ax, 0B800h ; videobuffer segment
mov es, ax
pop ax ; restore key
mov ah, 31 ; blue bg, white letters
;mov di, 0 ; offset segment
mov es:[di], ax
add di, 2 ; ax = 2 bytes
ret
PRINT_LETTER endp
INPUT_LETTER proc
mov ah, 10h ; input function
int 16h ; bios
ret
INPUT_LETTER endp
CHECK_LETTER proc
cmp al, 0 ; if (al == 0) ah != 0
jz _printer ; ignore
cmp al, 1Bh ; if (<ESC>)
jz _exit
ret
CHECK_LETTER endp
_exit:
int 20h
CSEG ends
end _zapuskator