;B2Nasm - Basic to Nasm compiler
;Copyright (C) 2003  Nicholas Dark
;For more information, see license.txt
puti:
        push ax
        cmp ax,0
        jge doit
        push ax
        mov al,'-'
        call putc
        pop ax
        neg ax
doit:
        call puti2
        mov al,10
        call putc
        pop ax
        ret

puti2:
        push bx
        push cx
        push dx
        mov bx,10
        xor cx,cx
puti2lp: 
        xor dx,dx
        div bx
        or dl,'0'
        push dx
        inc cx
        or ax,ax
        jnz puti2lp
popi2lp: 
        pop ax
        call putc
        loop popi2lp
        pop dx
        pop cx
        pop bx
ret

