\ @(#) t_alloc.fth 97/01/28 1.4
\ Copyright 1994 3DO, Phil Burk
64 constant NUM_TAF_SLOTS
\ hold addresses and sizes
NUM_TAF_SLOTS array TAF-ADDRESSES
NUM_TAF_SLOTS array TAF-SIZES
: TAF.MAX.ALLOC? { | numb addr ior maxb -- max }
\ determine maximum amount we can allocate
numb allocate -> ior -> addr
addr free abort" Free failed!"
taf.max.alloc? ." Total Avail = " dup . cr
NUM_TAF_SLOTS / taf-max-slot !
: TAF.ALLOC.SLOT { slotnum | addr size -- }
dup allocate abort" Allocation failed!"
addr slotnum taf-addresses !
\ paint RAM with slot number
: TAF.FREE.SLOT { slotnum | addr size -- }
slotnum taf-addresses @ -> addr
\ something allocated so check it and free it.
." , slot# " slotnum . cr
addr free abort" Free failed!"
0 slotnum taf-addresses !
: TAF.DO.SLOT { slotnum -- }
slotnum taf-addresses @ 0=
taf.max.alloc? dup ." Final MAX = " . cr
." Original MAX = " taf-max-alloc @ dup . cr
= IF ." Test PASSED." ELSE ." Test FAILED!" THEN cr
: TAF.TEST ( NumTests -- )
dup . ." tests" cr \ flushemit
." Please wait for test to complete..." cr
DO NUM_TAF_SLOTS choose taf.do.slot
.( Testing ALLOCATE and FREE) cr