nor86/strint.inc

34 lines
348 B
PHP

; IN:
; ax = number to convert
; ds:bx = storage buffer
; OUT:
; ds:bx = start of converted number
itoa:
push ax
push cx
push dx
mov cx, 10
add bx, 5
mov byte [bx], 0
.convert_loop:
test ax, ax
jz .end
xor dx, dx
div cx
add dl, '0'
dec bx
mov byte [bx], dl
jmp .convert_loop
.end:
pop dx
pop cx
pop ax
ret