-
Notifications
You must be signed in to change notification settings - Fork 85
/
time
71 lines (71 loc) · 1.51 KB
/
time
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
.PAG 'TIME 11/12/81'
;----------------------------------------
;
; TIME AND ALARM ROUTINES FOR 6526
; RSR 11/12/81
;
;----------------------------------------
;----------------------------------------
; RDTIM - READ THE TIME
; .Y = (BIT7=PM,BIT6/5=T8/T4,BITS4-0 HRS)
; .X = (BIT7=T2,BITS6-0 MINUTES)
; .A = (BIT7=T1,BITS6-0 SECONDS)
;----------------------------------------
RDTIM LDA CIA+TOD10
PHA ;SAVE FOR LATER
PHA
ASL A ;SHIFT TO ADD TO TODHRS
ASL A
ASL A
AND #$60 ;BIT POSISTIONS 5,6
ORA CIA+TODHR
TAY ;RETURN IN .Y
PLA
ROR A ;SHIFT TO ADD TO TODSEC
ROR A
AND #$80
ORA CIA+TODSEC
STA SAL ;SAVE FOR LATER
ROR A ;SHIT TO ADD TO TODMIN
AND #$80
ORA CIA+TODMIN
TAX ;RETURN IN .X
PLA
CMP CIA+TOD10 ;WATCH OUT FOR ROLLOVER
BNE RDTIM ;...IT CHANGED DO AGAIN...
LDA SAL
RTS
.PAG
;----------------------------------------
; SETTIM - SET TOD AND ALARM
; C-SET => SET ALARM
; C-CLR => SET TOD
; REGISTERS SAME AS RDTIM
;
;----------------------------------------
SETTIM PHA ;SAVE FOR LATER
PHA
ROR A ;SET BIT 8
AND #$80
ORA CIA+CRB
STA CIA+CRB
TYA ;GET BITS FROM TODHRS
ROL A
ROL A
ROL SAL ;BIT T8 (DON'T NEED TO CLEAR SAL)
ROL A
ROL SAL ;BIT T4
TXA ;GET BIT FROM TODMIN
ROL A
ROL SAL ;BIT T2
PLA ;GET BIT FROM TODSEC
ROL A
ROL SAL ;BIT T1
STY CIA+TODHR
STX CIA+TODMIN
PLA
STA CIA+TODSEC
LDA SAL
STA CIA+TOD10
RTS
.END