	.title	$5toa -- Radix 50 to Ascii
 
	.enabl	lc
	.nlist	bex
 
; A Compiler for the Post Office
; Convert radix 50 to ascii characters.
;
; Copyright (c) 1977 by Teklogix Ltd.
 
	.globl	$5toa
 
	.mcall	call,	return
 
;+
; ** $5toa -- convert radix 50 to ascii characters
;
; Inputs:
;	r0=radix 50 word
;	r1=pointer to output buffer
;
; Outputs:
;	r1=updated
;-
 
$5toa:	mov	r2,-(sp)	;Save registers
	mov	r3,-(sp)
	mov	r0,r3		;Set up argument word
	call	10$		;1st character
	mov	r2,-(sp)
	call	10$		;2nd character
	mov	r2,-(sp)
	call	10$		;3rd character
	movb	r2,(r1)+	;Put out the 3 characters
	movb	(sp)+,(r1)+
	movb	(sp)+,(r1)+
	mov	(sp)+,r3	;Return
	mov	(sp)+,r2
	return
 
10$:	clr	r2		;Sxt
	div	#50,r2		;Get one character
	mov	r3,-(sp)	;Get remainder
	mov	r2,r3
	mov	(sp)+,r2
	beq	40$		;Branch on blank
	cmp	r2,#33
	blt	30$		;Branch on alpha
	beq	20$		;Branch on dollar sign
	add	#22-11,r2	;Create ascii
20$:	add	#11-140,r2
30$:	add	#140-40,r2
40$:	add	#40,r2
	return
 
	.end
