-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lab9.asm
121 lines (115 loc) · 1.67 KB
/
Lab9.asm
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
;Lab9.asm
include .\INCLUDE\Irvine16.inc
.model small
.data
pageVar db 00h
wordVar db 07h
.stack 100h
.code
main proc
mov ax, @data
mov ds, ax
L1:
mov ah, 10h
int 16h
cmp al, 1bh
je exitProcess
cmp al, 00h
jne not_special
;F1-F4 Press
cmp ah, 3Bh
je F1_press
cmp ah, 3ch
je F2_press
cmp ah, 3dh
je F3_press
cmp ah, 3eh
je F4_press
F1_press: ;Change cursor
call Change_cursor
jmp L1
F2_press: ;Change bg color
call change_bg
jmp L1
F3_press:
call change_color
jmp L1
F4_press: ;Random Num
mov ax, 25
call RandomRange
add ax, 41h
not_special: ;Display word
push ax
mov bl, wordVar
pop ax
mov bh, pageVar ;move page
mov cx, 2
mov ah, 09h ;Write word
int 10h
mov ah, 03h ;get cursor dh, dl
int 10h
add dl, 2
inc dh
mov ah, 02h ;Set cursor
int 10h
jmp L1
mov ax, 10h
exitProcess:
mov ah, 4ch
int 21h
main endp
Change_cursor proc
mov ah, 03h
mov bh, pageVar
int 10h
cmp ch, 20h
je set_minCursor
cmp ch, 00h
jne dec_cursor
mov ch, 20h
jmp write_cursor
set_minCursor:
mov ch, 06h
jmp write_cursor
dec_cursor:
dec ch
write_cursor:
mov ah, 01h
int 10h
ret
Change_cursor endp
change_bg proc
mov ah, wordVar
cmp ah, 11110000b
jae set_Zero
add ah, 00010000b
jmp set_BG
set_Zero:
mov cl, 4
shl ah, cl
shr ah, cl
set_BG:
mov wordVar, ah
ret
change_bg endp
change_color proc
mov ah, wordvar
push ax
mov cl, 4
shl ah, cl
shr ah, cl
cmp ah, 00001111b
je set_zero
inc ah
jmp set_color
set_zero:
mov ah, 00h
set_color:
pop bx
shr bh, cl
shl bh, cl
add ah, bh
mov wordvar, ah
ret
change_color endp
end main