Skip to content

Instantly share code, notes, and snippets.

@Crest
Created April 15, 2020 21:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Crest/67bee2f2a95cfd6e76fec954fb895181 to your computer and use it in GitHub Desktop.
Save Crest/67bee2f2a95cfd6e76fec954fb895181 to your computer and use it in GitHub Desktop.
: ?# ( d -- d ) 2dup or 0= if bl hold else # then ;
: .padded ( n -- ) >r 0 <# r> 0 do ?# loop #> type ;
20 1024 * constant ram-size
$1FFFF7E0 h@ 1024 * constant flash-size
: compiletoram! ( ? -- ) if compiletoram else compiletoflash then ;
: flash-free ( -- n )
compiletoram?
compiletoflash flash-size here -
swap compiletoram! ;
: ram-free ( -- n )
compiletoram? compiletoram
flashvar-here 1 cells - here -
swap compiletoram! ;
: .free ( avail free -- )
." Total: " over 6 .padded
." Free: " dup 6 .padded
." Used: " - 6 .padded ;
: .flash-free ( -- ) flash-size flash-free .free ;
: .ram-free ( -- ) ram-size ram-free .free ;
: free ( -- )
cr
." FLASH: " .flash-free cr
." RAM: " .ram-free cr ;
free
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment