FlashForth: for PIC and Atmega Wiki
Brought to you by:
oh2aun
PIC18 Utility word collection by Pete Zawasky.
: forget ( <name> -- ) bl word latest @ (f) abort" ?" c>n 2- dup @ abort" ?" dup flash dp ! @ latest ! ram ; \ Display the single value u right-justified in a field of width +n. \ Use the current base. No leading zeros. \ : .r ( u +n -- ) >r 0 <# #s #> r> over - spaces type space ; \ HEX print of current memory locations; FLASH, EEPROM, RAM. \ Followed by DECIMAL print of remaining bytes in each memory type. \ : .mem ( -- ) \ print current memory locations base @ flash hi here dup cr ." flash : " hex #4 u.r - decimal #6 .r ." bytes remaining" eeprom hi here dup cr ." eeprom : " hex #4 u.r - decimal #6 .r ." bytes remaining" ram hi here dup cr ." ram : " hex #4 u.r - decimal #6 .r ." bytes remaining" base ! ; : depth ( -- u ) \ PIC18 sp@ s0 @ - 2/ ; \ get parameter stack depth : <= ( n1 n2 -- flag ) - 1- 0< ; \ leave true flag if n1 less than or equal to n2 : ?dup ( x -- 0 | x x ) dup if dup then ; \ duplicate TOS only if non-zero : fill ( c-addr u c -- ) \ fill u bytes with c starting at c-addr rot !p>r swap for dup pc! p+ next r>p drop ; : erase ( c-addr u -- ) 0 fill ; : blanks ( c-addr u -- ) bl fill ; : pick ( xu ... x0 u -- xu ... x0 xu) 2* 3 + sp@ swap - @ ; : ? ( addr -- ) \ print unsigned contents at addr 2 spaces @ u. ; \ in the current base (non-standard) : c? ( addr -- ) \ print byte contents at addr 2 spaces c@ . ; \ in the current base : c?% ( addr -- ) \ print byte contents at addr 2 spaces base @ swap \ in binary c@ 8 bin u.r base ! ; \ Compile a word which creates n cell indexed arrays. \ compile-time n array <name> where n is size of array \ run-time i <name> where i is the array index \ and i is zero based (0...n-1) : array ( n -- ) create cells allot does> ( i -- 'cell ) swap cells + ; \ Compile a word which creates n indexed character arrays. \ compile-time n carray <name> where n is size of array \ run-time i <name> where i is the array index \ and i is zero based (0...n-1) : carray ( n -- ) create allot does> ( i -- 'char ) + ; \ Create a 20 character array in eeprom called CALIBRATE. \ eeprom \ decimal 20 carray calibrate \ ram ram hex
Here is a file containing words that I have found helpful when using FF3.81 . Note the word 'hi' used in the word '.mem' is available in the FF3.81 version found under the Code tab in the git repository .
Last edit: Pete Zawasky 2013-10-17