-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClock.asm
More file actions
114 lines (96 loc) · 1.93 KB
/
Clock.asm
File metadata and controls
114 lines (96 loc) · 1.93 KB
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
IDEAL
MODEL small
STACK 100h
DATASEG
seconds db ?
CODESEG
start:
mov ax, @data
mov ds, ax
;first print
mov ah, 2Ch
int 21h
mov [seconds], dh
call PrintTime
Printing:
;check for keypress to exit
mov ah, 01h
int 16h ; check buffer from keyboard
jz Nokey ; ZF=1 → no input → continue loop
; key is pressed
mov ah, 00h
int 16h ; clear buffer
jmp exit
Nokey:
mov ah, 2Ch ;get current time
int 21h
cmp [seconds], dh ;if time has not changed, keep waiting
je Printing
mov [seconds], dh ;update only if time changed
call PrintTime
jmp Printing
exit:
mov ax, 4c00h
int 21h
Proc PrintTime
;setting up videoram
mov ax, 0B800h
mov es, ax
mov di, 3984 ;(24 * 80 + 72) * 2 = 3984 — bottom-right position for HH:MM:SS
cld
;getting current time.
mov ah, 2Ch
int 21h
;printing hours
xor ax, ax
mov al, ch ;hours
mov bl, 10
div bl ;Quotient is in al, remainder is in ah
add al, '0' ;ASCII of the first num
add ah, '0' ;ASCII of the second num
;printing numbers
mov bh, ah
mov ah, 72h
stosw
mov al, bh
mov ah, 72h
stosw
;colons printing
mov al, ':'
mov ah, 70h
stosw
;printing minutes
xor ax, ax
mov al, cl ;minutes
mov bl, 10
div bl ;Quotient is in al, remainder is in ah
add al, '0' ;ASCII of the first num
add ah, '0' ;ASCII of the second num
;printing numbers
mov bh, ah
mov ah, 71h
stosw
mov al, bh
mov ah, 71h
stosw
;colons printing
mov al, ':'
mov ah, 70h
stosw
;printing seconds
xor ax, ax
mov al, dh ;seconds
mov bl, 10
div bl ;Quotient is in al, remainder is in ah
add al, '0' ;ASCII of the first num
add ah, '0' ;ASCII of the second num
;printing numbers
mov bh, ah
mov ah, 74h
stosw
mov al, bh
mov ah, 74h
stosw
ret
endp
END start