; NOSLT20.AZM no-slot clock code for cpm Z80 use. ; Enter TIME to read clk. TIME W to write. TIME ? for help. ; Needs machine dependent "enable PROM" code. See DOC file. ; Assemble with Z80MR. Suggest rename COM file to TIME.COM. ; R.Gaspari Los Angeles 10-28-87 ORG 0100H CALL XSET ; put machine dependent code in place LD A,(0080H) ; inspect the command tail OR A ; see if anything's there JR Z,ARD ; if not, do a READ immediately LD A,(0082H) ; otherwise, get the byte there AND 0DFH ; convert it to upper case CP 'W' ; if W or w, set clock using WRBUF JR Z,AWR CP 'S' ; if S or s, set clk using cmnd tail JR Z,AST JP HELP ; all else, go give help AST: CALL WRSET ; set up WRITE routine from cmnd tail AWR: CALL CLEN ; clock enable CALL WRITE ; write (set) the clock CALL WRDISP ; display msg & fall thru to... ARD: CALL CLEN ; clock enable CALL READ ; read the clock CALL RDDISP ; display the results RET ; return to cpm operating system ; *********************************************** ; BUFFER FOR SETTING CLOCK AT START-UP ; *********************************************** DS 1 WRBUF: ; (example) for Tues 10/28/87 5:15pm DB 0,0 ; seconds (0000) DB 0 ; minutes (15h) DB 20H ; hour (17h) DB 14H ; day (04h) DB 28H ; date (28h) DB 10H ; month (10h) DB 87H ; year (87h) ; **************************** ; CLOCK ENABLE ; **************************** CLEN: CALL XRR ; READ with addr bit A2 high LD DE,0802H ; constants for later use LD HL,0C5A3H ; the pattern recognition sequence CLES: LD A,H ; A contains C5h CALL CE LD A,H CPL ; A contains 3Ah CALL CE LD A,L ; A contains A3h CALL CE LD A,L CPL ; A contains 5Ch CALL CE DEC E ; do this 2 times JR NZ,CLES RET ; return to main program CE: LD B,D CE2: RRA PUSH AF CALL XWR ; enter XWR with carry flag POP AF DEC B JR NZ,CE2 RET ; return to CES ; ****************************** ; READ CLOCK ; ****************************** READ: ; code from Andrew Sopchak 5/22/87 ld hl,rdbuf ; set up buffer ld e,8 ; do 8 bytes rdbyt ld d,8 ; do 8 bits rdbit call xrr srl a ; shift bit into cy rr (hl) ; shift bit into (hl) dec d ; dec bit counter jr nz,rdbit ; read next bit inc hl ; point to next buf location dec e ; dec byte counter jr nz,rdbyt ; read next byte ret RDBUF: ; (example) for Tues 10/20/87 5:15pm DB 0,0 ; seconds (0000) DB 0 ; minutes (15h) DB 0 ; hour (17h) DB 0 ; day (03h) DB 0 ; date (20h) DB 0 ; month (10h) DB 0 ; year (87h) ; ******************************* ; DISPLAY READ RESULTS ; ******************************* RDDISP: LD A,(RDBUF+6) ; get month (in BCD) LD HL,RMO ; point to place to put ascii month CALL RASCII LD A,(RDBUF+5) ; get date (in BCD) LD HL,RDA ; point to place to put ascii day CALL RASCII LD A,(RDBUF+7) ; get year LD HL,RYR ; CALL RASCII LD A,(RDBUF+3) ; get hour LD HL,RHR ; CALL RASCII LD A,(RDBUF+2) ; get minutes LD HL,RMN ; CALL RASCII LD A,(RDBUF+1) ; get seconds LD HL,RSC ; CALL RASCII LD C,9 LD DE,RMSG CALL 5 RET ; exit back to main program RMSG: DB ' Date: ' RMO: DB 0,0,'/' RDA: DB 0,0,'/' RYR: DB 0,0,' ' DB ' Time: ' RHR: DB 0,0,':' RMN: DB 0,0,':' RSC: DB 0,0,0dh,0ah,'$' RASCII: LD B,A ; store temporarily AND 0F0H ; get upper nibble RLC A ; shift right 4 times RLC A ; (same as left 4 times) RLC A ; RLC A ; CALL RASC2 ; LD A,B ; get byte back AND 0FH ; get lower nibble RASC2: OR 30H ; convert to ascii LD (HL),A ; store it INC HL ; update pointer RET ; retn RASC2 & retn RASCII ; ******************************* ; WRITE ROUTINE ; ******************************* WRITE: ; code from Andrew Sopchak 5/22/87 LD HL,WRBUF ld d,8 ; do 8 bytes wrbyt: ld a,(hl) ; get first byte ld b,a ; b contains byte ld c,8 ; do this for 8 bits wrbit srl b ; 0->b7...b0->cy call xwr dec c jr nz,wrbit ; do all 8 bits inc hl ; point to next byte dec d ; done with 8 bytes? jr nz,wrbyt ; go do next byte ret ; all done ; *********************************** ; DISPLAY WRITE MSG ; *********************************** WRDISP: LD C,9 ; now that we've set the clock... LD DE,WMSG ; send msg CALL 5 RET ; return to main program WMSG: DB ' The time has been set to: ',0dh,0ah,'$' ; ************************************* ; SET-UP WRBUF FROM CMND TAIL ; ************************************* WRSET: LD A,(0083H) ; month LD B,A LD A,(0084H) CALL WBCD LD (WRBUF+6),A LD A,(0086H) ; day LD B,A LD A,(0087H) CALL WBCD LD (WRBUF+5),A LD A,(0089H) ; year LD B,A LD A,(008AH) CALL WBCD LD (WRBUF+7),A LD A,(008CH) ; hour LD B,A LD A,(008DH) CALL WBCD LD (WRBUF+3),A LD A,(008FH) ; min LD B,A LD A,(0090H) CALL WBCD LD (WRBUF+2),A RET ; return back to main program WBCD: ; B has upper nibble, A has lower AND 0FH ; mask lower nibble LD C,A ; store temporarily in C LD A,B ; get upper nibble AND 0FH ; mask it RLA ; shift left RLA RLA RLA AND 0F0H ; get rid of lower nibble in A OR C ; combine it with lower nibble in C RET ; retn from subr with BCD result in A ; ************************** ; HELP ; ************************** HELP: LD C,9 LD DE,HLPMSG CALL 5 RET ; ret to cpm operating system HLPMSG: DB 'Enter TIME to read the clock' DB 0dh,0ah DB ' TIME W to write (set) ' DB 'clk using buffer at 0130h',0dh,0ah DB ' TIME S01/02/88,08:15 to set clk ' DB 'using command tail',0dh,0ah,0ah DB '$' ; ****************************** ; CHIP ENABLE FOR PROM ; ****************************** ; this code for Northstar Advantage ; NOTE - relocation is only needed if any code overwrites ; 4000h to 8000h (N* Adv PROM addr range as set up) NEWLOC EQU 03D0H ; modify as required XSET: LD DE,NEWLOC ; spot to put this code LD HL,XRL ; point to code we'll put there LD BC,XSIZE ; size of code block to be moved LDIR ; RET ; return to main program XRL EQU $ ; Machine Read (Local) XRR EQU NEWLOC ; Read routine (Relocated) DI LD A,084H ; select PROM memory OUT 0A1H,A ; map it onto 4000h - 8000h LD A,(04004H) ; READ with bit A2 high LD B,A ; store in B for the return LD A,1 ; select normal RAM memory OUT 0A1H,A ; map it onto 4000h - 8000h LD A,B EI RET ; return to calling program "READ" XWL EQU $ ; machine Write routine (Local) XWR EQU NEWLOC+(XWL-XRL) ; WRITE routine (Relocated) DI LD A,084H ; select PROM memory OUT 0A1H,A ; map it to 4000h to 8000h JR NC,X1 LD A,(04003H) ; WRITE with bit A2 low & bit A0 high JR X2 X1: LD A,(04002H) ; WRITE with bit A2 low & bit A0 low X2: LD A,1 ; select normal RAM memory OUT 0A1H,A ; map it onto 4000h to 8000h EI RET ; return to calling program "WRITE" XSIZE EQU $-XRL ; the size of code segment to move XREF EQU NEWLOC+XSIZE ; end of code in final location END ; NOSLT20.AZM