.title itoa Integer to Ascii .ident /000003/ ; ;+ ; ; Index Convert integer to Ascii ; ; Usage ; ; char * ; itoa(value, string) ; int value; ; char *string; ; ; Description ; ; itoa converts the value to a (signed) decimal string. ; The string is null-trailed. itoa returns a pointer to ; the trailing null. ; ; Note that the result can be computed (more flexibly) ; by executing sprintf(buffer, "%d", value); ; ; Bugs ; ;- ; Edit history ; ; 000001 06-Feb-80 MM Initial edit ; 000002 22-Aug-80 MM Return pointer in R0 ; 000003 22-Feb-82 CCG Fixed sign bug .psect c$code itoa:: mov 4(sp), r0 ;r0 -> string mov 2(sp), r1 ;r1 := datum ;03 bpl 10$ ;03 neg r1 movb #'-, (r0)+ 10$: jsr pc, 20$ clrb (r0) rts pc 20$: mov r1,-(sp) clr r1 30$: inc r1 sub #10.,@sp bhis 30$ add #'0+10.,@sp dec r1 beq 40$ jsr pc,20$ 40$: movb (sp)+,(r0)+ rts pc .end