.TITLE ATOR .PSECT .PROG. .IDENT /02/ .ENABL LC ; ; P. Hays 24 May 79 ; ; Convert 'C' string to RAD50. ; ; int * ; ator(r, n, cp) int *r; int n; char *cp; ; ; ; Offsets to the arguments re the stackframe: a.out = 12 a.n = 14 a.in = 16 term: .word 0 ; Fake 'terminated string' ator:: jsr r0,$$csav mov a.out(r5), r1 mov a.in(r5), r0 5$: dec a.n(r5) ; while(n--) { bmi 45$ mov #3, r3 ; Setup count of chars per word clr (r1) 10$: dec r3 ; while still filling a word bmi 42$ movb (r0),r2 ; Get character; if nonzero inc ptr & convert beq 35$ inc r0 cmp r2,#' blo 35$ beq 30$ cmp r2,#'$ beq 25$ cmp r2,#'. beq 20$ cmp r2,#'0 blo 35$ cmp r2,#'9 blos 20$ cmp r2,#'A blo 35$ cmp r2,#'Z blos 15$ cmp r2,#'a blo 35$ cmp #'z,r2 blo 35$ ; Lowercase alpha sub #40,r2 15$: ; Uppercase alpha sub #56,r2 20$: ; Numeric and '.' sub #11,r2 25$: ; '$' add #27,r2 30$: ; SPace sub #40,r2 br 40$ 35$: ; From now on, fill with blanks mov #term, r0 clr r2 40$: asl (r1) ; Multiply current word by 050 asl (r1) asl (r1) mov (r1),-(sp) asl (r1) asl (r1) add (sp)+,(r1) add r2,(r1) ; Add in the new character br 10$ ; Loop ^ 42$: tst (r1)+ ; Advance the output pointer br 5$ ; Loop ^ 45$: mov a.out(r5),r0 ; Return the address of the rad50 buffer jmp $$cret .end