/ PROGRAM i2a .title i2a .ident /1nov80/ ;AUTO s[100],n ; FUNCTION main[argc,argv] ;LET n = val[.argv[#1],#10.] ;LET r0 = i2a[n,&s] ;clrb (r0)+ ;PRINTF "str=(%s) s=%o r0=%o" &s &s r0 ; RET ;+ ; i2a - returns to string at a the integer (decimal) ; string representing the value i. The function ; returns the address of the next location after ; the string. This is to permit the user to null ; terminate it or do otherwise. ;- AUTO s,n,rem FUNCTION i2a[i,a] LET r4 = a IF i LT #0 neg i(r5) LET s = #-1 ELSE clr s(r5) FI clr n(r5) DO FOREVER LET r3 = i / #10. * #10. LET rem = i - r3 LET i = i / #10. LET n = n + #1 PUSH rem BREAK IF i LE #0 OD IF s LT #0 movb #'-,(r4)+ FI LOOP for r3 = #1 TO n POP r0 add #'0,r0 movb r0,(r4)+ NEXT r3 RET r4 .end