;--------------------------------------------------------
; File Created by SDCC : FreeWare ANSI-C Compiler
; Version 2.6.1 #4330 (Oct 18 2006)
; This file generated Wed Oct 18 23:45:59 2006
;--------------------------------------------------------
	.module _ltoa
	.optsdcc -mgbz80
	
;--------------------------------------------------------
; Public variables in this module
;--------------------------------------------------------
	.globl __ltoa
	.globl __ultoa
;--------------------------------------------------------
;  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:
	lda	sp,-45(sp)
;_ltoa.c:25: do {
;	genAddrOf
;	AOP_STK for __ultoa_sloc0_1_0
	lda	hl,12(sp)
	ld	a,l
	ld	d,h
	lda	hl,10(sp)
	ld	(hl+),a
	ld	(hl),d
;	genAssign
	ld	b,#0x20
;	genLabel
00103$:
;_ltoa.c:26: buffer[--index] = '0' + (value % radix);
;	genMinus
	dec	b
;	genPlus
;	AOP_STK for __ultoa_sloc0_1_0
;	AOP_STK for __ultoa_sloc2_1_0
;	Can't optimise plus by inc, falling back to the normal way
	lda	hl,10(sp)
	ld	e,(hl)
	inc	hl
	ld	d,(hl)
	ld	l,b
	ld	h,#0x00
	add	hl,de
	ld	a,l
	ld	d,h
	lda	hl,4(sp)
	ld	(hl+),a
	ld	(hl),d
;	genCast
;	AOP_STK for 
;	AOP_STK for __ultoa_sloc1_1_0
	lda	hl,53(sp)
	ld	a,(hl)
	lda	hl,6(sp)
	ld	(hl+),a
	ld	(hl),#0x00
	inc	hl
	ld	(hl),#0x00
	inc	hl
	ld	(hl),#0x00
;	genIpush
; _saveRegsForCall: sendSetSize: 0 deInUse: 0 bcInUse: 1 deSending: 0
	push	bc
;	AOP_STK for __ultoa_sloc1_1_0
	dec	hl
	ld	a,(hl+)
	ld	h,(hl)
	ld	l,a
	push	hl
	lda	hl,10(sp)
	ld	a,(hl+)
	ld	h,(hl)
	ld	l,a
	push	hl
;	genIpush
;	AOP_STK for 
	lda	hl,55(sp)
	ld	a,(hl+)
	ld	h,(hl)
	ld	l,a
	push	hl
	lda	hl,55(sp)
	ld	a,(hl+)
	ld	h,(hl)
	ld	l,a
	push	hl
;	genCall
	call	__modulong_rrx_s
;	AOP_STK for __ultoa_sloc3_1_0
	push	hl
	lda	hl,12(sp)
	ld	(hl),e
	inc	hl
	ld	(hl),d
	pop	de
	inc	hl
	ld	(hl),e
	inc	hl
	ld	(hl),d
	lda	sp,8(sp)
	pop	bc
;	genCast
;	AOP_STK for __ultoa_sloc3_1_0
	lda	hl,0(sp)
	ld	c,(hl)
;	genPlus
;	genPlusIncr
;	Can't optimise plus by inc, falling back to the normal way
	ld	a,c
	add	a,#0x30
;	genAssign (pointer)
;	AOP_STK for __ultoa_sloc2_1_0
;	isBitvar = 0
	lda	hl,4(sp)
	ld	e,(hl)
	inc	hl
	ld	d,(hl)
	ld	(de),a
;_ltoa.c:27: if ( buffer[index] > '9') buffer[index] += 'A' - '9' - 1;
;	genPointerGet
;	AOP_STK for __ultoa_sloc2_1_0
	dec	hl
	ld	e,(hl)
	inc	hl
	ld	d,(hl)
	ld	a,(de)
	ld	c,a
;	genCmpGt
	ld	a,#0x39
	sub	a,c
	rlca
	jp	NC,00102$
;	genPointerGet
;	AOP_STK for __ultoa_sloc2_1_0
	dec	hl
	ld	e,(hl)
	inc	hl
	ld	d,(hl)
	ld	a,(de)
;	genPlus
;	genPlusIncr
;	Can't optimise plus by inc, falling back to the normal way
	ld	c,a
	add	a,#0x07
;	genAssign (pointer)
;	AOP_STK for __ultoa_sloc2_1_0
;	isBitvar = 0
	dec	hl
	ld	e,(hl)
	inc	hl
	ld	d,(hl)
	ld	(de),a
;	genLabel
00102$:
;_ltoa.c:28: value /= radix;
;	genIpush
; _saveRegsForCall: sendSetSize: 0 deInUse: 0 bcInUse: 1 deSending: 0
	push	bc
;	AOP_STK for __ultoa_sloc1_1_0
	lda	hl,10(sp)
	ld	a,(hl+)
	ld	h,(hl)
	ld	l,a
	push	hl
	lda	hl,10(sp)
	ld	a,(hl+)
	ld	h,(hl)
	ld	l,a
	push	hl
;	genIpush
;	AOP_STK for 
	lda	hl,55(sp)
	ld	a,(hl+)
	ld	h,(hl)
	ld	l,a
	push	hl
	lda	hl,55(sp)
	ld	a,(hl+)
	ld	h,(hl)
	ld	l,a
	push	hl
;	genCall
	call	__divulong_rrx_s
;	AOP_STK for __ultoa_sloc3_1_0
	push	hl
	lda	hl,12(sp)
	ld	(hl),e
	inc	hl
	ld	(hl),d
	pop	de
	inc	hl
	ld	(hl),e
	inc	hl
	ld	(hl),d
	lda	sp,8(sp)
	pop	bc
;	genAssign
;	AOP_STK for __ultoa_sloc3_1_0
;	AOP_STK for 
	lda	hl,0(sp)
	ld	d,h
	ld	e,l
	lda	hl,47(sp)
	ld	a,(de)
	ld	(hl+),a
	inc	de
	ld	a,(de)
	ld	(hl+),a
	inc	de
	ld	a,(de)
	ld	(hl+),a
	inc	de
	ld	a,(de)
	ld	(hl),a
;_ltoa.c:29: } while (value != 0);
;	genCmpEq
;	AOP_STK for 
; genCmpEq: left 4, right 4, result 0
	lda	hl,47(sp)
	ld	a,(hl+)
	or	a,(hl)
	inc	hl
	or	a,(hl)
	inc	hl
	or	a,(hl)
	jp	NZ,00103$
	jr	00118$
00117$:
	jp	00103$
00118$:
;_ltoa.c:31: do {
;	genAssign
;	AOP_STK for __ultoa_index_1_1
	lda	hl,44(sp)
	ld	(hl),b
;	genAssign
;	AOP_STK for 
;	AOP_STK for __ultoa_sloc3_1_0
	lda	hl,51(sp)
	ld	a,(hl+)
	ld	e,(hl)
	lda	hl,0(sp)
	ld	(hl+),a
	ld	(hl),e
;	genLabel
00106$:
;_ltoa.c:32: *string++ = buffer[index++];
;	genAssign
;	AOP_STK for __ultoa_index_1_1
	lda	hl,44(sp)
	ld	c,(hl)
;	genPlus
;	AOP_STK for __ultoa_index_1_1
;	genPlusIncr
	inc	(hl)
;	genPlus
;	AOP_STK for __ultoa_sloc0_1_0
;	Can't optimise plus by inc, falling back to the normal way
	lda	hl,10(sp)
	ld	e,(hl)
	inc	hl
	ld	d,(hl)
	ld	l,c
	ld	h,#0x00
	add	hl,de
	ld	c,l
	ld	b,h
;	genPointerGet
	ld	a,(bc)
;	genAssign (pointer)
;	AOP_STK for __ultoa_sloc3_1_0
;	isBitvar = 0
	lda	hl,0(sp)
	ld	e,(hl)
	inc	hl
	ld	d,(hl)
	ld	(de),a
;	genPlus
;	AOP_STK for __ultoa_sloc3_1_0
;	genPlusIncr
	dec	hl
	inc	(hl)
	jr	NZ,00119$
	inc	hl
	inc	(hl)
00119$:
;_ltoa.c:33: } while ( index < NUMBER_OF_DIGITS );
;	genCmpLt
;	AOP_STK for __ultoa_index_1_1
	lda	hl,44(sp)
	ld	a,(hl)
	sub	a,#0x20
	jp	C,00106$
;_ltoa.c:35: *string = 0;  /* string terminator */
;	genAssign (pointer)
;	AOP_STK for __ultoa_sloc3_1_0
;	isBitvar = 0
	lda	hl,0(sp)
	ld	e,(hl)
	inc	hl
	ld	d,(hl)
	ld	a,#0x00
	ld	(de),a
;	genLabel
00109$:
;	genEndFunction
	lda	sp,45(sp)
	ret
__ultoa_end::
;_ltoa.c:38: void _ltoa(long value, char* string, unsigned char radix)
;	genLabel
;	genFunction
;	---------------------------------
; Function _ltoa
; ---------------------------------
__ltoa_start::
__ltoa:
	
;_ltoa.c:40: if (value < 0 && radix == 10) {
;	genCmpLt
;	AOP_STK for 
	lda	hl,5(sp)
	ld	a,(hl)
	bit	7,a
	jp	Z,00102$
;	genCmpEq
;	AOP_STK for 
; genCmpEq: left 1, right 1, result 0
	lda	hl,8(sp)
	ld	a,(hl)
	cp	a,#0x0A
	jp	NZ,00102$
	jr	00109$
00108$:
	jp	00102$
00109$:
;_ltoa.c:41: *string++ = '-';
;	genAssign
;	AOP_STK for 
	lda	hl,6(sp)
	ld	c,(hl)
	inc	hl
	ld	b,(hl)
;	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	hl,#0x0001
	add	hl,bc
	ld	a,l
	ld	d,h
	lda	hl,6(sp)
	ld	(hl+),a
	ld	(hl),d
;_ltoa.c:42: value = -value;
;	genUminus
;	AOP_STK for 
	ld	de,#0x0000
	ld	a,e
	lda	hl,2(sp)
	sub	a,(hl)
	ld	e,a
	ld	a,d
	inc	hl
	sbc	a,(hl)
	push	af
	ld      (hl-),a
	ld	(hl),e
	ld	de,#0x0000
	inc	hl
	inc	hl
	pop	af
	ld	a,e
	sbc	a,(hl)
	ld	e,a
	ld	a,d
	inc	hl
	sbc	a,(hl)
	ld      (hl-),a
	ld	(hl),e
;	genLabel
00102$:
;_ltoa.c:44: _ultoa(value, string, radix);
;	genAssign
;	(operands are equal 3)
;	genIpush
; _saveRegsForCall: sendSetSize: 0 deInUse: 0 bcInUse: 0 deSending: 0
;	AOP_STK for 
	lda	hl,8(sp)
	ld	a,(hl)
	push	af
	inc	sp
;	genIpush
;	AOP_STK for 
	dec	hl
	dec	hl
	ld	a,(hl+)
	ld	h,(hl)
	ld	l,a
	push	hl
;	genIpush
;	AOP_STK for 
	lda	hl,7(sp)
	ld	a,(hl+)
	ld	h,(hl)
	ld	l,a
	push	hl
	lda	hl,7(sp)
	ld	a,(hl+)
	ld	h,(hl)
	ld	l,a
	push	hl
;	genCall
	call	__ultoa
	lda	sp,7(sp)
;	genLabel
00104$:
;	genEndFunction
	
	ret
__ltoa_end::
	.area _CODE
