.title rdtoy .enabl lc ;++ ; ; Program to read the 11/94 TOY clock, for testing with Ersatz-11. ; ; By John Wilson . ; ; 12/19/95 JMBW Created. ; 10/21/98 JMBW Fixed per Cookie's Usenet post quoting manual. ; ;-- .mcall .exit,.print ; asr$= 177526 ;add'l status reg ; start: ; start here mov #asr$+1,r5 ;point at MSB of additional status reg ; write 64-bit signature to DS1215 mov #toysig,r4 ;point at signature mov #1,r3 ;bit 0 movb (r5),r0 ;get value (don't know if other bits are R/W) ;(this should also clear the DS1215 ptr) 10$: bic #1,r0 ;clear bit 8 bit r3,(r4) ;should we set it? beq 20$ inc r0 ;yes 20$: movb r0,(r5) ;write a bit asl r3 ;shift the bit left bcc 10$ ;didn't wrap inc r3 ;start over at bit 0 tst (r4)+ ;skip to next word cmp r4,#toysig+8. ;done all 64 bits of signature? blo 10$ ;loop if not ; presumably we're in, read 64 bits of clock data mov #toybuf+6,r4 ;pt at last word clr (r4) ;nuke out buf clr -(r4) clr -(r4) clr -(r4) ;(now R4=TOYBUF, R3=1 from above) 30$: bitb #1,(r5) ;read a bit beq 40$ bis r3,(r4) ;1, set it 40$: asl r3 ;shift the bit left bcc 30$ ;didn't wrap inc r3 ;start over at bit 0 tst (r4)+ ;skip to next word cmp r4,#toybuf+8. ;done all 64 data bits? blo 30$ ;loop if not ; display what we got (we assume all numbers are within valid range) mov #lbuf,r5 ;pt at buffer movb toybuf+3,r0 ;hours call num2 movb #':,(r5)+ ;colon movb toybuf+2,r0 ;minutes call num2 movb #':,(r5)+ ;colon movb toybuf+1,r0 ;seconds call num2 movb #'.,(r5)+ ;decimal point movb toybuf,r0 ;hundredths call num2 movb #<' >,(r5)+ ;2 spaces movb #<' >,(r5)+ mov #days,r4 ;pt at day table movb toybuf+4,r0 ;get day # (1-7, 1=Monday) call str3 ;look up 3-letter abbreviation movb #<',>,(r5)+ ;comma movb #<' >,(r5)+ ;space movb toybuf+5,r0 ;date call num2 movb #'-,(r5)+ ;hyphen movb toybuf+6,r0 ;month mov r0,r1 ;copy bic #^C17,r0 ;isolate low digit bic r0,r1 ;isolate high digit *16. asr r1 ;high dig *8 add r1,r0 asr r1 ;+high dig *2 asr r1 add r1,r0 ;=high dig *10. mov #months,r4 call str3 movb #'-,(r5)+ ;hyphen movb toybuf+7,r0 ;year call num2 clrb (r5) ;mark end .print #lbuf ;print the whole mess mov sp,r0 ;allow restart .exit ;later ; str3: ; copy 3-letter string at (r4+r0*3) to (r5)+ add r0,r4 ;add offset*1 asl r0 ;*2 add r0,r4 ;make that offset*3 movb (r4)+,(r5)+ ;copy movb (r4)+,(r5)+ movb (r4),(r5)+ rts pc ; num2: ; copy 2-digit BCD number in r0 to (r5)+ mov r0,r1 ;copy asr r0 ;right 4 bits (we probably have ASH but...) asr r0 asr r0 asr r0 bic #^C17,r0 ;isolate low digit of each bic #^C17,r1 add #'0,r0 ;convert each to ASCII add #'0,r1 movb r0,(r5)+ ;save movb r1,(r5)+ rts pc ; ; Signature pattern to get into Dallas Semiconductor DS1215 time of year chip toysig: .word 35305 ;C5 3A .word 56243 ;A3 5C .word 35305 ;C5 3A .word 56243 ;A3 5C ; days: .ascii /XxxMonTueWedThuFriSatSun/ months: .ascii /XxxJanFebMarAprMayJunJulAugSepOctNovDec/ ; .even toybuf: .blkw 4 ;TOY read buf ; lbuf: .blkb 80. ;output line buffer (a lot shorter than 80.) ; .end start