[PicForth] Data table usage and general error tracing ?

Samuel Tardieu sam at rfc1149.net
Tue Jan 20 18:56:15 CET 2004


On 20/01, easlab at absamail.co.za wrote:

| 2 separate problems here.
| 
|  I want to extend my initial picforth program tests/learning by
| accessing a data-array. I read: --
| 
| > New words
| > 
| >      * table,  ftable,  eetable,  table>  and  end-table  allow to create
| >        respectively RAM, flash or EEPROM tables.
| > ...
| > The following words allow you to create tables: 
| >   table      ( "name" -- )        Start a RAM table
| > ...
| >   t,         ( n -- )             Add one byte to the table
| >   table>     ( "b1 .. bn" -- )    Add bytes b1 to bn to the table
| >   end-table  ( -- )               End table declaration
| 
| I try to compile:
| table
|    table> "9 8 7"  \ try also <" 9 8 7 "> ; try also <9,>
| end-table
| 
| Q1. Where is the mistake(s) in my attempted code ?

Two errors:

  1) You didn't include the table name after table
  2) You are not supposed to include the quote (in a Forth
     signature, the quotes indicate that the parsing will
     happen at word execution and that the parameters are
     not to be expected on the stack)

For example, you can do:

  table foobar
    table> 9 8 7
  end-table

  main : main ( -- ) ;

You will see the following snippet of code

0x0005  3007    movlw   0x07
0x0006  00A4    movwf   0x24
0x0007  3008    movlw   0x08
0x0008  00A3    movwf   0x23
0x0009  3009    movlw   0x09
0x000A  00A2    movwf   0x22

indicating the construction of your table at runtime (as this
is a RAM table).

| Q2. How is it possible to capture the error trace to a file ?

Redirect standard error to a pager such as less for example, or
use a bigger terminal.

  Sam



More information about the PicForth mailing list