From d80736ab6e8e3cad2f1a30c6eaba2d6883dbe967 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sat, 26 Aug 2017 20:31:40 +0200 Subject: Remove AmForth --- amforth-6.5/examples/value-variations.frt | 65 ------------------------------- 1 file changed, 65 deletions(-) delete mode 100644 amforth-6.5/examples/value-variations.frt (limited to 'amforth-6.5/examples/value-variations.frt') diff --git a/amforth-6.5/examples/value-variations.frt b/amforth-6.5/examples/value-variations.frt deleted file mode 100644 index df7ec91..0000000 --- a/amforth-6.5/examples/value-variations.frt +++ /dev/null @@ -1,65 +0,0 @@ -\ This file contains variations of the -\ standard VALUE. in amforth values are -\ stored in EEPROM and occupy 1 cell (2bytes). -\ Calling the name of a value returns this -\ information on the stack. With the command -\ TO this data can be changed. Implementation -\ allows to extend this schema to any data -\ in any memory. - -\ First example is a 1byte value in RAM: - -\ two helper words, -: c@v @i c@ ; -: c!v @i c! ; - -: cvalue ( n "name" -- ) - (value) \ create a new wordlist entry - here , \ the address for the methods - postpone c@v \ method for the read operation - postpone c!v \ method for the write (TO) operation - here 1 allot ! \ allocate the memory and initialize it - ; - -\ $dead cvalue answer will store only the lower byte -\ of the number ($ad). The upper byte is either ignored -\ (TO) or set to 0 - - -\ a buffered value is a value that tolerates heavy write access -\ by using a RAM cell as a cache. - -\ you need to define a trigger, that flushes the cache -\ warm-cache initializes the cache with the stored data -\ (to be called in turnkey and similiar actions) - -\ it is a matter of style whether a sequence should be -\ ' vvv method -\ or -\ method vvv -\ is used. The implementation below goes the first way -\ since parsing words are considered suboptimal by the -\ gurus (they are state smart and less flexible) - -\ 2 is a magic number -: @cache 2 + @i @ ; -: !cache 2 + @i ! ; - -: flush-cache 1+ dup 2 + @i @ swap @i !e ; -: warm-cache 1+ dup @i @e swap 2 + @i ! ; - -: cache-value - (value) - dup ehere dup , dup cell+ to ehere !e - postpone @cache - postpone !cache - here 2 ( 1 cell ) allot dup , ! \ 3 address units, remember? -; - -\ \ test case -\ ehere dup . \ keep the eeprom address -\ 42 cache-value c-dp -\ 17 to c-dp -\ c-dp . dup @e . \ prints 17 and 42 -\ ' c-dp flush-cache -\ c-dp . dup @e . \ prints 17 and 17 -- cgit v1.2.3