;[]=====================================[]
; Вывод в десятичном формате (32-bit)
; в буфер строки (рег."de")
; вход:
;   hl = ст.разряд, hl'= мл.разряд
;   de = буфер строки
IntToChar32:
	exx
	ld	bc,0CA00h		; 1.000.000.000
	exx
	ld	bc,3B9Ah
	exx
	ld	ix,tmp1
	res	7,(ix+0)
	call	GetLen32
	ld	bc,0E100h		; 100.000.000
	exx
	ld	bc,05F5h
	exx
	call	GetLen32
	ld	bc,9680h		; 10.000.000
	exx
	ld	bc,98h
	exx
	call	GetLen32
	ld	bc,4240h		; 1.000.000...9.999.999
	exx
	ld	bc,0Fh
	exx
	call	GetLen32
	ld	bc,86A0h		; 100.000...999.999
	exx
	ld	bc,1
	exx
	call	GetLen32
; вывод 16-bit (hl'= 0)
IntToChar16:
	ld	bc,10000		; 10.000...99.999
	exx
	ld	bc,0
	exx
	call	GetLen32
	ld	bc,1000			; 1.000..9.999
	call	GetLen16
DigitToChar:
	ld	bc,100			; 100..999
	call	GetLen16
	ld	bc,10			; 10..99
	call	GetLen16
	ld	a,l
	add	a,"0"
	ld	(de),a
	ret

tmp1:	db	0

GetLen32:
	ld	a,2Fh
	or	a
glen32_loc1:
	inc	a
	sbc	hl,bc
	exx
	sbc	hl,bc
	exx
	jr	nc,glen32_loc1
	add	hl,bc
	exx
	adc	hl,bc
	exx
glen32:	cp	"0"
	jr	z,glen32_loc2
	set	7,(ix+0)
glen32_loc2:
	bit	7,(ix+0)
	ret	z
	ld	(de),a
	inc	de
	ret

GetLen16:
	ld	a,2Fh
	or	a
glen16_loc1:
	inc	a
	sbc	hl,bc
	jr	nc,glen16_loc1
	add	hl,bc
	jr	glen32
