forked from cirosantilli/x86-bare-metal-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rtc.S
64 lines (53 loc) · 1.11 KB
/
rtc.S
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
/* https://github.com/cirosantilli/x86-bare-metal-examples# */
/* TODO what do those numbers mean? Where is this all documented? */
.equ RTCaddress, 0x70
.equ RTCdata, 0x71
#include "common.h"
BEGIN
update_in_progress:
mov $10, %al
out %al, $RTCaddress
in $RTCdata, %al
testb $0x80, %al
jne update_in_progress
/* Second. */
mov $0, %al
out %al, $RTCaddress
in $RTCdata, %al
/* Only print if second changed. */
cmp %al, %cl
je update_in_progress
mov %al, %cl
PRINT_HEX <%al>
PUTC
/* Minute. */
mov $0x02, %al
out %al, $RTCaddress
in $RTCdata, %al
PRINT_HEX <%al>
PUTC
/* Hour. */
mov $0x04, %al
out %al, $RTCaddress
in $RTCdata, %al
PRINT_HEX <%al>
PUTC
/* Day. */
mov $0x07, %al
out %al, $RTCaddress
in $RTCdata, %al
PRINT_HEX <%al>
PUTC
/* Month. */
mov $0x08, %al
out %al, $RTCaddress
in $RTCdata, %al
PRINT_HEX <%al>
PUTC
/* Year. */
mov $0x09, %al
out %al, $RTCaddress
in $RTCdata, %al
PRINT_HEX <%al>
PRINT_NEWLINE
jmp update_in_progress