-
Notifications
You must be signed in to change notification settings - Fork 0
/
setclock.asm
260 lines (229 loc) · 3.04 KB
/
setclock.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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
assume cs:code
code segment
start:
mov bx,0b800h
mov es,bx
mov bx,0
mov cx,2000
sub1s:
mov byte ptr es:[bx],' '
add bx,2
loop sub1s
start0:
mov bx,0b800h
mov es,bx
mov si,160*12+20
mov al,8
call near ptr readtime
mov byte ptr es:[si+6],'\'
add si,10
mov al,7
call near ptr readtime
mov si,160*13+20
mov al,4
call near ptr readtime
mov byte ptr es:[si+6],':'
add si,10
mov al,2
call near ptr readtime
mov bx,0860h
mov ds,bx
;mov word ptr top,0
sss:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;y
mov dh,12
mov dl,11
mov ah,2
mov bh,0
int 10h
mov si,0
call getstr
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;d
mov dh,12
mov dl,16
mov ah,2
mov bh,0
int 10h
mov si,0
call getstr
ssss:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;h
mov si,0
mov dh,13
mov dl,11
mov ah,2
mov bh,0
int 10h
call getstr
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mov si,0
mov dh,13
mov dl,16
mov ah,2
mov bh,0
int 10h
call getstr
;;;;;;;;;;;;;;;;;;;;;;;;;
mov si,160*12+20
mov al,8
call near ptr writeime
add si,10
mov al,7
call near ptr writeime
mov si,160*13+20
mov al,4
call near ptr writeime
add si,10
mov al,2
call near ptr writeime
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mov word ptr [bx],0
mov word ptr [bx+2],0820h
jmp dword ptr [bx]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
readtime:
out 70h,al
in al,71h
mov ah,al
mov cl,4
shr ah,cl
and al,00001111b
add ah,30h
add al,30h
mov byte ptr es:[si],ah
mov byte ptr es:[si+2],al
ret
;;;;;;;;;;;;;;;;;;;;;;;;
writeime:
out 70h,al
mov ah,byte ptr es:[si]
mov al,byte ptr es:[si+2]
sub ah,30h
sub al,30h
mov cl,4
shl ah,cl
or al,ah
out 71h,al
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
getstr:
push ax
getstrs:
mov ah,0
int 16h
cmp al,30h
jb nochar
cmp al,39h
ja nochar
mov ah,0
call charstack
mov ah,2
call charstack
jmp getstrs
nochar:
cmp ah,0eh
je backspace
cmp ah,4bh
je uenter
cmp ah,48h
je uenter
cmp ah,1ch
je enter
cmp ah,1ch
je enter
jmp getstrs
backspace:
mov ah,1
call charstack
mov ah,2
call charstack
jmp getstrs
enter:
mov word ptr top,0
mov al,0
mov ah,2
call charstack
pop ax
ret
uenter:
cmp dh,12
jne uenterok
cmp dl,16
jne ssret
uenterok:
mov ah,1
call charstack
mov ah,1
call charstack
mov bp,sp
sub word ptr [bp],offset ssss-offset sss
ssret:
pop ax
ret
charstack:
jmp short charstart
table dw charpush,csharpop,charshow
top dw 0
charstart:
push bx
push dx
push di
push es
cmp ah,2
ja sret
mov bl,ah
mov bh,0
add bx,bx
jmp word ptr table[bx]
charpush:
cmp word ptr top,2
jna dat
charpush_n:
mov bx,top
mov [si][bx],al
inc top
jmp sret
csharpop:
cmp top,0
je sret
dec top
mov bx,top
mov al,[si][bx]
jmp sret
charshow:
mov bx,0b800h
mov es,bx
mov al,160
mov ah,0
mul dh
mov di,ax
add dl,dl
mov dh,0
add di,dx
mov bx,top
charshows:
cmp bx,0
jne noempty
jmp sret
noempty:
mov al,[si][bx]
mov es:[di],al
dec bx
sub di,2
jmp charshows
sret:
pop es
pop di
pop dx
pop bx
ret
dat:
mov word ptr top,1
mov bx,top
dec bx
mov ah,[si][bx+1]
mov [si][bx],ah
mov [si][bx+1],al
jmp sret
code ends
end start