mirror of
https://github.com/cc65/cc65.git
synced 2025-02-03 22:32:24 +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
|
||||
.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
|
||||
|
||||
|
||||
; Code
|
||||
|
||||
@ -80,12 +85,12 @@ _free: sta ptr1
|
||||
ora ptr1+1 ; Is the argument NULL?
|
||||
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.
|
||||
|
||||
sec
|
||||
lda ptr1
|
||||
sbc #2
|
||||
sub #admin_space
|
||||
sta ptr1
|
||||
bcs @L1
|
||||
dec ptr1+1
|
||||
@ -98,8 +103,7 @@ _free: sta ptr1
|
||||
|
||||
; Check if the block is on top of the heap
|
||||
|
||||
clc
|
||||
adc ptr1
|
||||
add ptr1
|
||||
tay
|
||||
lda ptr1+1
|
||||
adc ptr2+1
|
||||
@ -126,10 +130,9 @@ _free: sta ptr1
|
||||
lda __hlast+1
|
||||
sta ptr2+1 ; Pointer to last block now in ptr2
|
||||
|
||||
clc
|
||||
ldy #size
|
||||
lda (ptr2),y ; Low byte of block size
|
||||
adc ptr2
|
||||
add ptr2
|
||||
tax
|
||||
iny ; High byte of block size
|
||||
lda (ptr2),y
|
||||
@ -191,3 +194,4 @@ _free: sta ptr1
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user