.title edresl misc cluster lib support routines for C TED .psect rescod ,ro,i,lcl,rel,con .enabl gbl .mcall qiow$s .macro save list .if b , .ift save .iff .irp x, mov x,-(sp) .endr .endc .endm save .macro unsave list .if b , .ift unsave .iff .irp x, mov (sp)+,x .endr .endc .endm unsave .sbttl terminal read/write binary mode ; putbin(buffer,len) ; ; Passed: ; 2(sp) buffer address ; 4(sp) buffer length .WRITE = EMT + 4 XRB = 442 putbin::save ; save temp registers mov 6(sp) ,r0 ; get the passed length please bne 20$ ; something real to print mov 4(sp) ,r1 ; null length, asssume .asciz 10$: tstb (r1)+ ; find the end of the string beq 20$ ; found it inc r0 ; not ye, len++ br 10$ ; go back for next one 20$: mov r0 ,-(sp) call gsys cmpb r0 ,#4 ; RSTS/E ? bne 30$ ; no, rsx or p/os mov #XRB ,r1 ; yes, do straight .writes mov @sp ,(r1)+ ; size of the write mov (sp)+ ,(r1)+ ; size of the write, again mov 4(sp) ,(r1)+ ; buffer address clr (r1)+ ; channel zero clr (r1)+ ; unused clr (r1)+ ; unused also mov #4096. ,(r1)+ ; io.wal .WRITE br 40$ ; exit 30$: mov (sp)+ ,r0 ; mov 4(sp) ,r1 qiow$s #io.wal,#5,,,,, ; rsx and p/os 40$: clr r0 ; assume no errors and exit unsave ; pop register return ; ;putbin::mov 2(sp) ,r1 ; mov r1 ,r0 ;10$: tstb (r0)+ ; bne 10$ ; sub r1 ,r0 ; dec r0 ; qiow$s #io.wal,#5,,,,, ; return ; .save ; .globl $vexta ; .psect $$vex1 ,rw,d,gbl,rel,ovr ;.vex1: .word termtype ; .word systype ; .word 0 ; .restore gterm:: mov @#$vext ,r0 mov @(r0) ,r0 return gsys:: mov @#$vext ,r0 mov @2(r0) ,r0 return gvext:: mov @#$vext ,r0 return .sbttl get date and time .enabl lc .mcall gtim$s rgetti::save mov @r5 ,r0 ; can't use sp for arg in clusters sub #16. ,sp ; make room for result mov sp ,r1 ; result addr for gtim$ gtim$s r1 ; get time and date mov g.tida(r1),r2 ; r2 := day jsr pc ,cnvert ; convert and store day movb #'- ,(r0)+ ; insert dash mov g.timo(r1),r2 ; r2 := month asl r2 add g.timo(r1),r2 ; r2 := 3*month add #mnthtab-3,r2 ; r2 := mnthtab[3*month]@ movb (r2)+ ,(r0)+ movb (r2)+ ,(r0)+ ; store month name movb (r2)+ ,(r0)+ movb #'- ,(r0)+ ; insert dash mov @r1 ,r2 ; r2 := year jsr pc ,cnvert ; convert and store year movb #40 ,(r0)+ ; final space movb #40 ,(r0)+ ; final space mov #3,r3 ; loop count := 3 add #g.tihr,r1 ; start with hours 1$: mov (r1)+,r2 ; begin loop jsr pc,cnvert ; convert to ascii and store dec r3 ; if done beq 2$ ; then exit loop movb #':,(r0)+ ; else insert colon br 1$ ; end loop 2$: add #16.,sp clrb @r0 ; .asciz and exit unsave return ; ; cnvert: internal procedure to convert ; integer in r2 to ascii. cnvert: add #366,r2 ;begin loop tstb r2 bpl cnvert ;end loop add #"00-366,r2 ;convert to ascii swab r2 ;reorder bytes movb r2,(r0)+ ;store digit swab r2 movb r2,(r0)+ ;store digit rts pc ; .save .psect rwdata mnthtab:.ascii /JanFebMarAprMayJunJulAugSepOctNovDec/ .even .restore .sbttl local copy of csv.mac for the reslib .iif ndf C$PMTR C$PMTR = 4 ;formal[n] @ c$pmtr+(r5) .iif ndf C$AUTO C$AUTO = -6 ;local[n] @ c$auto-(r5) .iif ne C$PMTR-4 .error Bad definition of C$PMTR .iif ne C$AUTO+6 .error Bad definition of C$AUTO ; ; By defining C$PMTR and C$AUTO as local symbols, the task ; builder need not do so much work ;05- .psect c$code ; ; save R4-R2 and make a one-word temp slot on the stack. ; C$SAV:: ;06 CSV$:: MOV R5, R0 MOV SP, R5 MOV R4, -(SP) MOV R3, -(SP) MOV R2, -(SP) JSR PC,(R0) ;TST -(SP) JMP (R0) ;04 ; ; pop R2-R4 and restore stack linkage registers. ; C$RET:: ;06 CRET$:: MOV R5, R2 ;03 + MOV -(R2), R4 MOV -(R2), R3 MOV -(R2), R2 ;03 - C$RETS:: ;Funny Whitesmith's entry ;06 MOV R5, SP MOV (SP)+, R5 RTS PC .end