aboutsummaryrefslogtreecommitdiff
path: root/amforth-6.5/avr8/lib/forth2012
diff options
context:
space:
mode:
Diffstat (limited to 'amforth-6.5/avr8/lib/forth2012')
-rw-r--r--amforth-6.5/avr8/lib/forth2012/core-ext.frt13
-rw-r--r--amforth-6.5/avr8/lib/forth2012/core-ext/avr-defers.frt20
-rw-r--r--amforth-6.5/avr8/lib/forth2012/core-ext/marker-test.frt18
-rw-r--r--amforth-6.5/avr8/lib/forth2012/core-ext/marker.frt23
-rw-r--r--amforth-6.5/avr8/lib/forth2012/core.frt26
-rw-r--r--amforth-6.5/avr8/lib/forth2012/core/align.frt3
-rw-r--r--amforth-6.5/avr8/lib/forth2012/core/aligned.frt3
-rw-r--r--amforth-6.5/avr8/lib/forth2012/core/avr-values.frt11
-rw-r--r--amforth-6.5/avr8/lib/forth2012/core/c-comma.frt3
-rw-r--r--amforth-6.5/avr8/lib/forth2012/core/eeprom-buffer.frt15
-rw-r--r--amforth-6.5/avr8/lib/forth2012/core/environment-q.frt53
-rw-r--r--amforth-6.5/avr8/lib/forth2012/core/evaluate.frt46
-rw-r--r--amforth-6.5/avr8/lib/forth2012/core/fm-slash-mod.frt22
-rw-r--r--amforth-6.5/avr8/lib/forth2012/core/sm-slash-rem.frt8
-rw-r--r--amforth-6.5/avr8/lib/forth2012/core/star-slash-mod.frt4
15 files changed, 268 insertions, 0 deletions
diff --git a/amforth-6.5/avr8/lib/forth2012/core-ext.frt b/amforth-6.5/avr8/lib/forth2012/core-ext.frt
new file mode 100644
index 0000000..7e16121
--- /dev/null
+++ b/amforth-6.5/avr8/lib/forth2012/core-ext.frt
@@ -0,0 +1,13 @@
+\ 'core-ext.frt' generated automatically, do not edit
+#require case.frt
+\ #require case-test.frt
+#require compile-comma.frt
+\ #require exceptions.frt
+#require marker.frt
+\ #require marker-test.frt
+
+\ update the environment
+\ get-current environment set-current
+\ : core-ext 0 ;
+\ reset the definition word list
+\ set-current
diff --git a/amforth-6.5/avr8/lib/forth2012/core-ext/avr-defers.frt b/amforth-6.5/avr8/lib/forth2012/core-ext/avr-defers.frt
new file mode 100644
index 0000000..0421ab3
--- /dev/null
+++ b/amforth-6.5/avr8/lib/forth2012/core-ext/avr-defers.frt
@@ -0,0 +1,20 @@
+\ the following code works in the AVR only
+
+\ use the eeprom to keep the XT. Unlike the RAM/USER
+\ based locations, the EEPROM vector is available without
+\ initialization.
+: Edefer ( "name" -- )
+ (defer)
+ ehere dup ,
+ ['] Edefer@ ,
+ ['] Edefer! ,
+ cell+ to ehere
+;
+
+\ the flash is writable, not that often, but it is
+: Idefer ( "name" -- )
+ (defer)
+ ['] noop , \ a dummy action as place holder
+ [: @i execute ;] , \ XT is directly in the dictionary.
+ [: !i ;] ,
+;
diff --git a/amforth-6.5/avr8/lib/forth2012/core-ext/marker-test.frt b/amforth-6.5/avr8/lib/forth2012/core-ext/marker-test.frt
new file mode 100644
index 0000000..3a7c9b0
--- /dev/null
+++ b/amforth-6.5/avr8/lib/forth2012/core-ext/marker-test.frt
@@ -0,0 +1,18 @@
+#include dumper.frt
+#include order.frt
+#include marker.frt
+
+wordlist constant test-wl
+get-order test-wl swap 1+ set-order
+order
+marker empty
+
+' empty 4 - 10 idump
+
+: hallo ." Hallo " ;
+
+order
+words
+empty
+words
+order
diff --git a/amforth-6.5/avr8/lib/forth2012/core-ext/marker.frt b/amforth-6.5/avr8/lib/forth2012/core-ext/marker.frt
new file mode 100644
index 0000000..8d5756b
--- /dev/null
+++ b/amforth-6.5/avr8/lib/forth2012/core-ext/marker.frt
@@ -0,0 +1,23 @@
+\ Defines a word which resets the dictionary and removes itself
+\ when called.
+\ Better then forget but still has limitations.
+
+\ all information is in the first few EEPROM cells.
+\ (marker) is a value that holds the max eeprom address
+
+: marker
+ \ get information to remove the marker itself
+ get-current @e dp
+ \ create the wordlist entry
+ create
+ \ save all data
+ (marker) 0 do i @e , 2 +loop
+ \ save the marker-remove data
+ , ,
+ does>
+ \ restore data from saved state
+ (marker) 0 do dup @i i !e 1+ 2 +loop
+ \ purge the marker itself
+ dup @i to dp
+ 1+ @i get-current !e
+;
diff --git a/amforth-6.5/avr8/lib/forth2012/core.frt b/amforth-6.5/avr8/lib/forth2012/core.frt
new file mode 100644
index 0000000..5db1994
--- /dev/null
+++ b/amforth-6.5/avr8/lib/forth2012/core.frt
@@ -0,0 +1,26 @@
+\ 'core.frt' generated automatically, do not edit
+#require 2over.frt
+#require 2swap.frt
+#require aligned.frt
+#require align.frt
+#require blank.frt
+#require c-comma.frt
+#require char-plus.frt
+#require chars.frt
+#require dot-paren.frt
+#require environment-q.frt
+#require erase.frt
+#require evaluate.frt
+#require fm-slash-mod.frt
+#require star-slash.frt
+#require move.frt
+
+#require sm-slash-rem.frt
+#require source-id.frt
+#require find.frt
+
+\ update the environment
+get-current environment set-current
+: core -1 ;
+\ reset the definition word list
+set-current
diff --git a/amforth-6.5/avr8/lib/forth2012/core/align.frt b/amforth-6.5/avr8/lib/forth2012/core/align.frt
new file mode 100644
index 0000000..e68f679
--- /dev/null
+++ b/amforth-6.5/avr8/lib/forth2012/core/align.frt
@@ -0,0 +1,3 @@
+\ atmega's are always aligned
+: align ;
+
diff --git a/amforth-6.5/avr8/lib/forth2012/core/aligned.frt b/amforth-6.5/avr8/lib/forth2012/core/aligned.frt
new file mode 100644
index 0000000..f2b942a
--- /dev/null
+++ b/amforth-6.5/avr8/lib/forth2012/core/aligned.frt
@@ -0,0 +1,3 @@
+\ atmega's are always aligned
+: aligned ;
+
diff --git a/amforth-6.5/avr8/lib/forth2012/core/avr-values.frt b/amforth-6.5/avr8/lib/forth2012/core/avr-values.frt
new file mode 100644
index 0000000..a23d0be
--- /dev/null
+++ b/amforth-6.5/avr8/lib/forth2012/core/avr-values.frt
@@ -0,0 +1,11 @@
+
+
+\ EEPROM based values
+
+: Evalue ( n -- )
+ (value)
+ ehere ,
+ ['] Edefer@ ,
+ ['] Edefer! ,
+ ehere dup cell+ to ehere !e
+;
diff --git a/amforth-6.5/avr8/lib/forth2012/core/c-comma.frt b/amforth-6.5/avr8/lib/forth2012/core/c-comma.frt
new file mode 100644
index 0000000..2c4e678
--- /dev/null
+++ b/amforth-6.5/avr8/lib/forth2012/core/c-comma.frt
@@ -0,0 +1,3 @@
+\ a character occupies a full flash cell
+: c, , ;
+
diff --git a/amforth-6.5/avr8/lib/forth2012/core/eeprom-buffer.frt b/amforth-6.5/avr8/lib/forth2012/core/eeprom-buffer.frt
new file mode 100644
index 0000000..5cb2ceb
--- /dev/null
+++ b/amforth-6.5/avr8/lib/forth2012/core/eeprom-buffer.frt
@@ -0,0 +1,15 @@
+\ internal EEPROM routines. They do not operate on external
+\ storage
+
+\ Ebuffer: is the EEPROM pendant to buffer: from forth200x
+\ it takes the number of bytes to allocate in RAM and parses
+\ SOURCE for the name to give to the buffer
+
+\ Eallot is the EEPROM pendant for allot from the core word set
+\ it allocates n bytes of EEPROM storage and return the starting
+\ address.
+
+: Eallot ehere + to ehere ;
+: Ebuffer: ehere constant Eallot ;
+
+\ for usage see http://amforth.sourceforge.net/TG/recipes/EEPROM.html
diff --git a/amforth-6.5/avr8/lib/forth2012/core/environment-q.frt b/amforth-6.5/avr8/lib/forth2012/core/environment-q.frt
new file mode 100644
index 0000000..e16428d
--- /dev/null
+++ b/amforth-6.5/avr8/lib/forth2012/core/environment-q.frt
@@ -0,0 +1,53 @@
+\ environment queries are placed in a
+\ separate wordlist.
+
+\ #require imove.frt
+
+\ we have to distinguish between interpreted (RAM)
+\ and compiled (Flash) strings. First the RAM
+\ strings
+
+: (environment?) \ addr len -- 0|x*i -1
+ environment search-wordlist dup
+ if >r execute r> then
+;
+
+
+\ the compiled (Flash) strings are transferred
+\ to RAM and this copy processed afterwards.
+: [environment?]
+ ( iaddr len -- )
+ dup >r
+ here imove
+ here r> (environment?)
+;
+
+\ a state smart word to decide what to do.
+: environment?
+ state @ if
+ postpone [environment?]
+ else
+ (environment?)
+ then
+; immediate
+
+\ some environment queries
+
+\ save the definitions word list for this file
+\ and switch to the environment queries wordlist
+get-current environment set-current
+
+: /counted-strings &60 ;
+: floored 0 ;
+: address-unit-bits $10 ;
+: max-char $ff ;
+: max-d $7fffffff. ;
+: max-ud $ffffffff. ;
+: max-n $7fff ;
+: max-u $ffff ;
+
+: return-stack-cells &10 ;
+: stack-cells &10 ;
+
+\ reset the definition word list
+set-current
diff --git a/amforth-6.5/avr8/lib/forth2012/core/evaluate.frt b/amforth-6.5/avr8/lib/forth2012/core/evaluate.frt
new file mode 100644
index 0000000..80659bc
--- /dev/null
+++ b/amforth-6.5/avr8/lib/forth2012/core/evaluate.frt
@@ -0,0 +1,46 @@
+\ evaluate
+\ temporarily redirect the input source
+\ to string buffer. Return the the previous
+\ input source afterwards and continue
+
+\ #require imove.frt
+
+\ some helper words
+variable strlen
+variable str
+: source-string str @ strlen @ ;
+
+\ we have to distinguish between interpreted (RAM)
+\ and compiled (Flash) strings. First the RAM
+\ strings
+
+: (evaluate) \ i*x addr len -- j*y
+ ['] source defer@ >r
+ >in @ >r
+ 0 >in !
+ strlen !
+ str !
+ ['] source-string is source
+ ['] interpret catch
+ r> >in !
+ r> is source
+ throw
+;
+
+\ the compiled (Flash) strings are transferred
+\ to RAM and processed there.
+: [evaluate]
+ ( iaddr len -- )
+ dup >r
+ here imove
+ here r> (evaluate)
+;
+
+\ a state smart word to decide what to do.
+: evaluate
+ state @ if
+ postpone [evaluate]
+ else
+ (evaluate)
+ then
+; immediate
diff --git a/amforth-6.5/avr8/lib/forth2012/core/fm-slash-mod.frt b/amforth-6.5/avr8/lib/forth2012/core/fm-slash-mod.frt
new file mode 100644
index 0000000..dfb10e9
--- /dev/null
+++ b/amforth-6.5/avr8/lib/forth2012/core/fm-slash-mod.frt
@@ -0,0 +1,22 @@
+
+
+: fm/mod ( d1 n1 -- n2 n3 )
+ dup >r
+ 2dup xor >r
+ >r
+ dabs r@ abs um/mod
+ swap r> ?negate swap
+ r> 0< if
+ negate
+ over if
+ r@ rot - swap 1-
+ then
+ then
+ r> drop
+;
+
+\ alternative solution
+\
+\ : FM/MOD \ ( d m -- r q ) signed floored division
+\ DUP >R SM/REM 2DUP 0< AND IF 1- SWAP R> + SWAP ELSE R> DROP THEN ;
+\ \ No newline at end of file
diff --git a/amforth-6.5/avr8/lib/forth2012/core/sm-slash-rem.frt b/amforth-6.5/avr8/lib/forth2012/core/sm-slash-rem.frt
new file mode 100644
index 0000000..baf07cf
--- /dev/null
+++ b/amforth-6.5/avr8/lib/forth2012/core/sm-slash-rem.frt
@@ -0,0 +1,8 @@
+
+: sm/rem ( d1 n1 -- n2 n3 )
+ 2dup xor >r
+ over >r
+ abs >r dabs r> um/mod
+ swap r> ?negate
+ swap r> ?negate
+;
diff --git a/amforth-6.5/avr8/lib/forth2012/core/star-slash-mod.frt b/amforth-6.5/avr8/lib/forth2012/core/star-slash-mod.frt
new file mode 100644
index 0000000..9d47a61
--- /dev/null
+++ b/amforth-6.5/avr8/lib/forth2012/core/star-slash-mod.frt
@@ -0,0 +1,4 @@
+
+\ #require sm-slash-rem.frt
+
+: */mod >r m* r> sm/rem ;