aboutsummaryrefslogtreecommitdiff
path: root/CLOCK.sic
diff options
context:
space:
mode:
authorDominic Matarese <dominicmatarese@gmail.com>2021-07-12 16:26:11 +0000
committerDominic Matarese <dominicmatarese@gmail.com>2021-07-12 16:26:11 +0000
commit734dee6e865679fb98900e89d71fb3e2cd67da8f (patch)
tree4786f339c887d101ceec157d305825cbb57b8d51 /CLOCK.sic
required first commitHEADmaster
Diffstat (limited to 'CLOCK.sic')
-rw-r--r--CLOCK.sic97
1 files changed, 97 insertions, 0 deletions
diff --git a/CLOCK.sic b/CLOCK.sic
new file mode 100644
index 0000000..2b048ea
--- /dev/null
+++ b/CLOCK.sic
@@ -0,0 +1,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