;--------------------------------------------------------
; File Created by SDCC : FreeWare ANSI-C Compiler
; Version 2.6.1 #4330 (Oct 18 2006)
; This file generated Wed Oct 18 23:45:39 2006
;--------------------------------------------------------
	.module _ltoa
	.optsdcc -mz80
	
;--------------------------------------------------------
; Public variables in this module
;--------------------------------------------------------
	.globl __ltoa
	.globl __ultoa
;--------------------------------------------------------
; special function registers
;--------------------------------------------------------
;--------------------------------------------------------
;  ram data
;--------------------------------------------------------
	.area _DATA
;--------------------------------------------------------
; overlayable items in  ram 
;--------------------------------------------------------
	.area _OVERLAY
;--------------------------------------------------------
; external initialized ram data
;--------------------------------------------------------
;--------------------------------------------------------
; global & static initialisations
;--------------------------------------------------------
	.area _HOME
	.area _GSINIT
	.area _GSFINAL
	.area _GSINIT
;--------------------------------------------------------
; Home
;--------------------------------------------------------
	.area _HOME
	.area _CODE
;--------------------------------------------------------
; code
;--------------------------------------------------------
	.area _CODE
;_ltoa.c:18: void _ultoa(unsigned long value, char* string, unsigned char radix)
;	genLabel
;	genFunction
;	---------------------------------
; Function _ultoa
; ---------------------------------
__ultoa_start::
__ultoa:
	push	ix
	ld	ix,#0
	add	ix,sp
	ld	hl,#-41
	add	hl,sp
	ld	sp,hl
;_ltoa.c:25: do {
;	genAddrOf
;	AOP_STK for __ultoa_sloc2_1_0
	ld	hl,#0x0008
	add	hl,sp
	ld	-41(ix),l
	ld	-40(ix),h
;	genAssign
;	AOP_STK for __ultoa_index_1_1
	ld	-1(ix),#0x20
;	genLabel
00103$:
;_ltoa.c:26: buffer[--index] = '0' + (value % radix);
;	genMinus
;	AOP_STK for __ultoa_index_1_1
	dec	-1(ix)
;	genPlus
;	AOP_STK for __ultoa_sloc2_1_0
;	AOP_STK for __ultoa_index_1_1
;	AOP_STK for __ultoa_sloc0_1_0
;	Can't optimise plus by inc, falling back to the normal way
	ld	a,-41(ix)
	add	a,-1(ix)
	ld	-35(ix),a
	ld	a,-40(ix)
	adc	a,#0x00
	ld	-34(ix),a
;	genCast
;	AOP_STK for 
;	AOP_STK for __ultoa_sloc1_1_0
	ld	a,10(ix)
	ld	-39(ix),a
	ld	-38(ix),#0x00
	ld	-37(ix),#0x00
	ld	-36(ix),#0x00
;	genIpush
; _saveRegsForCall: sendSetSize: 0 deInUse: 0 bcInUse: 0 deSending: 0
;	AOP_STK for __ultoa_sloc1_1_0
	ld	l,-37(ix)
	ld	h,-36(ix)
	push	hl
	ld	l,-39(ix)
	ld	h,-38(ix)
	push	hl
;	genIpush
;	AOP_STK for 
	ld	l,6(ix)
	ld	h,7(ix)
	push	hl
	ld	l,4(ix)
	ld	h,5(ix)
	push	hl
;	genCall
	call	__modulong_rrx_s
	ld	b,d
	ld	c,e
	ld	e,h
	ld	d,l
	pop	af
	pop	af
	pop	af
	pop	af
;	genCast
; Removed redundent load
;	genPlus
;	genPlusIncr
;	Can't optimise plus by inc, falling back to the normal way
	ld	a,d
	add	a,#0x30
;	genAssign (pointer)
;	AOP_STK for __ultoa_sloc0_1_0
;	isBitvar = 0
	ld	l,-35(ix)
	ld	h,-34(ix)
	ld	(hl),a
;_ltoa.c:27: if ( buffer[index] > '9') buffer[index] += 'A' - '9' - 1;
;	genPointerGet
;	AOP_STK for __ultoa_sloc0_1_0
	ld	l,-35(ix)
	ld	h,-34(ix)
	ld	c,(hl)
;	genCmpGt
	ld	a,#0x39
	sub	a,c
	jp	P,00102$
;	genPointerGet
;	AOP_STK for __ultoa_sloc0_1_0
	ld	l,-35(ix)
	ld	h,-34(ix)
	ld	c,(hl)
;	genPlus
;	genPlusIncr
;	Can't optimise plus by inc, falling back to the normal way
	ld	a,c
	add	a,#0x07
;	genAssign (pointer)
;	AOP_STK for __ultoa_sloc0_1_0
;	isBitvar = 0
	ld	l,-35(ix)
	ld	h,-34(ix)
	ld	(hl),a
;	genLabel
00102$:
;_ltoa.c:28: value /= radix;
;	genIpush
; _saveRegsForCall: sendSetSize: 0 deInUse: 0 bcInUse: 0 deSending: 0
;	AOP_STK for __ultoa_sloc1_1_0
	ld	l,-37(ix)
	ld	h,-36(ix)
	push	hl
	ld	l,-39(ix)
	ld	h,-38(ix)
	push	hl
;	genIpush
;	AOP_STK for 
	ld	l,6(ix)
	ld	h,7(ix)
	push	hl
	ld	l,4(ix)
	ld	h,5(ix)
	push	hl
;	genCall
	call	__divulong_rrx_s
; Removed redundent load
; Removed redundent load
	ld	b,h
	ld	c,l
	pop	af
	pop	af
	pop	af
	pop	af
;	genAssign
;	AOP_STK for 
	ld	4(ix),c
	ld	5(ix),b
	ld	6(ix),e
	ld	7(ix),d
;_ltoa.c:29: } while (value != 0);
;	genCmpEq
;	AOP_STK for 
; genCmpEq: left 4, right 4, result 0
	ld	a,4(ix)
	or	a,5(ix)
	or	a,6(ix)
	or	a,7(ix)
	jp	NZ,00117$
	jp	00118$
00117$:
	jp	00103$
00118$:
;_ltoa.c:31: do {
;	genAssign
;	AOP_STK for __ultoa_index_1_1
;	(registers are the same)
;	genAssign
;	AOP_STK for 
	ld	e,8(ix)
	ld	d,9(ix)
;	genLabel
00106$:
;_ltoa.c:32: *string++ = buffer[index++];
;	genAssign
;	AOP_STK for __ultoa_index_1_1
	ld	b,-1(ix)
;	genPlus
;	AOP_STK for __ultoa_index_1_1
;	genPlusIncr
	inc	-1(ix)
;	genPlus
;	AOP_STK for __ultoa_sloc2_1_0
;	Can't optimise plus by inc, falling back to the normal way
	ld	a,-41(ix)
	add	a,b
	ld	b,a
	ld	a,-40(ix)
	adc	a,#0x00
	ld	c,a
;	genPointerGet
	ld	l,b
	ld	h,c
	ld	a,(hl)
;	genAssign (pointer)
;	isBitvar = 0
	ld	(de),a
;	genPlus
;	genPlusIncr
	inc	de
;_ltoa.c:33: } while ( index < NUMBER_OF_DIGITS );
;	genCmpLt
;	AOP_STK for __ultoa_index_1_1
	ld	a,-1(ix)
	sub	a,#0x20
	jp	C,00106$
;_ltoa.c:35: *string = 0;  /* string terminator */
;	genAssign (pointer)
;	isBitvar = 0
	ld	a,#0x00
	ld	(de),a
;	genLabel
00109$:
;	genEndFunction
	ld	sp,ix
	pop	ix
	ret
__ultoa_end::
;_ltoa.c:38: void _ltoa(long value, char* string, unsigned char radix)
;	genLabel
;	genFunction
;	---------------------------------
; Function _ltoa
; ---------------------------------
__ltoa_start::
__ltoa:
	push	ix
	ld	ix,#0
	add	ix,sp
;_ltoa.c:40: if (value < 0 && radix == 10) {
;	genCmpLt
;	AOP_STK for 
	ld	a,7(ix)
	bit	7,a
	jp	Z,00102$
;	genCmpEq
;	AOP_STK for 
; genCmpEq: left 1, right 1, result 0
	ld	a,10(ix)
	cp	a,#0x0A
	jp	NZ,00108$
	jp	00109$
00108$:
	jp	00102$
00109$:
;_ltoa.c:41: *string++ = '-';
;	genAssign
;	AOP_STK for 
	ld	c,8(ix)
	ld	b,9(ix)
;	genAssign (pointer)
;	isBitvar = 0
	ld	a,#0x2D
	ld	(bc),a
;	genPlus
;	AOP_STK for 
;	genPlusIncr
;	Can't optimise plus by inc, falling back to the normal way
	ld	a,c
	add	a,#0x01
	ld	8(ix),a
	ld	a,b
	adc	a,#0x00
	ld	9(ix),a
;_ltoa.c:42: value = -value;
;	genUminus
;	AOP_STK for 
	xor     a,a
	sbc	a,4(ix)
	ld	4(ix),a
	ld	a,#0x00
	sbc	a,5(ix)
	ld	5(ix),a
	ld	a,#0x00
	sbc	a,6(ix)
	ld	6(ix),a
	ld	a,#0x00
	sbc	a,7(ix)
	ld	7(ix),a
;	genLabel
00102$:
;_ltoa.c:44: _ultoa(value, string, radix);
;	genAssign
;	AOP_STK for 
	ld	c,4(ix)
	ld	b,5(ix)
	ld	e,6(ix)
	ld	d,7(ix)
;	genIpush
; _saveRegsForCall: sendSetSize: 0 deInUse: 0 bcInUse: 0 deSending: 0
;	AOP_STK for 
	ld	a,10(ix)
	push	af
	inc	sp
;	genIpush
;	AOP_STK for 
	ld	l,8(ix)
	ld	h,9(ix)
	push	hl
;	genIpush
	push	de
	push	bc
;	genCall
	call	__ultoa
	pop	af
	pop	af
	pop	af
	inc	sp
;	genLabel
00104$:
;	genEndFunction
	pop	ix
	ret
__ltoa_end::
	.area _CODE
