-
Notifications
You must be signed in to change notification settings - Fork 0
/
v3.asm
138 lines (119 loc) · 1.8 KB
/
v3.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
data segment
data ends
stackseg segment stack
db 400 dup(0)
TOP equ 400
stackseg ends
code segment
assume cs:code, ds:data, ss:stackseg
delay0 proc near
push dx
push cx
xor ax, ax
int 1ah
mov cs:Times, dx
mov cs:Times[2], cx
read_time0:
xor ax, ax
int 1ah
sub dx, cs:Times
sbb cx, cs:Times[2]
cmp dx, Diads
;jb表示小于则跳转,ja表示大于则跳转
jb read_time0
pop cx
pop dx
ret
delay0 endp
delay proc near
push dx
push cx
xor ax, ax
int 1ah
mov cs:Times, dx
mov cs:Times[2], cx
read_time:
mov ah, 01h ;check if a key is pressed
int 16h
jz notpressed ;zero = no pressed
mov ah, 0
int 16h
mov dl, al
cmp dl, 'z'
jnz judgeZ
mov dl, 'a'
sub dl, 1h
cmp dl, 'Z'
judgeZ:
cmp dl, 'Z'
jnz getsecret
mov dl, 'A'
sub dl, 1h
getsecret:
add dl, 1h
mov ah, 2h
int 21h
notpressed:
xor ax, ax
int 1ah
sub dx, cs:Times
sbb cx, cs:Times[2]
cmp dx, Diads
;jb表示小于则跳转,ja表示大于则跳转
jb read_time
pop cx
pop dx
ret
Times dw 0, 0
delay endp
;--------------------------------------------------------
Diads equ 182 ;延时10s
start:
mov ax, data
mov ds, ax
mov ax, stackseg
mov ss, ax
mov sp, TOP
mov al, 13h
out 20h, al
mov al, 8h
out 21h, al
mov al, 01h
out 21h, al
cli
mov ax,offset keyboard
mov word ptr es:[36],ax
mov ax,seg keyboard
mov word ptr es:[38],ax
sti
call delay0
;call keyboard
mov dx,offset leave
int 27h
keyboard:
push cx
push ax
push bx
pushf
pushf
pop ax
and ah, 11111100b
push ax
popf
mov bx, 3h
domore:
mov al, 02H ;写OCW1,屏蔽IR5、IR6、IR7中断源
out 21h, al ;假定这三个中断输入未用,其他开中断
call delay
mov al, 00H
out 21h, al
call delay
sub bx, 1h
jnz domore
pop bx
pop ax
pop cx
iret
leave:
code ends
end start