Add HEAPCHECK
This commit is contained in:
parent
8a33fe3e60
commit
11f454390e
|
@ -126,6 +126,12 @@ The compiler is command line driven, and creates an executable .prg file.
|
||||||
|
|
||||||
A list of source files can be provided.
|
A list of source files can be provided.
|
||||||
|
|
||||||
|
### Run time library defines
|
||||||
|
|
||||||
|
* -dNOLONG : no support for long in printf
|
||||||
|
* -dNOFLOAT : no float in printf
|
||||||
|
* -dHEAPCHECK : check heap allocate and free and jam if heap full or free out of range
|
||||||
|
|
||||||
#### Supported target machines
|
#### Supported target machines
|
||||||
|
|
||||||
* c64 : Commodore C64, (0x0800..0xa000)
|
* c64 : Commodore C64, (0x0800..0xa000)
|
||||||
|
|
|
@ -4214,6 +4214,9 @@ loop:
|
||||||
|
|
||||||
hempty:
|
hempty:
|
||||||
// no more heap blocks
|
// no more heap blocks
|
||||||
|
#ifdef HEAPCHECK
|
||||||
|
byt $02
|
||||||
|
#endif
|
||||||
rts
|
rts
|
||||||
|
|
||||||
avail:
|
avail:
|
||||||
|
@ -4316,6 +4319,25 @@ __asm free
|
||||||
rts
|
rts
|
||||||
notnull:
|
notnull:
|
||||||
|
|
||||||
|
#ifdef HEAPCHECK
|
||||||
|
lda accu + 1
|
||||||
|
ldx accu
|
||||||
|
|
||||||
|
cmp #>HeapStart
|
||||||
|
bcc hfail
|
||||||
|
bne hchk1
|
||||||
|
cpx #<HeapStart
|
||||||
|
bcs hchk1
|
||||||
|
hfail:
|
||||||
|
byt $02
|
||||||
|
hchk1:
|
||||||
|
cmp #>HeapEnd
|
||||||
|
bcc hchk2
|
||||||
|
bne hfail
|
||||||
|
cpx #<HeapEnd
|
||||||
|
bcs hfail
|
||||||
|
hckh2:
|
||||||
|
#endif
|
||||||
// cache end of block, rounding to next four byte
|
// cache end of block, rounding to next four byte
|
||||||
// address
|
// address
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue