aboutsummaryrefslogtreecommitdiff
path: root/amforth-6.5/avr8/lib/forth2012/core
diff options
context:
space:
mode:
Diffstat (limited to 'amforth-6.5/avr8/lib/forth2012/core')
-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
10 files changed, 168 insertions, 0 deletions
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 ;