.title stor50 .ident /840126/ .enabl lc ; ;Converts a string of ASCII characters to RAD50 ; ;Registers used ; R0 RAD50 character count ; R1 ASCII character temporary ; R2 pointer to ASCII string ; R3 number of RAD50 characters desired ; R4 pointer to integer array ; R5 RAD50 character packing temporary ; stor50:: mov sp,r0 mov r2,-(sp) mov (r0),r1 mov r3,(r0)+ mov (r0),r3 ;length of RAD50 string mov r4,(r0)+ mov (r0),r4 ;integer array mov r5,(r0)+ mov (r0),r2 ;ASCII string mov r1,(r0) ; newtri: tst r3 ;check count ble fin ;all done mov #3,r0 ;pack three characters per word clr r5 ;none yet mov r4,-(sp) oldtri: clr r1 ;clear out rubbish mov r3,-(sp) beq cnv ;pack rest of integer movb (r2),r1 ;get next char to convert beq cnv ;end of string, pad with blanks bmi 1$ ;illegal character mov r1,r3 ;check character mov #1,r4 ash #-4,r3 ;form index into table asl r3 bic #^c17,r1 ;form bit template ash r1,r4 bit r4,cnvbit(r3) beq 1$ ;illegal char ; movb (r2)+,r1 ;get character jmp @cnvtab(r3) ;convert ; 1$: movb #'/,r1 ;use illegal char symbol ; cnv2: cmpb r1,#'$ ;space, dollar sign, period, slash bhi cnv3 beq 1$ add #^R -' -^r $+'$,r1 ;space 1$: add #^R $-'$-^R 0+'0,r1 ;dollar sign cnv3: add #^R 0-'0-^R A+'A,r1 ;period, slash, 0-9 cnv4: cnv5: add #^R A-'A-^R A+'a,r1 ;A-Z cnv6: cnv7: add #^R A-'a,r1 ;A-Z ; cnv: mul #50,r5 ;pack char add r1,r5 mov (sp)+,r3 ;retrieve char count beq 1$ ;no more required dec r3 1$: sob r0,oldtri ;must keep packing ; mov (sp)+,r4 mov r5,(r4)+ ;store new triple br newtri ; fin: mov (sp)+,r2 ;return mov (sp)+,r3 mov (sp)+,r4 mov (sp)+,r5 rts pc ; cnvbit: .word ^b0000000000000000 .word ^b0000000000000000 .word ^b0100000000010001 .word ^b0000001111111111 .word ^b1111111111111110 .word ^b0000011111111111 .word ^b1111111111111110 .word ^b0000011111111111 ; cnvtab =.-4 .word cnv2,cnv3,cnv4,cnv5,cnv6,cnv7 .end