mirror of
https://github.com/cc65/cc65.git
synced 2024-10-01 15:54:59 +00:00
Use macpack for debugging, cosmetic changes
git-svn-id: svn://svn.cc65.org/cc65/trunk@171 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
0b7aae0f07
commit
bb4f3c4475
@ -64,11 +64,16 @@
|
|||||||
.import pushax, __hadd
|
.import pushax, __hadd
|
||||||
.export _free
|
.export _free
|
||||||
|
|
||||||
; Offsets into struct freeblock
|
.macpack generic
|
||||||
|
|
||||||
|
; Offsets into struct freeblock and other constant stuff
|
||||||
|
|
||||||
|
size = 0
|
||||||
|
next = 2
|
||||||
|
prev = 4
|
||||||
|
admin_space = 2
|
||||||
|
min_size = 6
|
||||||
|
|
||||||
size = 0
|
|
||||||
next = 2
|
|
||||||
prev = 4
|
|
||||||
|
|
||||||
; Code
|
; Code
|
||||||
|
|
||||||
@ -80,12 +85,12 @@ _free: sta ptr1
|
|||||||
ora ptr1+1 ; Is the argument NULL?
|
ora ptr1+1 ; Is the argument NULL?
|
||||||
beq @L9 ; Jump if yes
|
beq @L9 ; Jump if yes
|
||||||
|
|
||||||
; Decrement the given pointer by 2. The size of the block is stored there.
|
; Decrement the given pointer by the admin space amount, so it points to the
|
||||||
|
; real block allocated. The size of the block is stored in the admin space.
|
||||||
; Remember the block size in ptr2.
|
; Remember the block size in ptr2.
|
||||||
|
|
||||||
sec
|
|
||||||
lda ptr1
|
lda ptr1
|
||||||
sbc #2
|
sub #admin_space
|
||||||
sta ptr1
|
sta ptr1
|
||||||
bcs @L1
|
bcs @L1
|
||||||
dec ptr1+1
|
dec ptr1+1
|
||||||
@ -98,8 +103,7 @@ _free: sta ptr1
|
|||||||
|
|
||||||
; Check if the block is on top of the heap
|
; Check if the block is on top of the heap
|
||||||
|
|
||||||
clc
|
add ptr1
|
||||||
adc ptr1
|
|
||||||
tay
|
tay
|
||||||
lda ptr1+1
|
lda ptr1+1
|
||||||
adc ptr2+1
|
adc ptr2+1
|
||||||
@ -126,10 +130,9 @@ _free: sta ptr1
|
|||||||
lda __hlast+1
|
lda __hlast+1
|
||||||
sta ptr2+1 ; Pointer to last block now in ptr2
|
sta ptr2+1 ; Pointer to last block now in ptr2
|
||||||
|
|
||||||
clc
|
|
||||||
ldy #size
|
ldy #size
|
||||||
lda (ptr2),y ; Low byte of block size
|
lda (ptr2),y ; Low byte of block size
|
||||||
adc ptr2
|
add ptr2
|
||||||
tax
|
tax
|
||||||
iny ; High byte of block size
|
iny ; High byte of block size
|
||||||
lda (ptr2),y
|
lda (ptr2),y
|
||||||
@ -191,3 +194,4 @@ _free: sta ptr1
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user