{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil\fcharset0 Courier New;}} {\*\generator Msftedit 5.41.15.1515;}\viewkind4\uc1\pard\lang1033\b\f0\fs28 PropForth Core(\\) and Optional(\\\\) Words - Quick Reference\b0\fs20\par ******************************************************************************************\par (Based on ANSI Standard Forth - Quick Reference Copyright 1994 Forth Interest Group)\par \par \b\fs24 Arithmetic and Logical Operations\b0\fs20\par \par \\ \b and\b0 ( n1 n2 -- n1 ) bitwise and n1 n2\par \\ \b andn\b0 ( n1 n2 -- n1 ) bitwise and n1 invert n2\par \\ \b or\b0 ( n1 n2 -- n1_or_n2 ) bitwise or\par \\ \b xor\b0 ( n1 n2 -- n1_xor_n2 ) bitwise xor\par \\ \b invert\b0 ( n1 -- n2 ) bitwise invert n1\par \\ \b lshift\b0 (n1 n2 -- n3) n3 = n1 shifted left n2 bits\par \\ \b rshift\b0 ( n1 n2 -- n3) n3 = n1 shifted right logically n2 bits\par \\ \b rashift\b0 ( n1 n2 -- n3) n3 = n1 shifted right arithmetically n2 bits\par \\\\ \b andC! \b0 ( c1 addr -- ) and c1 with the contents of address\par \\ \b W+! \b0 ( n1 addr -- ) add n1 to the word contents of address\par \\ \b orC! \b0 ( c1 addr -- ) or c1 with the contents of address\par \\ \b andnC! \b0 ( c1 addr -- ) and inverse of c1 with the contents of address\par \\ \b orlnfa\b0 ( c1 -- ) ors c1 with the nfa length of the last name field entered\par \par \\ \b between\b0 ( n1 n2 n3 -- t/f ) true if n2 <= n1 <= n3\par \par \\ \b negate\b0 ( n1 -- 0-n1 ) the negative of n1\par \\ \b max\b0 ( n1 n2 -- n1 ) signed max of top 2 stack values\par \\\b min \b0 ( n1 n2 -- n1 ) signed min of top 2 stack values\par \\\\\b abs \b0 ( n1 -- abs_n1 ) absolute value of n1\par \\\\ \b sign\b0 ( n1 n2 -- n3 ) n3 is the xor of the sign bits of n1 and n2 \par \par \\ \b -\b0 ( n1 n2 -- n1-n2 )\par \\ \b +\b0 ( n1 n2 -- n1+n2 ) sum of n1 & n2\par \\\\ \b *\b0 ( n1 n2 -- n1*n2) n1 multiplied by n2\par \\\\ \b /\b0 ( n1 n2 -- n1/n2) n1 divided by n2\par \\\\ \b */mod \b0 ( n1 n2 n3 -- n4 n5 ) n5 = (n1*n2)/n3, n4 is the remainder. \par Uses a 64bit intermediate result.\par \\\\ \b */\b0 ( n1 n2 n3 -- n4 ) n4 = (n1*n2)/n3. Uses a 64bit intermediate result.\par \\\\ \b /mod \b0 ( n1 n2 -- n3 n4 ) \\ signed divide & mod n4 = n1/n2, n3 is the remainder\par \par \\ \b u/ \b0 ( u1 u2 -- u1/u2) u1 divided by u2\par \\ \b u* \b0 ( u1 u2 -- u1*u2) u1 multiplied by u2\par \\\b um* \b0 ( u1 u2 -- u1*u2L u1*u2H ) unsigned 32bit * 32bit -- 64bit result\par \\ \b um/mod ( \b0 u1lo u1hi u2 -- remainder quotient ) unsigned divide & mod u1 divided by u2\par \\ \b u/mod \b0 ( u1 u2 -- remainder quotient ) unsigned divide & mod u1 divided by u2\par \\\\ \b u*/mod \b0 ( u1 u2 u3 -- u4 u5 ) u5 = (u1*u2)/u3, u4 is the remainder. \par Uses a 64bit intermediate result.\par \\\\\b u*/ \b0 ( u1 u2 u3 -- u4 ) u4 = (u1*u2)/u3 Uses a 64bit intermediate result.\par \par \\ \b 1+ \b0 ( n1 -- n1+1 )\par \\ \b 1- \b0 ( n1 -- n1-1 )\par \\ \b 2+ \b0 ( n1 -- n1+2 )\par \\ \b 2- \b0 ( n1 -- n1-2 )\par \\ \b 4+ \b0 ( n1 -- n1+4 )\par \\ \b 2* \b0 ( n1 -- n1<<1 ) n2 is shifted logically left 1 bit\par \\ 4* ( n1 -- n1<<1 ) n2 is shifted logically left 2 bits\par \\ \b 2/ \b0 ( n1 -- n1>>1 ) n2 is shifted arithmetically right 1 bit\par \par \\\\ \b rnd\b0 ( -- n1 ) n1 is a random number from 00 - FF\par \\\\ \b rndtf\b0 ( -- t/f) true or false randomly\par \\\\ \b rndand\b0 ( n1 -- n2) n2 is randomly n1 or 0\par \par \b\fs28 Number Type Conversions\par \par \b0\fs20\\ \b w>l \b0 ( n1 n2 -- n1n2 ) consider only lower 16 bits\par \\ \b l>w \b0 ( n1n2 -- n1 n2) break into 16 bits\par \\ \b tochar\b0 ( n1 -- c1 ) convert n1 to a char\par \par \par \par \b\fs24 Comparison Operators\b0\fs20\par \par \\ \b =\b0 ( n1 n2 -- t/f ) compare top 2 32 bit stack values, \par true if they are equal\par \\ \b >\b0 ( n1 n2 -- t/f ) flag is true if and only if n1 is greater than n2\par \\ \b <\b0 ( n1 n2 -- t/f ) flag is true if and only if n1 is less than n2\par \\ \b <>\b0 ( x1 x2 -- flag ) flag is true if and only if x1 is not bit-for-bit \par the same as x2\par \\ \b >=\b0 ( n1 n2 -- t/f) true if n1 >= n2\par \\ \b <=\b0 ( n1 n2 -- t/f) true if n1 <= n2\par \\ \b 0= \b0 ( n1 -- t/f ) true if n1 is zero\par \\ \b 0<> \b0 ( n1 -- t/f ) true if n1 is not zero\par \\ \b 0< \b0 ( n1 -- t/f ) true if n1 < 0\par \\ \b 0> \b0 ( n1 -- t/f ) true if n1 > 0\par \\ \b 0>= \b0 ( n1 -- t/f ) true if n1 >= 0\par \par \b\fs24 Manipulating the Stack\b0\fs20\par \par \\ \b drop\b0 ( n1 -- ) drop the value on the top of the stack\par \\ \b dup\b0 ( n1 -- n1 n1 )\par \\ \b over\b0 ( n1 n2 -- n1 n2 n1 ) duplicate 2 value down on the stack to the\par top of the stack\par \\ \b rot\b0 ( n1 n2 n3 -- n2 n3 n1 ) rotate top 3 value on the stack\par \\ \b rot2\b0 ( x1 x2 x3 -- x3 x1 x2 )\par \\ \b swap\b0 ( n1 n2 -- n2 n1 ) swap top 2 stack values\par \\ \b 2dup\b0 ( n1 n2 -- n1 n2 n1 n2 copy top 2 items on the stack\par \\ \b 2drop \b0 ( n1 n2 -- ) drop top 2 items on the stack\par \\ \b 3drop \b0 ( n1 n2 n3 -- ) drop top 3 items on the stack\par \\ \b nip\b0 ( x1 x2 -- x2 ) delete the item x1 from the stack\par \\ \b tuck\b0 ( x1 x2 -- x2 x1 x2 copy top item into 3rd stack slolt\par \par \\ \b r> \b0 ( -- n1 ) pop top of RS to stack\par \\ \b >r \b0 ( n1 -- ) pop stack top to RS\par \\ \b 2>r \b0 ( n1 n2 -- ) pop top 2 stack top to RS\par \\\\ \b r@ \b0 ( -- n1 ) \\ copy top of RS to stack\par \par \\ \b bounds\b0 ( x n -- x+n x )\par \par \par \b\fs24 Memory-Stack Transfer\par \par \b0\fs20\\ \b L@ \b0 ( addr -- n1 ) fetch 32 bit value at main memory addr\par \\ \b C@ \b0 ( addr -- c1 ) fetch 8 bit value at main memory addr\par \\ \b W@ \b0 ( addr -- h1 ) fetch 16 bit value at main memory addr\par \par \\ \b L! \b0 ( n1 addr -- ) store 32 bit value (n1) at main memory addr\par \\ \b C! \b0 ( c1 addr -- ) store 8 bit value (c1) main memory at addr\par \\ \b W! \b0 ( h1 addr -- ) store 16 bit value (h1) main memory at addr\par \par \\ \b litw \b0 ( -- h1 ) push a 16 bit literal on the stack\par \\ \b litl\b0 ( -- n1 ) push a 32 bit literal on the stack\par \par \\ \b C@++ \b0 ( c-addr -- c-addr+1 c1 ) fetch the character and increment the address\par \par \par \b\fs24 Definite Loops\par \b0\fs20\par \\ \b do\b0 ( n1 -- ) marks start of a block run 1 or more times (immediate)\par \\ \b doloop\b0 used in loop & +loop\par \\ \b (loop) \b0 ( -- ) add 1 to loop counter, branch if count is below limit, \par offset follows\par \\ \b loop\b0 marks end of do block (immediate)\par \\ \b (+loop) \b0 ( n1 -- ) add n1 to loop counter, branch if count is below limit,\par offset follows\par \\ \b +loop \b0 marks end of do block (immediate)\par \\ \b leave\b0 ( -- ) exits at the next loop or +loop, i is placed to the max\par loop value\par \\ \b i\b0 ( -- n1 ) the most current loop counter\par \\ \b ibound\b0 ( -- n1 ) the upper bound of i\par \\\\ \b lasti? \b0 ( -- t/f ) true if this is the last value of i in this loop\par \\ \b seti\b0 ( n1 -- ) set the most current loop counter\par \par \\\\ \b j\b0 ( -- n1 ) the second most current loop counter\par \\\\ \b jbound\b0 ( -- n1 ) the upper bound of j\par \\\\ \b lastj? \b0 ( -- t/f ) true if this is the last value of j in this loop\par \\\\ \b setj \b0 ( n1 -- ) set the second most current loop counter\par \par \par \b\fs24 Indefinite Loops\par \par \b0\fs20\\ \b begin\b0 ( -- ) marks beginning of a group of words to be executed\par \\ \b until\b0 ( t/f -- ) iterates back to begin until true \par \par \par \par \b\fs24 String Operators\b0\fs20\par \par \\ \b <# \b0 ( -- ) initialize the output area\par \\ \b #>\b0 ( -- caddr ) address of a counted string representing the output,\par NOT ANSI\par \\ \b #\b0 ( n1 -- n2 ) divide n1 by base and convert the remainder to a char \par and append to the output\par \\ \b #s \b0 ( n1 -- 0 ) execute # until the remainder is 0\par \par \\ \b cmove\b0 ( c-addr1 c-addr2 u -- ) If u is greater than zero, copy u consecutive \par characters from the data space starting\par at c-addr1 to that starting at c-addr2, proceeding \par character-by-character from lower addresses to \par higher addresses.\par \par \\ \b ctoupper\b0 ( c1 -- c1 ) if c is a-z converts it to upper case\par \\ \b todigit\b0 ( c1 -- n1 ) converts character to a number \par \\ \b isdigit\b0 ( c1 -- t/f ) true if is it a valid digit according to base\par \\ \b isunumber\b0 ( c-addr len -- t/f ) true if the string is numeric\par \\ \b unumber\b0 ( c-addr len -- u1 ) convert string to an unsigned number\par \\ \b number\b0 ( c-addr len -- n1 ) convert string to a signed number\par \\ \b isnumber\b0 ( c-addr len -- t/f ) true if the string is numeric\par \par \\ \b fill\b0 ( c-addr u char -- ) set string at addr to u characters\par \\ \b accept\b0 ( c-addr +n1 -- +n2 ) collect n1 -2 characters or until eol, \par convert tab to space,\par \\ \b find\b0 ( c-addr -- c-addr 0 | xt 2 | xt 1 | xt -1 )\par c-addr is a counted string,\par 0 - not found, 2 eXecute word, \par 1 immediate word, -1 word NOT ANSI\par \par \b\fs24 Input/Output Operations\b0\fs20\par \par \\ \b cr\b0 ( -- ) emits a carriage return\par \\\b space \b0 ( -- ) emits a space\par \\ \b spaces \b0 ( n -- ) emit n spaces\par \\ _\b ecs\b0 emit esc charactere\par \par \\ \b .bvalue \b0 ( n1 -- ) emits 3 character \par \\ \b .addr \b0 ( n1 -- ) emits 6 character address\par \\ \b .value \b0 ( n1 -- ) emits 11 character number\par \\ \b .hex \b0 ( n -- ) emit a single hex digit\par \\ \b .byte \b0 ( n -- ) emit 2 hex digits\par \\ \b .word \b0 ( n -- ) emit 4 hex digits\par \\ \b .str \b0 ( c-addr u1 -- ) emit u1 characters at c-addr\par \\\\ \b .long \b0 ( n -- ) emit 8 hex digits\par \\ \b .\b0 ( n1 -- ) displays top of stack\par \par These routine will output to the console, they will not block, so characters may drop\par in the case of collisions.\par \par \\\\ \b .conemit \b0 ( c1 -- ) emit cr to console, will timeout, 80MHZ cog 57.6Kb \par console, should keep up\par \\\\ \b .concstr \b0 ( cstr -- ) emit cstr to console\par \\\\ \b .con \b0 ( n1 -- ) print n1 to the console to console\par \\\\ \b .concr \b0 ( -- ) emit a cr to the console\par \\\\ \b .conbvalue \b0\par \\\\ \b .conaddr \b0\par \\\\ \b .convalue \b0\par \\\\ \b .const? \b0 ( -- ) prints out the stack\par \par \\\b emit? \b0 ( -- t/f) true if the output is ready for a char\par \\ \b femit? \b0 (c1 -- t/f) true if the output emitted a char, a fast non blocking emit\par \\ \b emit\b0 ( c1 -- ) emit the char on the stack\par \\ \b key? \b0 ( -- t/f) true if there is a key ready for input\par \\ \b fkey? \b0 ( -- c1 t/f ) fast nonblocking key routine, true if c1 is a valid key\par \\ \b key \b0 ( -- c1 ) get a key\par \\ \b clearkeys\b0 ( -- ) clear the input keys\par \par \\ \b delms\b0 ( n1 -- ) delays n1 millisec (for 80Mhz 68DB max)\par \\ \b delsec\b0 ( n1 -- ) delays n1 seconds \par \par \par \\\\ \b cappendc\b0 ( c1 cstr -- ) append c1 the cstr\par \\\\ \b cappendnc\b0 ( n cstr -- ) print the number n and append to cstr and then \par append a blank\par \\\\ \b ctolower\b0 ( c1 -- c1 ) if c is A-Z converts it to lower case\par \\\\ #C ( c1 -- ) prepend the character c1 to the number currently being formatted\par \\\\ \b .cogch \b0 ( n1 n2 -- ) print as x(y)\par \par \\ \b alignl\b0 ( n1 -- n1) aligns n1 to a long (32 bit) boundary\par \\ \b alignw \b0 ( n1 -- n1) aligns n1 to a halfword (16 bit) boundary\par \\ \b npfx\b0 ( c-addr1 c-addr2 -- t/f ) -1 if c-addr2 is prefix of c-addr1, 0 otherwise\par \\ \b namelen ( \b0 c-addr -- c-addr+1 len )returns c-addr+1 and the length of the name at c-addr\par \\ \b namecopy\b0 ( c-addr1 c-addr2 -- ) Copy the name from c-addr1 to c-addr2\par \\ \b ccopy\b0 ( c-addr1 c-addr2 -- ) Copy the cstr from c-addr1 to c-addr2\par \\ \b cappend\b0 ( c-addr1 c-addr2 -- ) addpend the cstr from c-addr1 to c-addr2\par \\ \b cappendn\b0 ( n cstr -- ) print the number n and append to cstr\par \\ \b .strname \b0 ( c-addr -- ) c-addr point to a forth name field, print the name\par \\ \b .cstr \b0 ( addr -- ) emit a counted string at addr\par \\ \b dq\b0 ( -- ) emit a counted string at the ip, and increment the \par ip past it and word alignw it\par \par \par \b\fs24 File Input/Output (eeprom)\par \par \b0\fs20\\\\ \b ee>image \b0 ( addr n1 -- ) addr - the address to start producing an image from, \par n1 - count of bytes to produce, \par must be a multiple of 64 \par \\\\ \b image>ee \b0 ( n1 - n16 addr -- ) writes the 16 longs on the stack to the addr in eeprom\par \par \i Eeprom read and write routine for the prop proto board AT24CL256 eeprom \par on pin 28 sclk, 29 sda.\par \i0 The eereadpage and eewritePage words assume the eeprom are 64kx8 and will address up to \par 8 sequential eeproms.\par \i\par \i0\\\b _eestart \b0 ( -- ) start the data transfer\par \\ \b _eestop \b0 ( -- ) stop the data transfer\par \\ \b _eewrite \b0 ( c1 -- t/f ) write a byte to the eeprom, returns ack bit\par \\\b eewritepage \b0 ( eeAddr addr u -- t/f ) return true if there was an error, use lock 1\par \\ \b EW! \b0 ( n1 eeAddr -- )\par \\\\ \b eereset\b0 ( -- ) initialize the eeprom in case it is in a weird state\par \\\\ \b _eeread \b0 ( t/f -- c1 ) read a byte from the eeprom, ackbit in, byte out\par \\\\ \b eereadpage\b0 ( eeAddr addr u -- t/f ) return true if there was an error, use lock 1\par \\\\ EW@ ( eeAddr -- n1 )\par \\\\ \b EC@ \b0 ( eeAddr -- c1 )\par \\\\ \b eecopy\b0 ( addr1 addr2 u -- ) copy u bytes from addr1 to addr2, addr1 and addr2 \par must beon a 0x40 byte page boundary\par clears the pad, so make sure no commands follow and\par u must be a multiple of 0x40 and should not overlap\par \par \par \b\fs24 Inspect Memory, Debug & View Code\par \par \b0\fs20\\ \b words\b0 ( -- ) prints the words in the forth dictionary, if the pad has\par another string following, with that prefix\par \\\\ \b st? \b0 ( -- ) prints out the stack\par \\\\ \b sc\b0 ( -- ) clears the stack\par \\\\ \b _pna \b0 ( addr -- ) print the address, contents and forth name\par \\\\\b rs? \b0 ( -- ) prints out the return stack\par \par \\\\ \b (forget) \b0 ( cstr -- ) wind the dictionary back to the word which follows \par \\\\ \b forget\b0 ( -- ) wind the dictionary back to the word which follows \par \\\\ \b free\b0 ( -- ) display free main bytes and current cog longs\par \par \\\\ \b (dumpb)\par \b0\\\\ \b (dumpm)\par \b0\\\\ \b (dumpe)\par \b0\\\\ \b dump\b0 ( adr cnt -- ) uses tbuf\par \\\\ \b edump\b0 ( adr cnt -- ) uses tbuf\par \\\\ \b cogdump\b0 ( adr cnt -- )\par \par \\ Noisy reset messages\par \\\par \\ print out a reset message to the console\par \\ \b (rsm) \b0 ( n -- ) n is the last status\par \\ 0011FFFF - stack overflow\par \\ 0012FFFF - return stack overflow\par \\ 0021FFFF - stack underflow\par \\ 0022FFFF - return stack underflow\par \\ 8100FFFF - no free cogs\par \\ 8200FFFF - no free main memory\par \\ 8400FFFF - fl no free main memory\par \\ 8500FFFF - no free cog memory\par \\ 8800FFFF - eeprom write error\par \\ 9000FFFF - eeprom read error\par \par \par \par \par \b\fs24 Define Data Structures\par \par \b0\fs20\\ \b doconw\b0 ( -- h1 ) push 16 bit constant which follows on the stack \par - implicit a_exit\par \\\b doconl \b0 ( -- n1 ) push a 32 bit constant which follows the stack \par - implicit a_exit\par \\ \b dovarw \b0 ( -- addr ) push address of 16 bit variable which follows on the stack\par - implicit a_exit\par \\ \b asmlabel\b0 ( x -- ) skip blanks parse the next word \par and create an assembler entry\par \\ \b dovarl\b0 ( -- addr ) push address of 32 bit variable which follows the stack \par - implicit a_exit\par \par \\ \b wconstant\b0 ( x -- ) skip blanks parse the next word and create a constant\par allocate a word, 2 bytes\par \\ \b wvariable\b0 ( -- ) skip blanks parse the next word and create a variable\par allocate a word, 2 bytes \par \\\\\b cogvariable \b0 ( -- ) skip blanks parse the next word and create a cog variable,\par allocate a long\par \\\\ \b variable\b0 ( -- ) skip blanks parse the next word and create a variable,\par allocate a long, 4 bytes\par \\\\ \b constant \b0 ( x -- ) skip blanks parse the next word and create a constant,\par allocate a long, 4 bytes\par \par \par \par \b\fs24 Propeller-Specific Words \b0\fs20 (Not listed in other categories.)\par \b\fs24\par \b0\i\fs20 cog related words\b\i0\fs24\par \b0\fs20\\ \b cogstop\b0 ( n -- )\par \\ \b cogreset\b0 ( n1 -- ) reset the forth cog\par \\ \b cogio\b0 ( n -- addr) the address of the data area for cog n\par \\ \b cogiochan\b0 ( n1 n2 -- addr ) cog n1, channel n2 ->addr\par \\ \b io>cogchan \b0 ( addr -- n1 n2 ) addr -> n1 cogid, n2 channel\par \\ \b io>cog \b0 ( addr -- n ) addr -> cogid\par \\ \b io\b0 ( -- addr ) the address of the io channel for the cog\par \\ \b coghere \b0 ( -- addr ) access as a word, the first unused register address \par in this cog\par \\ \b cognchan\b0 ( n1 -- n2 ) number of io channels for cog n2\par \\ \b >con \b0 ( n1 -- ) disconnect the current cog, and connect the console \par to the forth cog\par \\ \b debugcmd \b0 ( -- addr ) address of the debugcmd as a word, used to commincate \par from forth cog to request a reset, or for traces\par \\ \b COG@ \b0 ( addr -- n1 ) fetch 32 bit value at cog addr\par \\ \b COG! \b0 ( n1 addr -- ) store 32 bit value (n1) at cog addr\par \\ \b (nfcog) \b0 ( -- n1 n2 ) n1 the next valid free forth cog, n2 is 0 if the cog is valid \par \\ \b nfcog\b0 ( -- n ) returns the next valid free forth cog\par \\ \b cogx\b0 ( cstr n -- ) execute cstr on cog n\par \\ \b cogid\b0 ( -- n1 ) return id of the current cog ( 0 - 7 )\par \\ \b cogpad\b0 \par \\ \b cognumpad\b0 \par \\ \b cogstate \par \b0\par \\ \b (iodis) \b0 ( n1 n2 -- ) cog n1 channel n2 disconnect, disconnect this cog and the cog \par it is connected to\par \\ \b iodis \b0 ( n1 -- ) cogid to disconnect, disconnect this cog and the cog \par it is connected to\par \\ \b (ioconn) \b0 ( n1 n2 n3 n4 -- ) connect cog n1 channel n2 to cog n3 channel n4, \par disconnect them from other cogs first\par \\ \b ioconn\b0 ( n1 n2 -- ) connect the 2 cogs, disconnect them from other cogs first\par \\ \b (iolink) \b0 ( n1 n2 n3 n4 -- ) links the 2 channels, output of cog n1 channel n2 -> input \par of cog n3 channel n4,\par output of n3 channel n4 -> old output of n1 channel n2\par \\ \b iolink \b0 ( n1 n2 -- ) links the 2 cogs, output of n1 -> input of n2, \par output of n2 -> old output of n1\par \\ \b (iounlink) \b0 ( n1 n2 -- ) unlinks cog n1 channel n2\par \\ \b iounlink\b0 ( n1 -- ) unlinks the cog n1\par \par \\\\ \b cog+ \b0 ( -- ) add a forth cog\par \\\\ \b (cog-) \b0 ( -- ) stop first forth cog, cannot be executed from \par the first forth cog \par \\\\ \b cog- \b0 ( -- ) stop first forth cog, cannot be executed from\par the first forth cog \par \\\\ \b cog? \b0 ( -- )\par \par \\\\ \b aallot\b0 ( n1 -- ) add n1 to coghere, allocates space in the cog or release it,\par n1 is # of longs\par \\\\ \b cog, \b0 ( x -- ) allocate 1 long in the cog and copy x to that location\par \\ \b hubop\b0 ( n1 n2 -- n3 t/f ) n2 specifies which hubop (0 - 7), n1 is the source datcog, \par \par \par \\ \b ERR\b0 ( n1 -- ) clear the input queue, set the error n1 and reset this cog\par \\ \b cogdebugcmd\par \b0\\\b debugvalue \b0 ( -- addr ) the address of the debugvalue as a long, \par used in conjuction with debugcmd\par \\ \b cogdebugvalue \b0\par n3 is returned, t/f is the 'c' flag is set from the hubop\par \i locks\i0\par \\ \b lockset\b0 ( n1 -- n2 ) set lock n1, result is in n2, -1 if the lock was set as per\par 'c' flag, lock ( n1 ) must have been allocated via locknew\par \\ \b lockclr\b0 ( n1 -- n2 ) clear lock n1, result is in n2, -1 if the lock was set as \par per 'c' flag, \par lock ( n1 ) must have been allocated via locknew\par \\ \b lockdict? \b0 ( -- t/f ) attempt to lock the forth dictionary, 0 if unsuccessful\par -1 if successful\par \\ \b freedict\b0 ( -- ) free the forth dictionary, if I have it locked\par \\ \b lockdict\b0 ( -- ) lock the forth dictionary\par \\ \b mydictlock\b0 ( -- addr ) access as a char, the number of times dictlock has been \par executed in the cog minus the freedict\par \\\\ \b locknew\b0 ( -- n2 ) allocate a lock, result is in n2, -1 if unsuccessful\par \\\\ \b lockret\b0 ( n1 -- ) deallocate a lock, previously allocated via locknew\par \par \i propeller pins\i0\par \\ \b pinin \b0 ( n1 -- ) set pin # n1 to an input\par \\ \b pinout\b0 ( n1 -- ) set pin # n1 to an output\par \\ \b pinlo\b0 ( n1 -- ) set pin # n1 to lo\par \\ \b pinhi\b0 ( n1 -- ) set pin # n1 to hi\par \\ \b px\b0 ( t/f n1 -- ) set pin # n1 to h - true or l false\par \\\\ \b px? \b0 ( n1 -- t/f) true if pin n1 is hi\par \par \par \\ reboot ( -- ) reboot the propellor chip\par \\ reset ( -- ) reset this cog\par \i registers (wconstants) \par \i0\\\b par \b0\\ \b ina\b0 \\ \b dira\b0 \\\\ \b ctra\b0 \\\\ \b frqa\b0 \\\\ \b phsa\b0 \\\\ \b vsfg\par \b0\\ \b cnt \b0 \\ \b outa\b0 \\\\ \b ctrb\b0 \\\\ \b frqb\b0 \\\\ \b phsb\b0 \\\\ \b vscl\b0 \par \par \\\b parat \b0 ( offset -- addr ) the offset is added to the contents of the par register,\par giving an address references \par \par \i clock related\i0\par \\ \b clkfreq\b0 ( -- u1 ) the system clock frequency\par \\\\ \b waitcnt\b0 ( n1 n2 -- n1 ) wait until n1, add n2 to n1\par \\\\ \b waitpeq\b0 ( n1 n2 -- ) wait until state n1 is equal to ina anded with n2\par \\\\ \b waitpne\b0 ( n1 n2 -- ) wait until state n1 is not equal to ina anded with n2\par \par \\\\\b _cfo \b0 ( n1 -- n2 ) n1 - desired frequency, n2 freq a \par \\\\\b setHza \b0 ( n1 n2 -- ) n1 is the pin, n2 is the freq, uses ctra\par set the pin oscillating at the specified frequency\par \\\\ \b qHzb \b0 ( n1 n2 -- n3 ) n1 - the pin, n2 - the # of msec to sample, n3 the frequency\par \\\\ \b setHzb\b0 ( n1 n2 -- ) n1 is the pin, n2 is the freq, uses ctrb\par set the pin oscillating at the specified frequency\par \par \par \par \par \b\fs24 Compiler & Interpreter System Extensions\par \par \b0\fs20\\ \b >out \b0 ( -- addr ) access as a word, the offset to the current output byte\par \\ >in ( -- addr ) access as a word, addr is the var the offset in characters \par from the start of the input buffer to the parse area.\par \\ \b pad\b0 ( -- addr ) access as bytes, or words and long, the address of the pad area - \par used by accept for keyboard input, can be used carefully \par by other code\par \\ \b pad>in \b0 ( -- addr ) addr is the address to the start of the parse area.\par \\ \b namemax\b0 ( -- n1 ) the maximum name length allowed must be 1F\par \par 80 wconstant \b padsize\b0 the size of the pad area \par \\ \b execword\b0 ( -- addr ) a long, an area where the current word for execute is stored\par \\ \b execute\b0 ( addr -- ) execute the word - pfa address is on the stack\par \\ \b pad>out \b0 ( -- addr ) addr is the address to the the current output byte\par \par \\ \b numpad\b0 ( -- addr ) the of the area used by the numeric output routines, \par can be used carefully by other code\par \b\\ numpadsize\b0 the size of the numpad, 0x21 bytes if we are working in binary,\par otherwise 1 + max num digits are necessary\b\par \b0\par \\ \b state\b0 ( -- addr) access as a char\par bit 0 - 0 - interpret mode / 1 - forth compile mode\par bit 1 - 0 - direct console output turned off \par 1 - direct console output turned on\par bit 2 - 0 - Free / 1 - PropForth cog\par bit 3 - 0 - Free \par 1 - Other cog does not support IO channels\par bit 4 - 0 - Free / 1 - Other cog supports io channels\par bit 5 - 7 - number of io channels - 1\par \par \\ \b compile? \b0 ( -- t/f ) true if we are in a compile\par \par Pad with 1 space at start & end. \par \\ \b parse\b0 ( c1 -- +n2 ) parse the word delimited by c1, or the end of buffer \par is reached, n2 is the length >in is the offset\par in the pad of the start of the parsed word\par \\ \b skipbl\b0 ( -- ) increment >in past blanks or until it equals padsize\par \\ \b nextword\b0 ( -- ) increment >in past current counted string\par \\\b parseword \b0 ( c1 -- +n2 ) skip blanks, and parse the following word delimited by c1, \par update to be a counted string in the pad\par \\ \b parsebl\b0 ( -- t/f) parse the next word in the pad delimited by blank,\par true if there is a word\par \\ \b parsenw\b0 ( -- cstr ) parse and move to the next word, str ptr is zero \par if there is no next word\par \\\\ \b parsenw \b0 ( -- cstr ) parse and move to the next word, str ptr is zero \par if there is no next word\par \\\\ \b padnw\b0 ( -- t/f ) move past current word and parse the next word, true \par if there is a next word\par \\\\ \b padclr\b0 ( -- )\par \\\\ \b padbl\b0 ( -- ) fills this cogs pad with blanks\par \par \\ \b ccreate\b0 ( cstr -- ) create a dictionary entry\par \\ \b create\b0 ( -- ) skip blanks parse the next word and create a dictionary entry\par \par \\ \b herewal\b0 ( -- ) align contents of here to a word boundary, 2 byte boundary\par \\ \b allot\b0 ( n1 -- ) add n1 to here, allocates space on the data dictionary or release it\par \\ \b herelal\b0 ( -- ) alignw contents of here to a long boundary, 4 byte boundary\par \\ \b immediate\b0 ( -- ) marks last entry as an immediate word\par \\ \b exec\b0 ( -- ) marks last entry as an eXecute word, executes always\par \par \\ \b w, \b0 ( x -- ) allocate 1 halfword 2 bytes in the dictionary \par and copy x to that location\par \\ \b c, \b0 ( x -- ) allocate 1 byte in the dictionary and copy x to that location\par \\ \b l, \b0 ( x -- ) allocate 1 long, 4 bytes in the dictionary \par and copy x to that location\par \par \\ \b '\b0 ( -- addr ) returns the execution token for the next name, \par if not found it returns 0\par \par \par \b\fs24 Defining Routines\b0\fs20\par \par \\ \b exit \b0 ( -- ) exit the current forth word, and back to the caller\par \\ \b branch\b0 16 bit branch offset follows - \par -2 is to itself, +2 is next word\par \\ \b 0branch\b0 ( t/f -- ) branch it top of stack value is zero \par 16 bit branch offset follows\par \\ \b dothen\b0 \par \\ \b then\b0 \par \\ \b thens\b0 \par \\ \b if \b0 \par \\ \b else\b0 \par \par \b : \b0 ( -- ) : starts definition for name\par \b ; \b0 ( -- ) finish defining name\par \par \\ \b forthentry\b0 ( -- ) marks last entry as a forth word\par \par \\ \b cq\b0 ( -- addr ) returns the address of the counted string following this word \par and increments the IP past it\par \\ \b c" \b0 ( -- c-addr ) compiles the string delimited by ", runtime return the addr \par of the counted string ** valid only in that line\par \par : \b _sp \b0 w, 1 >in W+! 22 parse dup c, dup pad>in here W@ rot cmove dup allot 1+ >in W+! herewal ; \par : \b ."\b0 $H_dq _sp ; immediate\par \par \par \b\fs28 Other\par \b0\fs20\par \i Change Compilation & Interpretation Settings\par \i0\\ \b base\b0 ( -- addr ) access as a word, the address of the base variable\par \\ \b hex \b0 ( -- ) set the base for hexadecimal\par \\ \b decimal\b0 ( -- ) set the base for decimal\par \par \i Comment Introducing Operators\i0\par \\ \b\\\b0 ( -- ) moves the parse pointer >in to the end of the line\par \\ \b\{\b0 ( -- ) discard all the characters between \{ and \}\par Open brace MUST be the first and only character on a new line, the close brace must be on \par another line - does not work in compile mode.\par \\ \b\}\par \b0\\ \b [if \b0 xxx ( -- ) if xxx is defined drop all characters until ], \par [if xxx not have any characters following it on the line\par \par \i word structure\i0\par \\ \b nfa>lfa \b0 ( addr -- addr ) \par go from the nfa (name field address) to the lfa (link field address)\par \\ \b nfa>pfa \b0 ( addr -- addr )\par go from the nfa (name field address) to the pfa (parameter field address)\par \\ \b nfa>next \b0 ( addr -- addr )\par go from the current nfa to the prev nfa in the dictionary\par \\ \b lastnfa\b0 ( -- addr ) gets the last NFA\par \\ \b isnamechar\b0 ( c1 -- t/f ) \par true if c1 is a valif name char > $20 < $7F\par \\ \b _forthpfa>nfa \b0 ( addr -- addr ) \par pfa>nfa for a forth word\par \\ \b _asmpfa>nfa \b0 ( addr -- addr )\par pfa>nfa for an asm word\par \\ \b pfa>nfa \b0 ( addr -- addr ) \par gets the name field address (nfa) for a parameter field address (pfa)\par \\\\\b pfa? \b0 ( addr -- t/f) true if addr is a pfa \par \par \i terminal\i0\par \\\\ \b crcl\b0 ( -- ) cr and clear the line (for an ansi terminal)\par A simple terminal which interfaces to the a channel.\par \\ \b term\b0 ( n1 n2 -- ) n1 - the cog, n2 - the channel number\par \b\fs28\par \b0\i\fs20 misc\b\i0\fs28\par \b0\fs20\\\\ \b lasm\b0 ( addr -- ) expects an address pointing to a structure in the following form\par empty long, long upper address of the assembler routine, long \par lower address of the assembler routine -\par a series of longs which are the assembler codes\par \par \\\\ \b !destination \b0 ( n1 n2 -- n1 ) set the d field of n1 with n2\par \\\\ \b !instruction \b0 ( n1 n2 -- n1 ) set the i field of n1 with n2\par \\\\ \b !source \b0 ( n1 n2 -- n1 ) set the s field of n1 with n2\par \par \par \i \i0 These are temporay variables, and by convention are only used within a word.\par \\ caution, make sure you know what words you are calling\par : \b t0\b0 98 parat ;\par : \b t1\b0 9A parat ;\par : \b tbuf\b0 9C parat ; \\ 0x20 (32) byte array overflows into numpad\par \par \par \\ one fast load at a time\par wvariable \b fl_lock\b0\par wvariable \b fl_in\par \b0\par \\ \b (flout) \b0 ( -- ) attempt to output a character\par \\ \b (fl) \b0 ( --) buffer input and emit\par \\ \b fl\b0 ( -- ) buffer the input and route to a free cog \par \\ \b fstart\b0 ( -- ) the start word ( This word is what the IP is set to on a reboot.)\par \b\fs28\par \b0\fs20\\ \b fisnumber\b0 ( -- ) dummy routine s for indirection when float package is loaded\par \par \\ \b checkdict\b0 ( n -- ) make sure there are at least n bytes available in the dictionary\par \\ \b clabel\b0 ( cstr -- ) create an assembler constant at the current cog coghere\par \par \par \par \\ \b interpretpad\b0 ( -- ) interpret the contents of the pad\par \\ \b interpret \b0 ( -- ) the main interpreter loop\par \\ \b _wc1 \b0 ( x -- nfa ) skip blanks parse the next word and create a constant,\par allocate a word, 2 bytes\par \\ \b >m \b0 ( n1 -- n2 ) produce a 1 bit mask n2 for position n\par \par \par \par \par \b XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\par \par \b0\par \par \par \par \par \par \par \par \par \par \par \par \par \par \par }