.TITLE RDASC Read ascii strings .NLIST BEX .ENABL LC ; ; Pdp11/dcn - read ascii strings ; ; External symbols ; .GLOBL TYPE ;determine char type .GLOBL RDBYT ;read byte ; ; Entry symbols ; .GLOBL RDASC ;read ascii char .GLOBL RDDEC ;read decimal string .GLOBL HASH ;read rad50 string .GLOBL RDOCT ;read octal string .GLOBL GETARG ;read argument string ; ; Procedure segment ; .PSECT $BOSI,RO,I ; ; Rdasc (rda) read ascii char and determine type ; Returns r0 = trimmed char, cc = ; Z eor ; C special ; N digit ; V letter ; RDASC: JSR PC,RDBYT ;get next char BEQ 1$ ;branch if eor JSR PC,TYPE ;clean char and type BEQ RDASC ;branch if special char RTS PC ; 1$: CLR R0 ;clean exit for eor RTS PC ; ; Hash (rdo) read rad50 string ; Rddec (rdo) read decimal string ; Rdoct (rdo) read octal string ; Returns r0 = number/hashed name, cc = ; Z eor ; N number ; V hashed name ; HASH = . ;(we don't tell the natives) RDDEC: MOV #10.,-(SP) ;set radix BR RDO1 ; RDOCT: MOV #8.,-(SP) ;4(sp). set radix RDO1: CLR -(SP) ;2(sp). set sign switch MOV R1,-(SP) ;0(sp). save register CLR R1 ;clear accumulator 1$: JSR PC,RDASC ;read next char and type BEQ 11$ ;branch if eor BMI 8$ ;branch if digit BCC 2$ ;branch if letter CMP R0,#'- ;special. is it minus BNE 1$ ;branch if no COM 2(SP) ;yes. complement sign switch BR 1$ ; 2$: ADD #1-'A,R0 ;letter. convert to rad50 3$: ADD R0,R1 4$: JSR PC,RDASC ;read next char BEQ 6$ ;branch if eor BCS 6$ ;branch if special BPL 5$ ;branch if letter ADD #36-'0-1+'A,R0 ;digit 5$: ADD #1-'A,R0 ;convert to rad50 CMP R1,#50*50 ;any more significant chars BHI 4$ ;branch if no MUL #50,R1 ;multiply by 50 BR 3$ ; 6$: CMP R1,#50*50 ;is value left justified BHIS 7$ ;branch if yes MUL #50,R1 ;no. multiply by 50 BR 6$ ; 7$: MOV R1,R0 ;get assembled value MOV (SP)+,R1 ;restore conditions CMP (SP)+,(SP)+ CCC SEV RTS PC ; 8$: ADD #0-'0,R0 ;convert to numeric ADD R0,R1 JSR PC,RDASC ;read next char and type BPL 9$ ;branch if not digit MUL 4(SP),R1 ;multiply accumulator by radix BR 8$ ; 9$: MOV R1,R0 ;get assembled value MOV (SP)+,R1 ;restore register TST (SP)+ ;test sign switch BEQ 10$ ;branch if positive NEG R0 ;negative. complement 10$: TST (SP)+ ;pop off radix CCC SEN RTS PC ; 11$: MOV (SP)+,R1 ;eor. restore conditions CMP (SP)+,(SP)+ CLR R0 ;return zero RTS PC ; ; Getarg (gta) read argument string ; R1 = output string pointer ; GETARG: JSR PC,RDBYT ;strip leading blanks BEQ 2$ CMPB R0,#<' > BLOS GETARG 1$: MOVB R0,(R1)+ ;store byte JSR PC,RDBYT BEQ 2$ CMPB R0,#<' > BHI 1$ 2$: CLRB @R1 RTS PC ; .END