.title time .ident /840525/ .mcall .gtim,.gval .globl v.stat,v.area ; ; Returns the current system time in ascii ; ; Register usage: ; R0 scratch ; R1 pointer to string ; R2 scratch ; R3 scratch ; R4 scratch ; R5 time conversion table ; time:: mov (sp)+,r0 ; Return address mov (sp)+,r1 ; String mov r0,-(sp) ; Move up return address mov r5,-(sp) mov r4,-(sp) mov r3,-(sp) mov r2,-(sp) ; .gval #v.area,#300 ; Find frequency of clock mov #50.,r4 ; Assume 50Hz bit #40,r0 bne 1$ mov #60.,r4 ; No, 60Hz 1$: mov #timtab,r5 mov r4,(r5) ; .gtim #v.area,#v.stat mov v.stat,r2 ; Get time mov v.stat+2,r3 ; 2$: mov #32.,r4 ; Thirty two bit dividend clr r0 ; Sixteen bit remainder 3$: asl r3 ; Get next binary place rol r2 rol r0 ; Shift into work register cmp (r5),r0 bhi 4$ ; Won't go sub (r5),r0 ; Divide inc r3 ; Thirty two bit quotient 4$: sob r4,3$ ; Next place ; mov r0,-(sp) ; Save remainder cmp (r5)+,(r5) ble 2$ ; Some more work ; mov (r5),4(sp) ; Don't want tick count 5$: call bindec mov (sp)+,r3 ; Get next value bmi 6$ ; End of list movb #':,(r1)+ br 5$ ; Move next value ; 6$: clrb (r1) ; Terminate string mov (sp)+,r2 ; Restore mov (sp)+,r3 mov (sp)+,r4 mov (sp)+,r5 rts pc ; bindec: clr r2 ; Convert to ascii div #10.,r2 add #'0,r2 add #'0,r3 movb r2,(r1)+ ; Move to string movb r3,(r1)+ rts pc ; .psect $varbl timtab: .word 0.,60.,60.,-1 .end