.title r50tos .ident /840117/ ; ;Converts a radix 50 string of characters to ;a string of ascii characters. ; ;Register usage ; R0 scratch ; R1 scratch ; R2 scratch ; R3 string (ASCII) ; R4 number of characters to translate ; R5 string (RAD50) ; r50tos:: mov sp,r0 mov (r0),r1 mov r2,(r0)+ mov (r0),r2 ;maximum length allowable mov r3,(r0)+ mov (r0),r3 ;ASCII string mov r4,(r0)+ mov (r0),r4 ;number of RAD50 characters mov r5,(r0)+ mov (r0),r5 ;RAD50 string mov r1,(r0) ; cmp r4,r2 ;see which to use blos 1$ mov r2,r4 ;use smallest value 1$: tst r4 beq 3$ ;nothing to do ; 2$: mov #3,r2 ;convert three per call mov (r5)+,r0 jsr pc,r50con br 1$ ;loop until all done ; 3$: clrb (r3)+ ;null to end string mov (sp)+,r2 mov (sp)+,r3 mov (sp)+,r4 mov (sp)+,r5 rts pc ; r50con:: mov r0,r1 ;set up for division clr r0 div #50,r0 tst r1 ;convert to ASCII beq 1$ cmp r1,#^r $ bhi 2$ beq 3$ add #'A-^r A-' +^r ,r1 1$: add #' -^r -'.+^r .,r1 2$: add #'.-^r .-'$+^r $,r1 3$: add #'$-^r $,r1 movb r1,-(sp) dec r2 ;adjust recursion count beq 4$ jsr pc,r50con ;convert high order characters 4$: movb (sp)+,r1 ;obtain current character tst r4 ;check number of characters converted beq 5$ dec r4 ;o.k., store another movb r1,(r3)+ 5$: rts pc ; .end