include mc.ash .model small ; ;Support routines for PRINTF.C ; ;Tom Jennings ;22 Jan 92 ; .code ;/* ; Internal routine used by "_spr" to perform ascii- ; to-decimal conversion and update an associated pointer: ;*/ ; ;int _gv2(sptr) ;char **sptr; ;{ ;int n; ; n = 0; ; while (isdigit(**sptr)) n = 10 * n + *(*sptr)++ - '0'; ; return(n); ;} func __gv2 push si mov si,arg0 ;SI= *sptr mov bx,[si] ;BX= sptr mov dx,0 ;N= 0 mov ah,0 gv1: mov al,[bx] ;AL= *sptr sub al,'0' ; jc gvz ; < '0' cmp al,10 jnc gvz ; > '9' add dx,dx ; N *= 2 mov cx,dx ; (save that) add dx,dx ; N *= 4 add dx,dx ; N *= 8 add dx,cx ; N *= 10 add dx,ax ; + digit inc bx jmp gv1 gvz: mov [si],bx pop si mov ax,dx endf __gv2 end