;--------------------------------------------------------
; File Created by SDCC : FreeWare ANSI-C Compiler
; Version 2.4.0 Tue Oct 12 01:19:50 2004

;--------------------------------------------------------
	.module malloc
	.optsdcc -mds390 --model-flat24
	
.flat24 on		; 24 bit flat addressing
dpx = 0x93		; dpx register unknown to assembler
dps = 0x86		; dps register unknown to assembler
dpl1 = 0x84		; dpl1 register unknown to assembler
dph1 = 0x85		; dph1 register unknown to assembler
dpx1 = 0x95		; dpx1 register unknown to assembler
ap = 0x9C		; ap register unknown to assembler
_ap = 0x9C		; _ap register unknown to assembler
mcnt0 = 0xD1		; mcnt0 register unknown to assembler
mcnt1 = 0xD2		; mcnt1 register unknown to assembler
ma = 0xD3		; ma register unknown to assembler
mb = 0xD4		; mb register unknown to assembler
mc = 0xD5		; mc register unknown to assembler
F1 = 0xD1		; F1 user flag unknown to assembler
esp = 0x9B		; ESP user flag unknown to assembler
;--------------------------------------------------------
; Public variables in this module
;--------------------------------------------------------
	.globl _init_dynamic_memory_PARM_2
	.globl _init_dynamic_memory
	.globl _malloc
	.globl _free
;--------------------------------------------------------
; special function registers
;--------------------------------------------------------
;--------------------------------------------------------
; special function bits 
;--------------------------------------------------------
;--------------------------------------------------------
; overlayable register banks 
;--------------------------------------------------------
	.area REG_BANK_0	(REL,OVR,DATA)
	.ds 8
;--------------------------------------------------------
; internal ram data
;--------------------------------------------------------
	.area DSEG    (DATA)
;--------------------------------------------------------
; overlayable items in internal ram 
;--------------------------------------------------------
	.area OSEG    (OVR,DATA)
;--------------------------------------------------------
; indirectly addressable internal ram data
;--------------------------------------------------------
	.area ISEG    (DATA)
;--------------------------------------------------------
; bit data
;--------------------------------------------------------
	.area BSEG    (BIT)
;--------------------------------------------------------
; external ram data
;--------------------------------------------------------
	.area XSEG    (XDATA)
_FIRST_MEMORY_HEADER_PTR:
	.ds 3
_init_dynamic_memory_PARM_2::
	.ds 2
_malloc_size_1_1::
	.ds 2
_malloc_current_header_1_1::
	.ds 3
_malloc_new_header_1_1::
	.ds 3
_free_prev_header_1_1::
	.ds 3
;--------------------------------------------------------
; external initialized ram data
;--------------------------------------------------------
	.area XISEG   (XDATA)
;--------------------------------------------------------
; global & static initialisations
;--------------------------------------------------------
	.area GSINIT  (CODE)
	.area GSFINAL (CODE)
	.area GSINIT  (CODE)
;--------------------------------------------------------
; Home
;--------------------------------------------------------
	.area HOME    (CODE)
	.area CSEG    (CODE)
;--------------------------------------------------------
; code
;--------------------------------------------------------
	.area CSEG    (CODE)
;------------------------------------------------------------
;Allocation info for local variables in function 'init_dynamic_memory'
;------------------------------------------------------------
;size                      Allocated with name '_init_dynamic_memory_PARM_2'
;array                     Allocated to registers r2 r3 r4 
;------------------------------------------------------------
;	malloc.c:145: void init_dynamic_memory(MEMHEADER xdata * array, unsigned int size) 
;	genFunction 
;	-----------------------------------------
;	 function init_dynamic_memory
;	-----------------------------------------
_init_dynamic_memory:
	ar2 = 0x02
	ar3 = 0x03
	ar4 = 0x04
	ar5 = 0x05
	ar6 = 0x06
	ar7 = 0x07
	ar0 = 0x00
	ar1 = 0x01
;	genReceive 
	mov	dpl1,dpl
	mov	dph1,dph
	mov	dpx1,dpx
;	malloc.c:167: if ( !array ) /*Reserved memory starts on 0x0000 but it's NULL...*/
;	genIfx 
	mov	a,dpl1
	orl	a,dph1
	orl	a,dpx1
;	genIfxJump
; Peephole 109   removed ljmp by inverse jump logic
	jnz  00102$
00106$:
;	malloc.c:169: array = (MEMHEADER xdata * )((char xdata * ) array + 1) ;
;	genPlus 
	mov	dps,#0x01
	inc	dptr
	mov	dps,#0
;	did genPlusIncr
;	malloc.c:170: size --;
;	genAssign 
	mov	dptr,#_init_dynamic_memory_PARM_2
;	genAssign: resultIsFar = FALSE
	movx	a,@dptr
	mov	r5,a
	inc	dptr
	movx	a,@dptr
	mov	r6,a
;	genMinus 
	dec	r5
	cjne	r5,#0xFF,00107$
	dec	r6
00107$:
;	genAssign 
;	genAssign: resultIsFar = TRUE
	mov	dptr,#_init_dynamic_memory_PARM_2
	mov	a,r5
	movx	@dptr,a
	inc	dptr
	mov	a,r6
	movx	@dptr,a
;	genLabel 
00102$:
;	malloc.c:172: FIRST_MEMORY_HEADER_PTR = array;
;	genAssign 
;	genAssign: resultIsFar = TRUE
	mov	dptr,#_FIRST_MEMORY_HEADER_PTR
	mov	a,dpl1
	movx	@dptr,a
	inc	dptr
	mov	a,dph1
	movx	@dptr,a
	inc	dptr
	mov	a,dpx1
	movx	@dptr,a
;	malloc.c:174: array->next = (MEMHEADER xdata * )(((char xdata * ) array) + size - HEADER_SIZE);
;	genPlus 
	mov	dptr,#_init_dynamic_memory_PARM_2
	movx	a,@dptr
	add	a,dpl1
	mov	r5,a
	inc	dptr
	movx	a,@dptr
	addc	a,dph1
	mov	r6,a
; Peephole 3.d   changed mov to clr
	clr	a
	addc	a,dpx1
	mov	r7,a
;	genMinus 
	mov	a,r5
	add	a,#0xF8
	mov	r5,a
	mov	a,r6
	addc	a,#0xFF
	mov	r6,a
	mov	a,r7
	addc	a,#0xFF
	mov	r7,a
;	genPointerSet 
	mov	a,r5
	inc	dps
	movx	@dptr,a
	inc	dptr
	mov	a,r6
	movx	@dptr,a
	inc	dptr
	mov	a,r7
	movx	@dptr,a
; Peephole 220a removed bogus DPS set
	mov     dps, #1
	lcall	__decdptr
	lcall	__decdptr
	mov	dps,#0
;	malloc.c:175: array->next->next = (void xdata * ) NULL; //And mark it as last
;	genCast 
	mov	dpl,r5
	mov	dph,r6
	mov	dpx,r7
;	genPointerSet 
; Peephole 101   removed redundant mov
; Peephole 180   changed mov to clr
	clr  a
	movx @dptr,a
	inc  dptr
	movx @dptr,a
	inc	dptr
; Peephole 101   removed redundant mov
; Peephole 180   changed mov to clr
	clr  a
	movx @dptr,a
	inc  dptr
	movx @dptr,a
;	malloc.c:176: array->prev       = (void xdata * ) NULL; //and mark first as first
;	genPlus 
	mov	dpx,dpx1
	mov	dph,dph1
	mov	dpl,dpl1
	inc	dptr
	inc	dptr
	inc	dptr
;	did genPlusIncr
;	genPointerSet 
; Peephole 101   removed redundant mov
; Peephole 180   changed mov to clr
	clr  a
	movx @dptr,a
	inc  dptr
	movx @dptr,a
	inc	dptr
; Peephole 101   removed redundant mov
; Peephole 180   changed mov to clr
	clr  a
	movx @dptr,a
	inc  dptr
	movx @dptr,a
;	malloc.c:177: array->len        = 0;    //Empty and ready.
;	genPlus 
	mov	a,#0x06
	add	a,dpl1
	mov	dpl,a
; Peephole 180   changed mov to clr
	clr  a
	addc	a,dph1
	mov	dph,a
; Peephole 180   changed mov to clr
	clr  a
	addc	a,dpx1
	mov	dpx,a
;	genPointerSet 
; Peephole 101   removed redundant mov
; Peephole 180   changed mov to clr
	clr  a
	movx @dptr,a
	inc  dptr
	movx @dptr,a
;	genLabel 
00103$:
;	genEndFunction 
	ret
;------------------------------------------------------------
;Allocation info for local variables in function 'malloc'
;------------------------------------------------------------
;size                      Allocated with name '_malloc_size_1_1'
;current_header            Allocated with name '_malloc_current_header_1_1'
;new_header                Allocated with name '_malloc_new_header_1_1'
;sloc0                     Allocated with name '_malloc_sloc0_1_0'
;sloc1                     Allocated with name '_malloc_sloc1_1_0'
;------------------------------------------------------------
;	malloc.c:180: void  xdata * malloc (unsigned int size)
;	genFunction 
;	-----------------------------------------
;	 function malloc
;	-----------------------------------------
_malloc:
;	genReceive 
	mov     dps, #1
	mov     dptr, #_malloc_size_1_1
	mov	a,dpl
	movx	@dptr,a
	inc	dptr
	mov	a,dph
	movx	@dptr,a
	mov	dps,#0
;	malloc.c:185: if (size>(0xFFFF-HEADER_SIZE)) return (void xdata *) NULL; //To prevent overflow in next line
;	genCmpGt 
	mov	dptr,#_malloc_size_1_1
;	genCmp
	clr	c
	mov	a,#0xF7
	xch	a, b
	movx	a,@dptr
	xch	a, b
	subb	a,b
	mov	a,#0xFF
	xch	a, b
	inc	dptr
	movx	a,@dptr
	xch	a, b
	subb	a,b
;	genIfxJump
; Peephole 108   removed ljmp by inverse jump logic
	jnc  00102$
00122$:
;	genRet 
; Peephole 181a   used 24 bit load of dptr
	mov  dptr,#0x0000
	mov	b,#0x00
	ljmp	00114$
;	genLabel 
00102$:
;	malloc.c:186: size += HEADER_SIZE; //We need a memory for header too
;	genPlus 
	mov	dptr,#_malloc_size_1_1
;	Swapped plus args.
	movx	a,@dptr
	add	a,#0x08
	movx	@dptr,a
	inc	dptr
	movx	a,@dptr
	addc	a,#0x00
	movx	@dptr,a
;	malloc.c:187: current_header = FIRST_MEMORY_HEADER_PTR;
;	genAssign 
	mov	dptr,#_FIRST_MEMORY_HEADER_PTR
;	genAssign: resultIsFar = FALSE
	movx	a,@dptr
	mov	r4,a
	inc	dptr
	movx	a,@dptr
	mov	r5,a
	inc	dptr
	movx	a,@dptr
	mov	r6,a
;	genAssign 
;	genAssign: resultIsFar = TRUE
	mov	dptr,#_malloc_current_header_1_1
	mov	a,r4
	movx	@dptr,a
	inc	dptr
	mov	a,r5
	movx	@dptr,a
	inc	dptr
	mov	a,r6
	movx	@dptr,a
;	malloc.c:188: while (1)
;	genLabel 
00108$:
;	malloc.c:198: if ((((unsigned int)current_header->next) -
;	genPointerGet 
;	genFarPointerGet
	mov	dptr,#_malloc_current_header_1_1
;	genFarPointerGet -- indirection special case.
	movx	a,@dptr
	push	acc
	inc	dptr
	movx	a,@dptr
	push	acc
	inc	dptr
	movx	a,@dptr
	mov	dpx,a
	pop	dph
	pop	dpl
	movx	a,@dptr
	inc	dptr
	mov	r7,a
	movx	a,@dptr
	inc	dptr
	mov	r0,a
	movx	a,@dptr
	mov	r1,a
;	genCast 
	mov	ar2,r7
	mov	ar3,r0
;	malloc.c:199: ((unsigned int)current_header) -
;	genAssign 
	mov	dptr,#_malloc_current_header_1_1
;	genAssign: resultIsFar = FALSE
	movx	a,@dptr
	mov	r4,a
	inc	dptr
	movx	a,@dptr
	mov	r5,a
	inc	dptr
	movx	a,@dptr
	mov	r6,a
;	genCast 
;	genMinus 
	clr	c
	mov	a,r2
	subb	a,r4
	mov	r2,a
	mov	a,r3
	subb	a,r5
	mov	r3,a
;	malloc.c:200: current_header->len) >= size) break; //if spare is more than need
;	genPlus 
	mov	dptr,#_malloc_current_header_1_1
;	Swapped plus args.
	movx	a,@dptr
	add	a,#0x06
	mov	dpl1,a
	inc	dptr
	movx	a,@dptr
	addc	a,#0x00
	mov	dph1,a
	inc	dptr
	movx	a,@dptr
	addc	a,#0x00
	mov	dpx1,a
;	genPointerGet 
;	genFarPointerGet
	inc	dps
	movx	a,@dptr
	inc	dptr
	mov	r4,a
	movx	a,@dptr
	mov	r5,a
; Peephole 220a removed bogus DPS set
	mov     dps, #1
	lcall	__decdptr
	mov	dps,#0
;	genMinus 
	clr	c
	mov	a,r2
	subb	a,r4
	mov	r2,a
	mov	a,r3
	subb	a,r5
	mov	r3,a
;	genCmpLt 
	mov	dptr,#_malloc_size_1_1
;	genCmp
	clr	c
	mov	a,r2
	xch	a, b
	movx	a,@dptr
	xch	a, b
	subb	a,b
	mov	a,r3
	xch	a, b
	inc	dptr
	movx	a,@dptr
	xch	a, b
	subb	a,b
;	genIfxJump
; Peephole 108   removed ljmp by inverse jump logic
	jnc  00109$
00123$:
;	malloc.c:201: current_header = current_header->next;    //else try next             
;	genAssign 
;	genAssign: resultIsFar = TRUE
	mov	dptr,#_malloc_current_header_1_1
	mov	a,r7
	movx	@dptr,a
	inc	dptr
	mov	a,r0
	movx	@dptr,a
	inc	dptr
	mov	a,r1
	movx	@dptr,a
;	malloc.c:202: if (!current_header->next)  return (void xdata *) NULL;  //if end_of_list reached
;	genPointerGet 
;	genFarPointerGet
	mov	dptr,#_malloc_current_header_1_1
;	genFarPointerGet -- indirection special case.
	movx	a,@dptr
	push	acc
	inc	dptr
	movx	a,@dptr
	push	acc
	inc	dptr
	movx	a,@dptr
	mov	dpx,a
	pop	dph
	pop	dpl
	movx	a,@dptr
	inc	dptr
	mov	r2,a
	movx	a,@dptr
	inc	dptr
	mov	r3,a
	movx	a,@dptr
	mov	r4,a
;	genIfx 
	mov	a,r2
	orl	a,r3
	orl	a,r4
;	genIfxJump
	jz	00124$
	ljmp	00108$
00124$:
;	genRet 
; Peephole 181a   used 24 bit load of dptr
	mov  dptr,#0x0000
	mov	b,#0x00
	ljmp	00114$
;	genLabel 
00109$:
;	malloc.c:204: if (!current_header->len)
;	genIfx 
	mov	a,r4
	orl	a,r5
;	genIfxJump
; Peephole 109   removed ljmp by inverse jump logic
	jnz  00111$
00125$:
;	malloc.c:206: current_header->len = size; //for first allocation
;	genPointerSet 
	mov	dptr,#_malloc_size_1_1
	movx	a,@dptr
	mov	dps,#1
	movx	@dptr,a
	inc	dptr
	mov	dps,#0
	inc	dptr
	movx	a,@dptr
	mov	dps,#1
	movx	@dptr,a
	mov	dps,#0
;	malloc.c:207: return ((xdata *)&(current_header->mem));
;	genPlus 
	mov	dptr,#_malloc_current_header_1_1
;	Swapped plus args.
	movx	a,@dptr
	add	a,#0x08
	mov	dpl1,a
	inc	dptr
	movx	a,@dptr
	addc	a,#0x00
	mov	dph1,a
	inc	dptr
	movx	a,@dptr
	addc	a,#0x00
	mov	dpx1,a
;	genRet 
	mov	dpl,dpl1
	mov	dph,dph1
	mov	dpx,dpx1
	ljmp	00114$
;	genLabel 
00111$:
;	malloc.c:209: new_header = (MEMHEADER xdata * )((char xdata *)current_header + current_header->len);
;	genPlus 
	mov	dptr,#_malloc_current_header_1_1
	mov	dps, #1
	mov	dptr, #_malloc_new_header_1_1
	dec	dps
;	Swapped plus args.
	movx	a,@dptr
	add	a,r4
	inc	dps
	movx	@dptr,a
	dec	dps
	inc	dptr
	movx	a,@dptr
	addc	a,r5
	inc	dps
	inc	dptr
	movx	@dptr,a
	dec	dps
	inc	dptr
	movx	a,@dptr
	addc	a,#0
	inc	dps
	inc	dptr
	movx	@dptr,a
	mov	dps,#0
;	malloc.c:210: new_header->next = current_header->next; //and plug it into the chain
;	genPointerSet 
	mov	dptr,#_malloc_new_header_1_1
;	genFarPointerSet -- indirection special case.
	movx	a,@dptr
	push	acc
	inc	dptr
	movx	a,@dptr
	push	acc
	inc	dptr
	movx	a,@dptr
	mov	dpx,a
	pop	dph
	pop	dpl
	mov	a,r7
	movx	@dptr,a
	inc	dptr
	mov	a,r0
	movx	@dptr,a
	inc	dptr
	mov	a,r1
	movx	@dptr,a
;	malloc.c:211: new_header->prev = current_header;
;	genPlus 
	mov	dptr,#_malloc_new_header_1_1
;	Swapped plus args.
	movx	a,@dptr
	add	a,#0x03
	mov	dpl1,a
	inc	dptr
	movx	a,@dptr
	addc	a,#0x00
	mov	dph1,a
	inc	dptr
	movx	a,@dptr
	addc	a,#0x00
	mov	dpx1,a
;	genPointerSet 
	mov	dptr,#_malloc_current_header_1_1
	movx	a,@dptr
	mov	dps,#1
	movx	@dptr,a
	inc	dptr
	mov	dps,#0
	inc	dptr
	movx	a,@dptr
	mov	dps,#1
	movx	@dptr,a
	inc	dptr
	mov	dps,#0
	inc	dptr
	movx	a,@dptr
	mov	dps,#1
	movx	@dptr,a
	mov	dps,#0
;	malloc.c:212: current_header->next  = new_header;
;	genPointerSet 
	mov	dptr,#_malloc_current_header_1_1
;	genFarPointerSet -- indirection special case.
	movx	a,@dptr
	push	acc
	inc	dptr
	movx	a,@dptr
	push	acc
	inc	dptr
	movx	a,@dptr
	mov	dpx,a
	pop	dph
	pop	dpl
	mov     dps, #1
	mov     dptr, #_malloc_new_header_1_1
	movx	a,@dptr
	dec	dps
	movx	@dptr,a
	inc	dptr
	inc	dps
	inc	dptr
	movx	a,@dptr
	dec	dps
	movx	@dptr,a
	inc	dptr
	inc	dps
	inc	dptr
	movx	a,@dptr
	dec	dps
	movx	@dptr,a
;	malloc.c:213: if (new_header->next)  new_header->next->prev = new_header;
;	genIfx 
	mov	a,r7
	orl	a,r0
	orl	a,r1
;	genIfxJump
	jnz	00126$
	ljmp	00113$
00126$:
;	genPointerGet 
;	genFarPointerGet
	mov	dptr,#_malloc_new_header_1_1
;	genFarPointerGet -- indirection special case.
	movx	a,@dptr
	push	acc
	inc	dptr
	movx	a,@dptr
	push	acc
	inc	dptr
	movx	a,@dptr
	mov	dpx,a
	pop	dph
	pop	dpl
	movx	a,@dptr
	inc	dptr
	mov	r2,a
	movx	a,@dptr
	inc	dptr
	mov	r3,a
	movx	a,@dptr
	mov	r4,a
;	genPlus 
	mov	a,#0x03
	add	a,r2
	mov	dpl1,a
; Peephole 180   changed mov to clr
	clr  a
	addc	a,r3
	mov	dph1,a
; Peephole 180   changed mov to clr
	clr  a
	addc	a,r4
	mov	dpx1,a
;	genPointerSet 
	mov	dptr,#_malloc_new_header_1_1
	movx	a,@dptr
	mov	dps,#1
	movx	@dptr,a
	inc	dptr
	mov	dps,#0
	inc	dptr
	movx	a,@dptr
	mov	dps,#1
	movx	@dptr,a
	inc	dptr
	mov	dps,#0
	inc	dptr
	movx	a,@dptr
	mov	dps,#1
	movx	@dptr,a
	mov	dps,#0
;	genLabel 
00113$:
;	malloc.c:214: new_header->len  = size; //mark as used
;	genPlus 
	mov	dptr,#_malloc_new_header_1_1
;	Swapped plus args.
	movx	a,@dptr
	add	a,#0x06
	mov	dpl1,a
	inc	dptr
	movx	a,@dptr
	addc	a,#0x00
	mov	dph1,a
	inc	dptr
	movx	a,@dptr
	addc	a,#0x00
	mov	dpx1,a
;	genPointerSet 
	mov	dptr,#_malloc_size_1_1
	movx	a,@dptr
	mov	dps,#1
	movx	@dptr,a
	inc	dptr
	mov	dps,#0
	inc	dptr
	movx	a,@dptr
	mov	dps,#1
	movx	@dptr,a
	mov	dps,#0
;	malloc.c:215: return ((xdata *)&(new_header->mem));
;	genPlus 
	mov	dptr,#_malloc_new_header_1_1
;	Swapped plus args.
	movx	a,@dptr
	add	a,#0x08
	mov	dpl1,a
	inc	dptr
	movx	a,@dptr
	addc	a,#0x00
	mov	dph1,a
	inc	dptr
	movx	a,@dptr
	addc	a,#0x00
	mov	dpx1,a
;	genRet 
	mov	dpl,dpl1
	mov	dph,dph1
	mov	dpx,dpx1
;	genLabel 
00114$:
;	genEndFunction 
	ret
;------------------------------------------------------------
;Allocation info for local variables in function 'free'
;------------------------------------------------------------
;p                         Allocated to registers r2 r3 r4 
;prev_header               Allocated with name '_free_prev_header_1_1'
;------------------------------------------------------------
;	malloc.c:218: void free (void xdata * p)
;	genFunction 
;	-----------------------------------------
;	 function free
;	-----------------------------------------
_free:
;	genReceive 
	mov	r2,dpl
	mov	r3,dph
	mov	r4,dpx
;	malloc.c:221: if ( p ) //For allocated pointers only!
;	genIfx 
	mov	a,r2
	orl	a,r3
	orl	a,r4
;	genIfxJump
	jnz	00113$
	ljmp	00108$
00113$:
;	malloc.c:223: p = (MEMHEADER xdata * )((char xdata *)  p - HEADER_SIZE); //to start of header
;	genMinus 
	mov	a,r2
	add	a,#0xF8
	mov	r5,a
	mov	a,r3
	addc	a,#0xFF
	mov	r6,a
	mov	a,r4
	addc	a,#0xFF
	mov	r7,a
;	genAssign 
;	genAssign: resultIsFar = TRUE
	mov	ar2,r5
	mov	ar3,r6
	mov	ar4,r7
;	malloc.c:224: if ( ((MEMHEADER xdata * ) p)->prev ) // For the regular header
;	genPlus 
	mov	dpx,r4
	mov	dph,r3
	mov	dpl,r2
	inc	dptr
	inc	dptr
	inc	dptr
;	did genPlusIncr
;	genPointerGet 
;	genFarPointerGet
	movx	a,@dptr
	inc	dptr
	mov	r5,a
	movx	a,@dptr
	inc	dptr
	mov	r6,a
	movx	a,@dptr
	mov	r7,a
;	genIfx 
	mov	a,r5
	orl	a,r6
	orl	a,r7
;	genIfxJump
	jnz	00114$
	ljmp	00104$
00114$:
;	malloc.c:226: prev_header = ((MEMHEADER xdata * ) p)->prev;
;	genAssign 
;	genAssign: resultIsFar = TRUE
	mov	dptr,#_free_prev_header_1_1
	mov	a,r5
	movx	@dptr,a
	inc	dptr
	mov	a,r6
	movx	@dptr,a
	inc	dptr
	mov	a,r7
	movx	@dptr,a
;	malloc.c:227: prev_header->next = ((MEMHEADER xdata * ) p)->next;
;	genPointerGet 
;	genFarPointerGet
	mov	dpl,r2
	mov	dph,r3
	mov	dpx,r4
	movx	a,@dptr
	inc	dptr
	mov	r0,a
	movx	a,@dptr
	inc	dptr
	mov	r1,a
	movx	a,@dptr
	mov	r5,a
;	genPointerSet 
	mov	dptr,#_free_prev_header_1_1
;	genFarPointerSet -- indirection special case.
	movx	a,@dptr
	push	acc
	inc	dptr
	movx	a,@dptr
	push	acc
	inc	dptr
	movx	a,@dptr
	mov	dpx,a
	pop	dph
	pop	dpl
	mov	a,r0
	movx	@dptr,a
	inc	dptr
	mov	a,r1
	movx	@dptr,a
	inc	dptr
	mov	a,r5
	movx	@dptr,a
;	malloc.c:228: if (((MEMHEADER xdata * ) p)->next)
;	genIfx 
	mov	a,r0
	orl	a,r1
	orl	a,r5
;	genIfxJump
; Peephole 110   removed ljmp by inverse jump logic
	jz  00108$
00115$:
;	malloc.c:229: ((MEMHEADER xdata * ) p)->next->prev = prev_header;
;	genPlus 
	mov	a,#0x03
	add	a,r0
	mov	dpl1,a
; Peephole 180   changed mov to clr
	clr  a
	addc	a,r1
	mov	dph1,a
; Peephole 180   changed mov to clr
	clr  a
	addc	a,r5
	mov	dpx1,a
;	genPointerSet 
	mov	dptr,#_free_prev_header_1_1
	movx	a,@dptr
	mov	dps,#1
	movx	@dptr,a
	inc	dptr
	mov	dps,#0
	inc	dptr
	movx	a,@dptr
	mov	dps,#1
	movx	@dptr,a
	inc	dptr
	mov	dps,#0
	inc	dptr
	movx	a,@dptr
	mov	dps,#1
	movx	@dptr,a
	mov	dps,#0
;	genGoto 
;	genLabel 
; Peephole 132   changed ljmp to sjmp
	sjmp 00108$
00104$:
;	malloc.c:231: else ((MEMHEADER xdata * ) p)->len = 0; //For the first header
;	genPlus 
	mov	a,#0x06
	add	a,r2
	mov	dpl,a
; Peephole 180   changed mov to clr
	clr  a
	addc	a,r3
	mov	dph,a
; Peephole 180   changed mov to clr
	clr  a
	addc	a,r4
	mov	dpx,a
;	genPointerSet 
; Peephole 101   removed redundant mov
; Peephole 180   changed mov to clr
	clr  a
	movx @dptr,a
	inc  dptr
	movx @dptr,a
;	genLabel 
00108$:
;	genEndFunction 
	ret
	.area CSEG    (CODE)
	.area XINIT   (CODE)
