-
Notifications
You must be signed in to change notification settings - Fork 0
/
program.asm
95 lines (68 loc) · 1.16 KB
/
program.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
BITS 16
section .bss
digits resb 2
section .text
global _start
_start:
xor ax, ax
mov byte [digits], 0
mov byte [digits + 1], 0
call display_time
call display_crlf
mov ah, 4ch
int 21h
display_time:
push bp
mov bp, sp
mov ah, 2Ch
int 21h
mov al, ch
call display_digits
mov ah, 02h
mov dl, ':'
int 21h
mov al, cl
call display_digits
mov ah, 02h
mov dl, ':'
int 21h
mov al, dh
call display_digits
leave
ret
display_digits:
push bp
mov bp, sp
call extract_digits
add byte [digits], 30h
add byte [digits + 1], 30h
mov ah, 02h
mov dl, [digits] ; Reads the tens of hour
int 21h
mov dl, [digits + 1] ; Reads the units of hour
int 21h
leave
ret
extract_digits:
push bp
mov bp, sp
xor ah, ah
push bx
mov bl, 10
div bl
pop bx
mov byte [digits], al
mov byte [digits + 1], ah
leave
ret
display_crlf:
push bp
mov bp, sp
mov ah, 02h
mov dl, 13 ; '\r'
int 21h
mov ah, 02h
mov dl, 10 ; '\n'
int 21h
leave
ret