This repository has been archived by the owner on Nov 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
7.2.asm
167 lines (152 loc) · 2.8 KB
/
7.2.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
DATA SEGMENT
NUMBER DB 40H,79H,24H,30H,19H,12H,02H,78H,00H,10H
MIN1 DB 0
MIN2 DB 0
SEC1 DB 0
SEC2 DB 0
CIR DW 800
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX, DATA
MOV DS, AX
MOV AL, 89H
MOV DX, 206H ;初始化
OUT DX, AL ;A,B输出,C输入
MOV BX, 0H
LEA SI, NUMBER
OUTPUT:
MOV AL, 00000001B
MOV DX, 200H ;选中第4个数码管
OUT DX, AL
MOV BL, SEC2 ;输出SEC2
MOV AL, [SI+BX]
MOV DX, 202H
OUT DX, AL
MOV CX, CIR
S4:
LOOP S4
MOV AL, 00000010B
MOV DX, 200H ;选中第3个数码管
OUT DX, AL
MOV BL, SEC1
MOV AL, [SI+BX]
MOV DX, 202H
OUT DX, AL
MOV CX, CIR
S3:
LOOP S3
MOV AL, 00000100B
MOV DX, 200H ;选中第2个数码管
OUT DX, AL
MOV BL, MIN2
MOV AL, [SI+BX]
MOV DX, 202H
OUT DX, AL
MOV CX, CIR
S2:
LOOP S2
MOV AL, 00001000B
MOV DX, 200H ;选中第3个数码管
OUT DX, AL
MOV BL, MIN1
MOV AL, [SI+BX]
MOV DX, 202H
OUT DX, AL
MOV CX, CIR
S1:
LOOP S1
;四个数码管显示结束,判断C端口状态
MOV DX, 204H
IN AL, DX
CMP AL, 06H
JE STOP ;STOP暂停计时
CMP AL, 03H
JE TAIL1 ;CLEAR清零计时
;没有按按键或者按了STRAT,增加秒数并判断是否进位
INC SEC2
CMP SEC2, 10
JNZ OUTPUT
;SEC2 = 10,进位
MOV SEC2, 0H
INC SEC1
CMP SEC1, 10
JNZ OUTPUT
;SEC1 = 10,进位
MOV SEC1, 0H
INC MIN2
CMP MIN2, 10
JNZ OUTPUT
;MIN2 = 10, 进位
MOV MIN2, 0H
INC MIN1
CMP MIN1, 10
JNZ OUTPUT
;MIN1 = 10,清零
MOV MIN1, 0H
JMP OUTPUT
STOP:
MOV AL, 00000001B
MOV DX, 200H ;选中第4个数码管
OUT DX, AL
MOV BL, SEC2
MOV AL, [SI+BX]
MOV DX, 202H
OUT DX, AL
MOV CX, CIR
S8:
LOOP S8
MOV AL, 00000010B
MOV DX, 200H ;选中第3个数码管
OUT DX, AL
MOV BL, SEC1
MOV AL, [SI+BX]
MOV DX, 202H
OUT DX, AL
MOV CX, CIR
S7:
LOOP S7
MOV AL, 00000100B
MOV DX, 200H ;选中第2个数码管
OUT DX, AL
MOV BL, MIN2
MOV AL, [SI+BX]
MOV DX, 202H
OUT DX, AL
MOV CX, CIR
S6:
LOOP S6
MOV AL, 00001000B
MOV DX, 200H ;选中第1个数码管
OUT DX, AL
MOV BL, MIN1
MOV AL, [SI+BX]
MOV DX, 202H
OUT DX, AL
MOV CX, CIR
S5:
LOOP S5
; 判断是继续计时、暂停还是清零
MOV DX, 204H
IN AL, DX
CMP AL, 05H ;START按键按下
JE OUTPUT
CMP AL, 03H ;CLEAR按键按下
JE TAIL2
JMP STOP
TAIL1:
CALL ZERO
JMP OUTPUT
TAIL2:
CALL ZERO
JMP STOP
ZERO PROC
MOV SEC2, 0H
MOV SEC1, 0H
MOV MIN1, 0H
MOV MIN2, 0H
RET
ZERO ENDP
CODE ENDS
END START