Re: [Flashforth-devel] FF and PIC processors
Brought to you by:
oh2aun
From: Pete Z. <pza...@pz...> - 2013-06-09 01:18:06
|
Hi Peter, 1. DUMP in FF3.8 requires lengths in multiples of $10. e.g. here $0f dump nothing printed. here $10 dump for 1 line of print. 2. For the math words, look at Mikael's file 'math.txt' Double and mixed math words -------------------------------------------------------------------------------- math.txt --------- */ ( n1 n2 n3 -- quotient ) */mod swap drop Multiply n1 and n2 then divide by n3. 32 bit intermediate result. */mod ( n1 n2 n3 -- rem quot ) Multiply n1 and n2 then divide by n3. 32-bit intermediate result. /mod ( n1 n2 -- rem quot ) 16/16 -> 16-bit signed division. fm/mod (d n -- rem quot ) Floored 32/16 -> 16-bit division. m* ( n n -- d ) Signed 16*16->32 multiply. mod ( n1 n2 -- remainder ) Remainder of n1 divided by n2. sm/rem ( d n -- rem quot ) Symmetric 32/16 -> 16 bit division. 3. Most people who have used FORTH for a while will have a "toolkit" of words they developed over time and particular applications. Here is mine for FF 3.8 Utility words -------------------------------------------------------------------------------- util38.txt --------- forget <name> ( -- ) Forget name. .mem ( -- ) HEX print of current memory locations; FLASH, EEPROM, RAM. <= ( n1 n2 -- flag ) Leave true flag if n1 less than or equal to n2. ?dup ( x -- 0 | x x ) Conditionally duplicate the top item on the stack, if its value is non-zero. blanks ( c-addr u -- ) Fill u bytes with $20 starting at c-addr. fill ( c-addr u c -- ) Fill u bytes with c starting at c-addr. erase ( c-addr u -- ) Fill u bytes with $00 starting at c-addr. pick ( xu ... x0 u -- xu ... x0 xu ) Place a copy of the nthstack entry on top of the stack. 0 pick is equivalent to dup. ? ( addr -- ) Print unsigned contents at addr in the current base. c? ( addr -- ) Print byte contents at addr in the current base. c?% ( addr -- ) Print byte contents at addr in binary. array ( n -- ) 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) carray ( n -- ) 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) I will try to send you this file, but I may have to send it directly to you, not through SourceForge. Pete Pete Zawasky PZEF Co. 361 Mills RD Oriental, NC 28571 www.pzef.net pza...@pz... 1-252-249-3393 (voice and fax) 1-252-670-6940 (cell) On 6/8/2013 1:53 PM, Peter Jacobs wrote: > Peter, > > I checked by downloading the file after I put it in place so my guess is that your browser is offering up a cached copy. To get around the browser being too smart, I've made a copy of the same file to eoff-2013-jun-08.pdf. That should appear new to your browser. > > I'll play with the words you sent below. Being fairly new to Forth, I am still being surprised by how neat these little utility words are. Is there a collection of such things that is generally available? > > I'm also still learning how much there is to cover in a tutorial. Although I have been trying to limit the document to about 20 pages (so it's not so daunting for the students) I'm open to being more inclusive for this document or for a follow-on document. > > As for dump, I was going to include it but I didn't get it to work as I expected > marker -play ok<$,ram> > $ff93 3 dump ok<$,ram> > create a-array 3 , 2 , 1 , 0 , ok<$,ram> > a-array 8 dump ok<$,ram> > a-array @ . 3 ok<$,ram> > I'm probably just doing it wrong but I also had trouble finding the words mod /mod */ */mod for the single signed numbers. Any hints? > > Peter J. > > |