home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
CPM
/
PROGRAMS
/
CLOCKK
/
MDCLCK13.LBR
/
READTIME.AZM
/
READTIME.ASM
Wrap
Assembly Source File
|
2000-06-30
|
4KB
|
177 lines
; Program in 8080 assembly language to read real-time-clock located
; at ports 30h through 33h in Morrow MD 2/3 rev. 2 main board
; Mike Allen 7/13/86
;
CLS EQU 'Z'-40H ;^Z TO CLEAR SCREEN
HOME EQU '^'-40H ;^^ TO HOME CURSOR
ESC EQU 01BH ;ESCAPE
PA EQU 30H ;REAL-TIME-CLOCK PORT A
PB EQU 31H ;REAL-TIME-CLOCK PORT B
PC EQU 32H ;REAL-TIME-CLOCK PORT C
CNTRL EQU 33H ;REAL-TIME-CLOCK CONTROL PORT
BDOS EQU 5 ;BDOS CALL VECTOR
WBOOT EQU 0 ;BDOS WARM BOOT CODE
CONOUT EQU 2 ;BDOS CONSOLE CHARACTER OUT CODE
PRTSTR EQU 9 ;BDOS CONSOLE STRING OUT CODE
CONSTAT EQU 0BH ;BDOS CONSOLE STATUS CODE
ORG 100H
LXI D,CUROFF ;TURN OFF THE CURSOR
MVI C,PRTSTR
CALL BDOS
MVI E,CLS ;CLEAR THE SCREEN
MVI C,CONOUT
CALL BDOS
MVI A,090H ;SET UP 8255
OUT CNTRL
MVI A,020H ;PUT MSM5832 IN READ MODE
OUT PC
LOOP: LXI D,RTC ;START OF REAL-TIME-CLOCK BUFFER
MVI A,0 ;FIRST MSM5832 ADDRESS
LOOP1: MOV B,A ;SAVE CURRENT ADDRESS
OUT PB ;SEND ADDRESS TO MSM5832
NOP ;WAIT A WHILE
NOP
NOP
NOP
IN PA ;GET DATA FROM MSM5832
ANI 0FH ;MASK OFF 4 MSB
STAX D ;SAVE IT IN BUFFER
INX D ;INCREMENT BUFFER POINTER
MOV A,B ;GET LATEST ADDRESS
INR A ;INCREMENT IT
CPI 13 ;GOT ALL THE DATA?
JNZ LOOP1 ;NOPE, SO REPEAT IT
MVI E,HOME ;HOME THE CURSOR
MVI C,CONOUT
CALL BDOS
LXI D,DATE ;SEND OUT THE DATE LABEL
MVI C,PRTSTR
CALL BDOS
MVI H,0 ;ZERO TOP 8 BITS OF HL
LDA RTC+6 ;GET DAY-OF-WEEK NUMBER ...
MOV L,A ; ... AND MULTIPLY BY 12
DAD H ;X2
DAD H ;X4
PUSH H ;SAVE X4 IN DE
POP D
DAD H ;X8
DAD D ;X12
LXI D,DAY ;ADD TO START OF DAY STRING AREA TO ...
DAD D ; ... FIND PROPER DAY NAME.
XCHG ;PRINT DAY OF WEEK.
MVI C,PRTSTR
CALL BDOS
LDA RTC+0AH ;GET MONTH X10
CALL PNZNUM ;PRINT IT IF NON-ZERO
LDA RTC+9 ;GET MONTH X1
CALL PRTNUM ;PRINT IT
CALL PRTSLH ;PRINT A '/'
LDA RTC+8 ;GET DAY X10
ANI 3 ;MASK OFF LEAP YEAR FLAG
CALL PNZNUM ;PRINT IT IF NON-ZERO
LDA RTC+7 ;GET DAY X1
CALL PRTNUM ;PRINT IT
CALL PRTSLH ;PRINT A '/'
LDA RTC+0CH ;GET YEAR X10
CALL PRTNUM ;PRINT IT
LDA RTC+0BH ;GET YEAR X1
CALL PRTNUM ;PRINT IT
LXI D,CRLF ;PRINT CR/LF PAIR
MVI C,PRTSTR
CALL BDOS
LXI D,TIME ;SEND OUT THE TIME LABEL
MVI C,PRTSTR
CALL BDOS
LDA RTC+5 ;CHECK FOR 24HR, AM OR PM
MVI B,0
CPI 8 ;CHECK FOR 24HR
JP SETFLG ;YEP, FINISH IT
INR B
CPI 4 ;CHECK FOR PM
JM SETFLG ;NOPE, IS AM
INR B ;YEP, IT IS PM
SETFLG: ANI 3 ;STRIP OFF 24HR AND PM BITS
STA RTC+5 ;SAVE IT
MOV A,B ;GET FLAG
STA FLAG ;SAVE IT
ORA A ;IS IT ZERO (24HR)?
LDA RTC+5 ;GET HR X10
CZ PRTNUM ;ALWAYS PRINT IF 24 HR TIME
CNZ PNZNUM ;DON'T PRINT IF ZERO AND NOT 24HR TIME
LDA RTC+4 ;GET HR X1
CALL PRTNUM ;PRINT HR X1
CALL PRTCOL ;PRINT A ':'
LDA RTC+3 ;PRINT MIN X10
CALL PRTNUM
LDA RTC+2 ;PRINT MIN X1
CALL PRTNUM
CALL PRTCOL ;PRINT A ':'
LDA RTC+1 ;PRINT SEC X10
CALL PRTNUM
LDA RTC ;PRINT SEC X1
CALL PRTNUM
MVI H,0 ;ZERO TOP 8 BITS OF HL
LDA FLAG ;GET TAG INDEX ...
MOV L,A ; ... AND MULTIPLY BY 6
DAD H ;X2
PUSH H ;SAVE X2 IN DE
POP D
DAD H ;X4
DAD D ;X6
LXI D,TAG ;ADD TO START OF TAG STRING AREA TO ...
DAD D ; ... FIND PROPER TAG.
XCHG ;PRINT TAG.
MVI C,PRTSTR
CALL BDOS
MVI C,CONSTAT ;SEE IF KEY HAS BEEN PRESSED
CALL BDOS
ORA A
JZ LOOP ;NO KEY PRESS, REPEAT.
MVI A,0H ;DONE - TURN OFF THE MSM5832 READ, ...
OUT PC
LXI D,CURON ; ... TURN THE CURSOR BACK ON ...
MVI C,PRTSTR
CALL BDOS
MVI C,WBOOT ;... AND WARM BOOT
CALL BDOS
PNZNUM: ORA A
RZ ;DON'T PRINT A '0'
PRTNUM: ADI '0' ;MAKE NUMER ASCII
MOV E,A ;GET READY TO PRINT
PRTSYM: MVI C,CONOUT
JMP BDOS ;LET BDOS SUPPLY THE 'RET'
PRTSLH: MVI E,'/'
JMP PRTSYM
PRTCOL: MVI E,':'
JMP PRTSYM
CUROFF: DB ESC,'"6$' ;(ESC " 6) TURNS CURSOR OFF [MDT 60/70]
CURON: DB ESC,'"0$' ;(ESC " 0) TURNS CURSOR ON [MDT 60/70]
DATE: DB 'DATE: $'
TIME: DB 'TIME: $'
DAY: DB 'Sunday, $',0,0,0
DB 'Monday, $',0,0,0
DB 'Tuesday, $',0,0
DB 'Wednesday, $'
DB 'Thursday, $',0
DB 'Friday, $',0,0,0
DB 'Saturday, $'
TAG: DB ' HRS.$'
DB ' AM$',0,0
DB ' PM$'
CRLF: DB 0DH,0AH,'$'
FLAG: DS 1
RTC: DS 13
END
$',0,0,0
DB 'Saturday, $'
TAG: DB ' HRS.$'
DB ' AM$',0,0
DB ' PM$'
CRLF: DB 0DH,0AH,'$'
FLAG: DS 1
RTC: DS 1