-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrtc.asm
More file actions
executable file
·148 lines (131 loc) · 5.29 KB
/
rtc.asm
File metadata and controls
executable file
·148 lines (131 loc) · 5.29 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
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
;--------------------------------------------------------------------------------
;| Título: Control RTC |
;| Versión: 1.0 Fecha: 16/07/2009 |
;| Autor: D.GARCIA Modelo: IA-32 (32 bits) |
;| ------------------------------------------------------------------------ |
;| Descripción: |
;| Rutina para manejo de servicios del Reloj de Tiempo Real |
;| ------------------------------------------------------------------------ |
;| Recibe: |
;| AL = 0 Subfuncion fecha |
;| AL = 1 Subfuncion hora |
;| |
;| Retorna: |
;| Fecha: |
;| DH = Año |
;| DL = Mes |
;| AH = Dia |
;| AL = Dia de la semana |
;| Hora: |
;| DL = Hora |
;| AH = Minutos |
;| AL = Segundos |
;| CL = 0:OK N:Codigo de error |
;| ------------------------------------------------------------------------ |
;| Revisiones: |
;| 1.0 | 15/02/2010 | D.GARCIA | Original |
;--------------------------------------------------------------------------------
RTC_Service:
cmp al, 0
je Fecha ; Servicio de Fecha
cmp al, 1
je Hora ; Servicio de Hora
jmp RTC_Err_Exit ; Funcion no valida, salida con error
RTC_Err_Exit:
mov cl, 1 ; Codigo de error. Subfuncion invalida
ret
RTC_Exit:
mov cl, 0 ; Codigo de error. OK
ret
;--------------------------------------------------------------------------------
;| Título: Auxiliar RTC |
;| Versión: 1.0 Fecha: 16/07/2009 |
;| Autor: D.GARCIA Modelo: IA-32 (32 bits) |
;| ------------------------------------------------------------------------ |
;| Descripción: |
;| Subfuncion para obtener la hora del sistema desde el RTC |
;| ------------------------------------------------------------------------ |
;| Recibe: |
;| Nada |
;| Retorna: |
;| Nada |
;| ------------------------------------------------------------------------ |
;| Revisiones: |
;| 1.0 | 15/02/2010 | D.GARCIA | Original |
;--------------------------------------------------------------------------------
Hora:
call RTC_disponible ; asegura que no esté actualizandose el RTC
mov al, 4
out 70h, al ; Selecciona Registro de Hora
in al, 71h ; lee hora
mov dl, al
mov al, 2
out 70h, al ; Selecciona Registro de Minutos
in al, 71h ; lee minutos
mov ah, al
xor al, al
out 70h, al ; Selecciona Registro de Segundos
in al, 71h ; lee minutos
jmp RTC_Exit
;--------------------------------------------------------------------------------
;| Título: Auxiliar RTC |
;| Versión: 1.0 Fecha: 16/07/2009 |
;| Autor: D.GARCIA Modelo: IA-32 (32 bits) |
;| ------------------------------------------------------------------------ |
;| Descripción: |
;| Subfuncion para obtener la fecha del sistema desde el RTC |
;| ------------------------------------------------------------------------ |
;| Recibe: |
;| Nada |
;| Retorna: |
;| Nada |
;| ------------------------------------------------------------------------ |
;| Revisiones: |
;| 1.0 | 15/02/2010 | D.GARCIA | Original |
;--------------------------------------------------------------------------------
Fecha:
call RTC_disponible ; asegura que no esté
; actualizandose el RTC
mov al, 9
out 70h, al ; Selecciona Registro de Año
in al, 71h ; lee año
mov dh, al
mov al, 8
out 70h, al ; Selecciona Registro de Mes
in al, 71h ; lee mes
mov dl, al
mov al, 7
out 70h, al ; Selecciona Registro de Fecha
in al, 71h ; lee Fecha del mes
mov ah, al
mov al, 6
out 70h, al ; Selecciona Registro de DÃa
in al, 71h ; lee dÃa de la semana
jmp RTC_Exit
;--------------------------------------------------------------------------------
;| Título: Auxiliar RTC |
;| Versión: 1.0 Fecha: 16/07/2009 |
;| Autor: D.GARCIA Modelo: IA-32 (32 bits) |
;| ------------------------------------------------------------------------ |
;| Descripción: |
;| Verifica en el Status Register A que el RTC no esta actualizando |
;| fecha y hora. |
;| Retorna cuando el RTC esta disponible |
;| ------------------------------------------------------------------------ |
;| Recibe: |
;| Nada |
;| Retorna: |
;| Nada |
;| ------------------------------------------------------------------------ |
;| Revisiones: |
;| 1.0 | 15/02/2010 | D.GARCIA | Original |
;--------------------------------------------------------------------------------
RTC_disponible:
mov al, 0Ah
out 70h, al ; Selecciona registro de status A
wait_for_free:
in al, 71h ; lee Status
test al, 80h
jnz wait_for_free
ret
;/* ----------- Fin del archivo ----------- */