diff --git a/README.md b/README.md index 3ab4eff..eaf2675 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,12 @@ The compiler is command line driven, and creates an executable .prg file. 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 * c64 : Commodore C64, (0x0800..0xa000) diff --git a/include/crt.c b/include/crt.c index 5bb41d8..f1a96ed 100644 --- a/include/crt.c +++ b/include/crt.c @@ -4214,6 +4214,9 @@ loop: hempty: // no more heap blocks +#ifdef HEAPCHECK + byt $02 +#endif rts avail: @@ -4316,6 +4319,25 @@ __asm free rts notnull: +#ifdef HEAPCHECK + lda accu + 1 + ldx accu + + cmp #>HeapStart + bcc hfail + bne hchk1 + cpx #HeapEnd + bcc hchk2 + bne hfail + cpx #