This repository has been archived on 2021-01-14. You can view files and clone it, but cannot push or open issues or pull requests.
xed/lib/___itoa.s
2020-09-19 22:16:34 +02:00

37 lines
555 B
ArmAsm

#code _CODE
#include "___uitoa.s"
;
;void __itoa(int value, char *string, unsigned char radix);
;
___itoa::
push ix
ld ix, #0
add ix, sp
;
; 4(ix) - value
; 6(ix) - string
; 8(ix) - radix
;
ld e, 4 (ix)
ld d, 5 (ix)
bit 7, d
jp Z, ___uitoa_de
;positive/negative numbers are supported only for radix=10
ld a, 8 (ix)
cp a, #10
jp NZ, ___uitoa_de
;add minus sign to result and inverse value
ld hl, #0
or a, a
sbc hl, de
ex de, hl
ld l, 6 (ix)
ld h, 7 (ix)
ld (hl), #0x2D ;minus symbol
inc hl
ld 6 (ix), l
ld 7 (ix), h
jp ___uitoa_dehl