bjork@NISC.SRI.COM (02/11/91)
Here's a clock utility that I've used with the Compu-time S100 clock board. It has the OKI MSM5832 chip. --Steven ; 22 jun 84 rev 1 computime clock stuff atomic penguin ; 5 feb 91 rev 2 RMAC version clk equ 0ech ; clock board address cld equ clk+1 ; data port address cla equ clk+2 ; address port address wval equ 50 ; 150 microseconds/3 for 4 mhz public start cseg start: lda 80h ; get user string cpi 0 ; anything there? jz ptim ; nope, just read the clock. lda 82h ; see what user typed. cpi 'D' ; Set the day? jz sday ; go set day cpi 'T' ; set the time? jz stim ; go set time cpi 'F' ; forever mode? jnz qwak ; invalid, bark at human xra a ; usual zero sta frevrf ; set the forever flag jmp ptim ; print time qwak: lxi d,xmsg ; point at bark string mvi c,9 jmp 5 ; returns to cmd level dseg frevrf: db 1 ; zero if forever mode xmsg: db '** Invalid option **',0dh,0ah db 0dh,0ah db 'Type DAY D dd/mm/yy to set date.',0dh,0ah db 0dh,0ah db 'Type DAY T hh:mm:ss to set time.',0dh,0ah,'$' mo1: db ' January $' mo2: db ' February $' mo3: db ' March $' mo4: db ' April $' mo5: db ' May $' mo6: db ' June $' mo7: db ' July $' mo8: db ' August $' mo9: db ' September $' mo10: db ' October $' mo11: db ' November $' mo12: db ' December $' cseg ptim: mvi a,08h ; address MSM5832 internal reg call rnib ; get day of month msb ani 3 ; mask gibberish adi 30h ; add ascii offset mov e,a mvi c,2 call 5 mvi a,7 call pnib ; print day of month lsb mvi a,0ah ; MSM5832 register call rnib ; get month msb cpi 1 jnz month ; jump if less than august. mvi a,9 call rnib ; get month lsb lxi d,mo10 cpi 0 jz pmo lxi d,mo11 cpi 1 jz pmo lxi d,mo12 ; must be december jmp pmo month: mvi a,9 ; get month lsb call rnib lxi d,mo1 cpi 1 jz pmo lxi d,mo2 cpi 2 jz pmo lxi d,mo3 cpi 3 jz pmo lxi d,mo4 cpi 4 jz pmo lxi d,mo5 cpi 5 jz pmo lxi d,mo6 cpi 6 jz pmo lxi d,mo7 cpi 7 jz pmo lxi d,mo8 cpi 8 jz pmo lxi d,mo9 pmo: mvi c,9 call 5 ; print name of month mvi a,0ch ; MSM5832 register call pnib ; print year msb mvi a,0bh ; MSM5832 register call pnib ; print year lsb mvi e,' ' mvi c,2 call 5 ; pretty print mvi a,5 call rnib ; get hours msb ani 3 ; mask gibberish adi 30h ; add ascii offset mov e,a mvi c,2 call 5 mvi a,4 call pnib mvi e,':' mvi c,2 call 5 mvi a,3 call pnib ; print minutes msb mvi a,2 call pnib ; print minutes lsb mvi e,':' mvi c,2 call 5 mvi a,1 call pnib ; print seconds msb xra a ; usual zero call pnib mvi e,0dh mvi c,2 call 5 lda frevrf ; get the forever flag ora a ; set CPU flags jz ptim ; do it forever if zero ret pnib: call rnib adi 30h ; add ascii offset mov e,a mvi c,2 jmp 5 ; os does a return rnib: mov c,a ; save address mvi a,10h ; value for hold bit out cld ; set hold bit call w150 ; wait 150 microseconds ! mov a,c ori 20h ; "set 5,a" out cla call w6 ; wait 6 microseconds in cld mov b,a xra a ; usual zero out cla ; clear read bit out cld ; clear hold bit mov a,b ani 0fh ; mask gibberish w6: ret w150: mvi b,wval ; relate this to cpu clock wl: dcr b ; "djnz wl" jnz wl ret stim: lxi h,84h ; point to cmd line gunk mov a,m ori 8h ; set 24 hour bit mvi b,5 ; point to hours reg call wnib ; write the nibble inx h mov a,m mvi b,4 call wnib ; write hours lsb inx h inx h ; skip slash & get minutes msb mov a,m mvi b,3 call wnib ; write minutes msb inx h mov a,m mvi b,2 call wnib ; write minutes lsb inx h inx h mov a,m mvi b,1 call wnib inx h mov a,m mvi b,0 jmp wnib ; returns to cmd level sday: lxi h,84h ; point to cmd line gunk mov a,m mvi b,8 call wnib ; write day msb inx h mov a,m mvi b,7 call wnib ; write day lsb inx h inx h mov a,m mvi b,10 call wnib ; write month msb inx h mov a,m mvi b,9 call wnib ; write month lsb inx h inx h mov a,m mvi b,12 call wnib ; write year msb inx h mov a,m mvi b,11 wnib: ani 0fh ; strip gibberish ori 10h ; "set 4,a" out cld mov c,b ; save address call w150 ; loiter mov a,c ; get address of register ori 10h ; "set 4,a" out cla ani 0efh ; "res 4,a" out cla xra a out cla out cld ret end