;
; File generated by cc65 v 2.13.1
;
	.fopt		compiler,"cc65 v 2.13.1"
	.setcpu		"6502"
	.smart		on
	.autoimport	on
	.case		on
	.debuginfo	on
	.importzp	sp, sreg, regsave, regbank, tmp1, ptr1, ptr2
	.macpack	longbranch
	.dbg		file, "../../../data/src/data_tools.c", 6244, 1267200498
	.dbg		file, "../inc/manifest.h", 151, 1267200480
	.dbg		file, "../../../data/inc/data_tools.h", 1380, 1267200498
	.dbg		file, "../../../data/inc/types.h", 1544, 1267200498
	.export		_data_atol
	.export		_data_ltoa
	.export		_data_strnlen
	.export		_data_strncpy
	.export		_data_strnicpy

; ---------------------------------------------------------------
; unsigned long __near__ data_atol (__near__ signed char*)
; ---------------------------------------------------------------

.segment	"CODE"

.proc	_data_atol: near

.segment	"CODE"

;
; ULONG i = 0L;
;
	.dbg	line, "../../../data/src/data_tools.c", 77
	ldx     #$00
	txa
	jsr     push0ax
;
; BYTE b = 0;
;
	.dbg	line, "../../../data/src/data_tools.c", 78
	jsr     pusha
;
; while(p[b] != 0) { 
;
	.dbg	line, "../../../data/src/data_tools.c", 81
L0005:	ldy     #$06
	lda     (sp),y
	tax
	dey
	lda     (sp),y
	sta     ptr1
	stx     ptr1+1
	ldy     #$00
	lda     (sp),y
	tay
	lda     (ptr1),y
	jeq     L0006
;
; i <<= 4;
;
	.dbg	line, "../../../data/src/data_tools.c", 82
	ldy     #$04
	jsr     ldeaxysp
	jsr     shleax4
	ldy     #$01
	jsr     steaxysp
;
; if((p[b] >= '0')&&(p[b] <= '9'))      i |= (p[b] & 0x0F);
;
	.dbg	line, "../../../data/src/data_tools.c", 83
	ldy     #$06
	lda     (sp),y
	tax
	dey
	lda     (sp),y
	sta     ptr1
	stx     ptr1+1
	ldy     #$00
	lda     (sp),y
	tay
	lda     (ptr1),y
	sec
	sbc     #$30
	bvs     L000F
	eor     #$80
L000F:	bpl     L000B
	ldy     #$06
	lda     (sp),y
	tax
	dey
	lda     (sp),y
	sta     ptr1
	stx     ptr1+1
	ldy     #$00
	lda     (sp),y
	tay
	lda     (ptr1),y
	sec
	sbc     #$3A
	bvc     L0013
	eor     #$80
L0013:	bpl     L000B
	ldy     #$04
	jsr     ldeaxysp
	jsr     pusheax
	ldy     #$0A
	lda     (sp),y
	tax
	dey
	lda     (sp),y
	sta     ptr1
	stx     ptr1+1
	ldx     #$00
	ldy     #$04
	lda     (sp),y
	tay
	lda     (ptr1),y
	and     #$0F
;
; else if((p[b] >= 'A')&&(p[b] <= 'F')) i |= (p[b] - 55);
;
	.dbg	line, "../../../data/src/data_tools.c", 84
	jmp     L0038
L000B:	ldy     #$06
	lda     (sp),y
	tax
	dey
	lda     (sp),y
	sta     ptr1
	stx     ptr1+1
	ldy     #$00
	lda     (sp),y
	tay
	lda     (ptr1),y
	sec
	sbc     #$41
	bvs     L001E
	eor     #$80
L001E:	bpl     L001A
	ldy     #$06
	lda     (sp),y
	tax
	dey
	lda     (sp),y
	sta     ptr1
	stx     ptr1+1
	ldy     #$00
	lda     (sp),y
	tay
	lda     (ptr1),y
	sec
	sbc     #$47
	bvc     L0022
	eor     #$80
L0022:	bpl     L001A
	ldy     #$04
	jsr     ldeaxysp
	jsr     pusheax
	ldy     #$0A
	lda     (sp),y
	tax
	dey
	lda     (sp),y
	sta     ptr1
	stx     ptr1+1
	ldx     #$00
	ldy     #$04
	lda     (sp),y
	tay
	lda     (ptr1),y
	bpl     L00AC
	dex
L00AC:	sec
	sbc     #$37
;
; else if((p[b] >= 'a')&&(p[b] <= 'f')) i |= (p[b] - 87);
;
	.dbg	line, "../../../data/src/data_tools.c", 85
	jmp     L00B4
L001A:	ldy     #$06
	lda     (sp),y
	tax
	dey
	lda     (sp),y
	sta     ptr1
	stx     ptr1+1
	ldy     #$00
	lda     (sp),y
	tay
	lda     (ptr1),y
	sec
	sbc     #$61
	bvs     L002E
	eor     #$80
L002E:	bpl     L0006
	ldy     #$06
	lda     (sp),y
	tax
	dey
	lda     (sp),y
	sta     ptr1
	stx     ptr1+1
	ldy     #$00
	lda     (sp),y
	tay
	lda     (ptr1),y
	sec
	sbc     #$67
	bvc     L0032
	eor     #$80
L0032:	bpl     L0006
	ldy     #$04
	jsr     ldeaxysp
	jsr     pusheax
	ldy     #$0A
	lda     (sp),y
	tax
	dey
	lda     (sp),y
	sta     ptr1
	stx     ptr1+1
	ldx     #$00
	ldy     #$04
	lda     (sp),y
	tay
	lda     (ptr1),y
	bpl     L00AF
	dex
L00AF:	sec
	sbc     #$57
L00B4:	bcs     L0038
	dex
L0038:	jsr     axlong
	jsr     tosoreax
	ldy     #$01
	jsr     steaxysp
;
; b++;
;
	.dbg	line, "../../../data/src/data_tools.c", 87
	ldy     #$00
	lda     (sp),y
	clc
	adc     #$01
	sta     (sp),y
;
; }
;
	.dbg	line, "../../../data/src/data_tools.c", 88
	jmp     L0005
;
; return i;
;
	.dbg	line, "../../../data/src/data_tools.c", 91
L0006:	ldy     #$04
	jsr     ldeaxysp
;
; }
;
	.dbg	line, "../../../data/src/data_tools.c", 92
	jmp     incsp7
	.dbg	line

.endproc

; ---------------------------------------------------------------
; __near__ signed char* __near__ data_ltoa (__near__ signed char*, unsigned long, unsigned int)
; ---------------------------------------------------------------

.segment	"CODE"

.proc	_data_ltoa: near

.segment	"CODE"

;
; q = p + MAXDIG;
;
	.dbg	line, "../../../data/src/data_tools.c", 241
	jsr     decsp6
	ldy     #$0D
	lda     (sp),y
	tax
	dey
	lda     (sp),y
	clc
	adc     #$80
	bcc     L0084
	inx
L0084:	jsr     stax0sp
;
; j = (ULONG) (i % radix);
;
	.dbg	line, "../../../data/src/data_tools.c", 243
L0085:	ldy     #$0B
	jsr     ldeaxysp
	jsr     pusheax
	ldy     #$0B
	lda     (sp),y
	tax
	dey
	lda     (sp),y
	jsr     tosumod0ax
	ldy     #$02
	jsr     steaxysp
;
; j += '0';
;
	.dbg	line, "../../../data/src/data_tools.c", 244
	ldx     #$00
	stx     sreg
	stx     sreg+1
	lda     #$30
	ldy     #$02
	jsr     laddeqysp
;
; if (j > '9') {
;
	.dbg	line, "../../../data/src/data_tools.c", 245
	ldy     #$05
	jsr     ldeaxysp
	cmp     #$3A
	txa
	sbc     #$00
	lda     sreg
	sbc     #$00
	lda     sreg+1
	sbc     #$00
	bcc     L008D
;
; j += 'A' - '0' - 10;
;
	.dbg	line, "../../../data/src/data_tools.c", 246
	ldx     #$00
	stx     sreg
	stx     sreg+1
	lda     #$07
	ldy     #$02
	jsr     laddeqysp
;
; *--q = (CHAR) j;
;
	.dbg	line, "../../../data/src/data_tools.c", 249
L008D:	ldx     #$00
	lda     #$01
	jsr     subeq0sp
	sta     ptr1
	stx     ptr1+1
	ldy     #$02
	lda     (sp),y
	ldy     #$00
	sta     (ptr1),y
;
; i = i / radix;
;
	.dbg	line, "../../../data/src/data_tools.c", 250
	ldy     #$0B
	jsr     ldeaxysp
	jsr     pusheax
	ldy     #$0B
	lda     (sp),y
	tax
	dey
	lda     (sp),y
	jsr     tosudiv0ax
	ldy     #$08
	jsr     steaxysp
;
; } while(i);
;
	.dbg	line, "../../../data/src/data_tools.c", 251
	ldy     #$0B
	jsr     ldeaxysp
	jsr     utsteax
	bne     L0085
;
; j = p + MAXDIG - q;
;
	.dbg	line, "../../../data/src/data_tools.c", 253
	ldy     #$0D
	lda     (sp),y
	tax
	dey
	lda     (sp),y
	clc
	adc     #$80
	bcc     L0099
	inx
L0099:	jsr     pushax
	ldy     #$03
	lda     (sp),y
	tax
	dey
	lda     (sp),y
	jsr     tossubax
	jsr     axlong
	ldy     #$02
	jsr     steaxysp
;
; *p++ = *q++;
;
	.dbg	line, "../../../data/src/data_tools.c", 255
L009A:	ldy     #$0D
	lda     (sp),y
	tax
	dey
	lda     (sp),y
	sta     regsave
	stx     regsave+1
	clc
	adc     #$01
	bcc     L009E
	inx
L009E:	jsr     staxysp
	lda     regsave
	ldx     regsave+1
	jsr     pushax
	ldy     #$03
	lda     (sp),y
	tax
	dey
	lda     (sp),y
	sta     regsave
	stx     regsave+1
	clc
	adc     #$01
	bcc     L00A0
	inx
L00A0:	jsr     staxysp
	lda     regsave
	ldx     regsave+1
	ldy     #$00
	jsr     ldaidx
	jsr     staspidx
;
; } while (--j);
;
	.dbg	line, "../../../data/src/data_tools.c", 256
	ldx     #$00
	stx     sreg
	stx     sreg+1
	lda     #$01
	ldy     #$02
	jsr     lsubeqysp
	jsr     utsteax
	bne     L009A
;
; *p = 0; // NULL TERMINATE THE STRING
;
	.dbg	line, "../../../data/src/data_tools.c", 258
	ldy     #$0D
	lda     (sp),y
	tax
	dey
	lda     (sp),y
	sta     ptr1
	stx     ptr1+1
	lda     #$00
	tay
	sta     (ptr1),y
;
; return(p);
;
	.dbg	line, "../../../data/src/data_tools.c", 260
	ldy     #$0D
	lda     (sp),y
	tax
	dey
	lda     (sp),y
;
; }
;
	.dbg	line, "../../../data/src/data_tools.c", 261
	ldy     #$0E
	jmp     addysp
	.dbg	line

.endproc

; ---------------------------------------------------------------
; unsigned char __near__ data_strnlen (__near__ signed char*, unsigned char)
; ---------------------------------------------------------------

.segment	"CODE"

.proc	_data_strnlen: near

.segment	"CODE"

;
; BYTE b = 0;
;
	.dbg	line, "../../../data/src/data_tools.c", 113
	lda     #$00
	jsr     pusha
;
; while((p[b] != 0) && (b < max)) {
;
	.dbg	line, "../../../data/src/data_tools.c", 116
L003E:	ldy     #$03
	lda     (sp),y
	tax
	dey
	lda     (sp),y
	sta     ptr1
	stx     ptr1+1
	ldx     #$00
	lda     (sp,x)
	tay
	lda     (ptr1),y
	beq     L003F
	lda     (sp,x)
	ldy     #$01
	cmp     (sp),y
	bcs     L003F
;
; b++;
;
	.dbg	line, "../../../data/src/data_tools.c", 117
	dey
	lda     (sp),y
	clc
	adc     #$01
	sta     (sp),y
;
; }
;
	.dbg	line, "../../../data/src/data_tools.c", 118
	jmp     L003E
;
; return b;
;
	.dbg	line, "../../../data/src/data_tools.c", 120
L003F:	lda     (sp,x)
;
; }
;
	.dbg	line, "../../../data/src/data_tools.c", 121
	jmp     incsp4
	.dbg	line

.endproc

; ---------------------------------------------------------------
; unsigned char __near__ data_strncpy (__near__ signed char*, __near__ signed char*, unsigned char)
; ---------------------------------------------------------------

.segment	"CODE"

.proc	_data_strncpy: near

.segment	"CODE"

;
; BYTE b = 0;
;
	.dbg	line, "../../../data/src/data_tools.c", 143
	lda     #$00
	jsr     pusha
;
; while((p2[b] != 0) && (b < max)) {
;
	.dbg	line, "../../../data/src/data_tools.c", 146
L004A:	ldy     #$03
	lda     (sp),y
	tax
	dey
	lda     (sp),y
	sta     ptr1
	stx     ptr1+1
	ldx     #$00
	lda     (sp,x)
	tay
	lda     (ptr1),y
	beq     L004B
	lda     (sp,x)
	ldy     #$01
	cmp     (sp),y
	bcs     L004B
;
; p1[b] = p2[b];
;
	.dbg	line, "../../../data/src/data_tools.c", 147
	lda     (sp,x)
	clc
	ldy     #$04
	adc     (sp),y
	sta     sreg
	txa
	iny
	adc     (sp),y
	sta     sreg+1
	ldy     #$03
	lda     (sp),y
	tax
	dey
	lda     (sp),y
	sta     ptr1
	stx     ptr1+1
	ldx     #$00
	lda     (sp,x)
	tay
	lda     (ptr1),y
	ldy     #$00
	sta     (sreg),y
;
; b++;
;
	.dbg	line, "../../../data/src/data_tools.c", 148
	lda     (sp),y
	clc
	adc     #$01
	sta     (sp),y
;
; if(b<max) p1[b] = 0; // terminate when fit
;
	.dbg	line, "../../../data/src/data_tools.c", 149
	iny
	cmp     (sp),y
	bcs     L004A
	lda     (sp,x)
	clc
	ldy     #$04
	adc     (sp),y
	sta     ptr1
	txa
	iny
	adc     (sp),y
	sta     ptr1+1
	txa
	tay
	sta     (ptr1),y
;
; }
;
	.dbg	line, "../../../data/src/data_tools.c", 150
	jmp     L004A
;
; return b;
;
	.dbg	line, "../../../data/src/data_tools.c", 152
L004B:	lda     (sp,x)
;
; }
;
	.dbg	line, "../../../data/src/data_tools.c", 153
	jmp     incsp6
	.dbg	line

.endproc

; ---------------------------------------------------------------
; unsigned char __near__ data_strnicpy (__near__ signed char*, __near__ signed char*, unsigned char)
; ---------------------------------------------------------------

.segment	"CODE"

.proc	_data_strnicpy: near

.segment	"CODE"

;
; BYTE b = 0;
;
	.dbg	line, "../../../data/src/data_tools.c", 157
	lda     #$00
	jsr     pusha
;
; while((p2[b] != 0) && (b < max)) {
;
	.dbg	line, "../../../data/src/data_tools.c", 160
L005F:	ldy     #$03
	lda     (sp),y
	tax
	dey
	lda     (sp),y
	sta     ptr1
	stx     ptr1+1
	ldx     #$00
	lda     (sp,x)
	tay
	lda     (ptr1),y
	jeq     L0060
	lda     (sp,x)
	ldy     #$01
	cmp     (sp),y
	jcs     L0060
;
; if((p2[b]>='A')&&(p2[b]<='Z'))
;
	.dbg	line, "../../../data/src/data_tools.c", 161
	ldy     #$03
	lda     (sp),y
	tax
	dey
	lda     (sp),y
	sta     ptr1
	stx     ptr1+1
	ldx     #$00
	lda     (sp,x)
	tay
	lda     (ptr1),y
	sec
	sbc     #$41
	bvs     L006B
	eor     #$80
L006B:	bpl     L0067
	ldy     #$03
	lda     (sp),y
	tax
	dey
	lda     (sp),y
	sta     ptr1
	stx     ptr1+1
	ldx     #$00
	lda     (sp,x)
	tay
	lda     (ptr1),y
	sec
	sbc     #$5B
	bvc     L006F
	eor     #$80
L006F:	bpl     L0067
;
; p1[b] = p2[b] | 0x20;
;
	.dbg	line, "../../../data/src/data_tools.c", 162
	lda     (sp,x)
	clc
	ldy     #$04
	adc     (sp),y
	pha
	txa
	iny
	adc     (sp),y
	tax
	pla
	jsr     pushax
	ldy     #$05
	lda     (sp),y
	tax
	dey
	lda     (sp),y
	sta     ptr1
	stx     ptr1+1
	ldx     #$00
	ldy     #$02
	lda     (sp),y
	tay
	lda     (ptr1),y
	ora     #$20
;
; else
;
	.dbg	line, "../../../data/src/data_tools.c", 163
	jmp     L00BE
;
; p1[b] = p2[b];
;
	.dbg	line, "../../../data/src/data_tools.c", 164
L0067:	lda     (sp,x)
	clc
	ldy     #$04
	adc     (sp),y
	pha
	txa
	iny
	adc     (sp),y
	tax
	pla
	jsr     pushax
	ldy     #$05
	lda     (sp),y
	tax
	dey
	lda     (sp),y
	sta     ptr1
	stx     ptr1+1
	ldx     #$00
	ldy     #$02
	lda     (sp),y
	tay
	lda     (ptr1),y
L00BE:	ldy     #$00
	jsr     staspidx
;
; b++;
;
	.dbg	line, "../../../data/src/data_tools.c", 166
	ldy     #$00
	lda     (sp),y
	clc
	adc     #$01
	sta     (sp),y
;
; if(b<max) p1[b] = 0; // terminate when fit
;
	.dbg	line, "../../../data/src/data_tools.c", 167
	iny
	cmp     (sp),y
	jcs     L005F
	lda     (sp,x)
	clc
	ldy     #$04
	adc     (sp),y
	sta     ptr1
	txa
	iny
	adc     (sp),y
	sta     ptr1+1
	txa
	tay
	sta     (ptr1),y
;
; }
;
	.dbg	line, "../../../data/src/data_tools.c", 168
	jmp     L005F
;
; return b;
;
	.dbg	line, "../../../data/src/data_tools.c", 170
L0060:	lda     (sp,x)
;
; }
;
	.dbg	line, "../../../data/src/data_tools.c", 171
	jmp     incsp6
	.dbg	line

.endproc

