-
Notifications
You must be signed in to change notification settings - Fork 2
/
TIME.ASM
171 lines (119 loc) · 5.71 KB
/
TIME.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
$Title ('DTC/PC BIOS Time of Day and Real Time Clock V1.0')
$Pagelength (80) Pagewidth (132) Debug Nogen
Name Time
; Author: Don K. Harrison
; Start date: December 7, 1983 Last edit: December 20, 1983
; ************************
; * Module Description *
; ************************
;
; This module contains the time of day driver routine (Int 26)
; and the real time clock hardware interrupt service routine (Int 8)
;
; (c) Display Telecommunications Corporation, 1983
; All Rights Reserved
$Eject
; **********************
; * Revision History *
; **********************
$Eject
; ********************
; * Public Symbols *
; ********************
Public TodDriver, TimerHdwrInt
; *************
; * Equates *
; *************
; All Equates in include file: IbmInc
$Include (IbmInc)
$Eject
; *******************
; * Data Segments *
; *******************
BiosDataArea Segment Public
Extrn TimerLow:Word, TimerHigh:Word,TimerOverflow:Byte
Extrn MotorStatus:Byte, MotorCount:Byte
BiosDataArea Ends
$Eject
; ******************
; * Code Segment *
; ******************
Bios Segment Common
Assume Cs:Bios, Ds:BiosDataArea
; ************************
; * Time of Day Driver *
; ************************
Org 0FE6EH ;Align with Pc and Xt
TodDriver Proc Far
Sti ;Restore interrupts
Push Ds ;Setup
Push Ax ;...our
Mov Ax,BiosDataArea ;...data
Mov Ds,Ax ;...segment
Pop Ax ;Restore command
Cli ;Allow no ints
Or Ah,Ah ;Command = 0 = Read
Jz ReadClock ;...jump if so
Dec Ah ;Command = 1 = Set
Jnz TodReturn ;...jump if not and return
; Set the clock
Mov TimerLow,Dx ;Low portion of day clock
Mov TimerHigh,Cx ;High portion of day clock
Mov TimerOverflow,0 ;Overflow = false
Jmp Short TodReturn ;...Return
; Read the clock
ReadClock:
Mov Cx,TimerHigh ;Return High portion
Mov Dx,TimerLow ;Return Low portion
Mov Al,TimerOverflow ;Return overflow status
TodReturn:
Sti ;Restore interrupts
Pop Ds ;Restore user data seg.
Iret ;...and return
TodDriver Endp
$Eject
; *****************************
; * Real Time Clock Handler *
; *****************************
Org 0FEA5H ;Align with PC and Xt
TimerHdwrInt Proc Far
Sti ;Restore interrupts
Push Ds ;Save minimum registers
Push Dx ;...so this runs
Push Ax ;...fast
Mov Ax,BiosDataArea ;Load segment register
Mov Ds,Ax ;...with bios segment
; First, process diskette motor timer
Dec MotorCount ;Reduce timer for motor by 1
Jnz MotorsStillRun ;...and return if not 0
And MotorStatus,11110000B ;Clear motor running bits
Mov Al,00001100B ;...and turn off motors
Mov Dx,PortFDCAdptMode ;Point at port
Out Dx,Al ;...turn them off
MotorsStillRun:
; Now, process clock
Inc TimerLow ;Inc the low part of timer
Jnz NoCarryToHi ;...and jump if it didn't carry
Inc TimerHigh ;...else increment High timer
NoCarryToHi:
Cmp TimerHigh,18H ;Does the timer = 24 hrs
Jne NoCarryToOflo ;...jump if not
Cmp TimerLow,0B0H ;Does the timer = 24 hrs
Jne NoCarryToOflo ;...jump if not
; Set overflow
Mov TimerHigh,0 ;Clear the
Mov TimerLow,0 ;...timer and
Mov TimerOverflow,1 ;...set the overflow flag
NoCarryToOflo:
; Now, process user RTC tick routine
Int TrapTimerBreak ;Probably a dummy return
; Acknowledge interrupt
Mov Al,PicEoi ;End of interrupt
Out PortPICOCW2,Al ;...to 8259A
Pop Ax ;Restore
Pop Dx ;...registers
Pop Ds ;...and
Iret ;...return
TimerHdwrInt Endp
Bios Ends
End