aboutsummaryrefslogtreecommitdiff
path: root/CLOCK.sic
blob: 2b048ea2ba49b897471a9b9cc49ed9bc64254225 (plain)
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
CLOCK	START	7EEE	#count backwards from 7FFD after program is finished
	LDA	TIMER
	STA	SAVED
	LDA	ZEROB	#load 1 byte of zero into A
	STA	HOUR	#store 00 into HOUR and MINUTE
	STA	MINUTE
	LDA	SAVED
	COMP	ZERO
	JGT	CALC1	#greater than zero means 12 hour format...jump to the calculation
ADJUST	AND	SEVENF	#Do AND operation with the value in SAVED and 7FFFFF
CALC2	COMP	HCOUNT	#calculation for 24 hour format
	JLT	CALC2A
	SUB	HCOUNT
	STA	STORE	#add one to HOUR:
	LDA	HOUR	#load HOUR into A
	ADD	ONE	#add one
	STA	HOUR	#store new value in HOUR
	LDA	STORE	#load the time back into A
	COMP	HCT2
	JGT	CALC2
CALC2A	COMP	MCOUNT
	JLT	DISP24
	SUB	MCOUNT
	STA	STORE	#add one to minute
	LDA	MINUTE
	ADD	ONE
	STA	MINUTE
	LDA	STORE
	COMP	MCT2
	JGT	CALC2A
	J	DISP24
CALC1	COMP	HCOUNT	#calculation for 12 hour format
	JLT	CALC1A
	SUB	HCOUNT
	STA	STORE	#add one to hour
	LDA	HOUR
	ADD	ONE
	STA	HOUR
	LDA	STORE
	COMP	HCT2
	JGT	CALC1
CALC1A	COMP	MCOUNT
	JLT	DISP12
	SUB	MCOUNT
	STA	STORE	#add one to minute
	LDA	MINUTE
	ADD	ONE
	STA	MINUTE
	LDA	STORE
	COMP	MCT2
	JGT	CALC1A
	J	DISP12
DISP24	TD	OUTPUT	#test if device is ready to be written to
	JEQ	DISP24	#loop until the device is ready
	LDCH	HOUR
	WD	OUTPUT
	LDCH	MINUTE
	WD	OUTPUT
	J	ENDING
DISP12	TD	OUTPUT	#test if device is ready to be written to
	JEQ	DISP24	#loop until device is ready
	LDA	HOUR
	COMP	TWELVE
	JGT	PM
	LDCH	HOUR
AM	WD	OUTPUT
	LDCH	MINUTE
	WD	OUTPUT
	LDCH	A
	WD	OUTPUT
	J	ENDING	
PM	SUB	TWELVE
	LDCH	HOUR
	WD	OUTPUT
	LDCH	MINUTE
	WD	OUTPUT
	LDCH	P
	WD	OUTPUT
	J	ENDING
A	BYTE	C'A'
P	BYTE	C'P'
HCOUNT	BYTE	X'E10'	#3600 in decimal
HCT2	BYTE	X'E0F'	#3599
MCOUNT	BYTE	X'3C'	#60 in decimal
MCT2	BYTE	X'3B'	#59 in decmial
SEVENF	WORD	7FFFFF
TWELVE	BYTE	X'C'
ZERO	WORD	0
ZEROB	BYTE	X'00'	#one byte of zeros to be placed in HOUR and MINUTE at program start
ONE	BYTE	X'1'	#representation of the number 1 for incrementing
HOUR	RESB	1	#1 byte for number of hours max 23
MINUTE	RESB	1	#1 byte for number of minutes max 59
STORE	RESW	1	#store value of register A temporarily so another value can be placed for adding
SAVED	RESW	1	#saving the timer so unexpected changes wont break the program
OUTPUT	BYTE	X'40'	#output device
TIMER	RESW	1	#reserve 1 word for the timer. Needs to end up at address 7FFD (last word in mem)
ENDING	END