From: Erich W. <ew....@na...> - 2013-06-10 10:09:38
|
Hello, On 06/10/2013 10:01 AM, Wojciech Zabołotny wrote: > Hi, > > If I want to extend the standard dictionary with some words defined by me, is it possible to compile them on PC so, that when ATmega is programmed, my words are already available? > I simply want to avoid relatively lengthy process of adding the new definitions after programming (and minimize the EEPROM usage, as it is rewritten, whenever new word is defined ;-) ) > I know, that I can do it defining the new words in assembler, but the syntax is not very easy to read and write... > is there any better solution? > There is a little gforth tool at http://www.forth-ev.de/repos/g4/ if you feed amforth source code to it, it will produce the equivalent .asm code in the same style as most of the words/*.asm file look. "value" is not supported at the moment, maybe more. But it should be possible to fix g4.fs accordingly. Another option to "reprogram the controller to a known state" is this: . put amforth onto the controller . add whatever words you want . read the flash/eeprom state back to your PC use these files to reprogramm. See makefile for appropriate targets. Cheers, Erich ew@metis:~/Forth 2 > gforth g4.fs ; g4 macro definitions: <0> ; g4 version #31 ; some alias <0> ; label ; headers <0> ; compiling words <0> user:<4> 0 -149508408 -149508392 0 user:<4> 0 -149508408 -149508392 0 ; some state smart words ; g4 macro compiler ; control structures <0> ; exceptions utils <0> ; Simple words <0> ; _: to _cr _." .dw XT_TO " _; does not work this way ; added more words ; finis ; Items on stack: <0> mk 10. 6.2013 11:44:25 Gforth 0.6.2-20060527, Copyright (C) 1995-2006 Free Software Foundation, Inc. Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license' Type `bye' to exit variable N ; defining a variable: VE_N: .dw $FF01 .db "N",0 .dw VE_HEAD .set VE_HEAD = VE_N XT_N: .dw PFA_DOVARIABLE PFA_N: .dw heap .set heap = heap + CELLSIZE ok : N+ ( -- ) 1 N +! VE_N+: .dw $FF02 .db "N+" .dw VE_HEAD .set VE_HEAD = VE_N+ XT_N+: .dw DO_COLON PFA_N+: ; ( -- ) .dw XT_DOLITERAL .dw $1 .dw XT_N .dw XT_PLUSSTORE _] bye |