.title atoi8 Convert Ascii octal number to integer .ident /000001/ ;+ ; ; Index Convert Ascii octal number to integer ; ; Usage ; ; atoi8(p) ; char *p; ; ; Description ; ; Convert an Ascii octal number to an integer. No data checking ; is performed. The conversion stops at the first non-octal integer. ; Leading spaces, tabs, plus-signs and/or newlines are ignored. ; ;- ; Edit History ; 000001 17-Jan-83 TTC Initial edit ; .psect c$code atoi8:: jsr r5,csv$ ; Linkage mov c$pmtr+0(r5),r4 ; r4 = ptr to string clr r3 ; r3 = number 10$: movb (r4)+,r0 ; Grab byte beq 30$ ; Done cmp r0,#12 ; Ignore newlines beq 10$ ; cmp r0,#11 ; Tabs beq 10$ ; cmp r0,#'+ ; Plus signs beq 10$ ; cmp r0,#' ; and spaces beq 10$ ; 20$: sub #'0,r0 ; Convert to octal int cmp r0,#7. ; Legal ? bhi 30$ ; No, done asl r3 ; r3 = 8*r3 asl r3 ; asl r3 ; add r0,r3 ; r3 = r3 + new movb (r4)+,r0 ; get next bne 20$ ; Br if not end 30$: mov r3,r0 ; Return to caller jmp cret$ ; .end