From 67d25d837ac55f28a366c0a3b262e439a6e75fc3 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sat, 19 Aug 2017 12:15:28 +0200 Subject: Add AmForth --- amforth-6.5/msp430/lib/forth-2012/core-ext.frt | 12 ++++++++++ .../msp430/lib/forth-2012/core-ext/marker.frt | 3 +++ amforth-6.5/msp430/lib/forth-2012/core.frt | 21 ++++++++++++++++ amforth-6.5/msp430/lib/forth-2012/core/c-comma.frt | 5 ++++ .../msp430/lib/forth-2012/core/environment-q.frt | 28 ++++++++++++++++++++++ .../msp430/lib/forth-2012/core/evaluate.frt | 22 +++++++++++++++++ .../msp430/lib/forth-2012/core/star-slash-mod.frt | 6 +++++ amforth-6.5/msp430/lib/forth-2012/core/value.frt | 9 +++++++ .../msp430/lib/forth-2012/double/d-invert.frt | 4 ++++ amforth-6.5/msp430/lib/int-q.frt | 3 +++ amforth-6.5/msp430/lib/run-hayes.frt | 26 ++++++++++++++++++++ 11 files changed, 139 insertions(+) create mode 100644 amforth-6.5/msp430/lib/forth-2012/core-ext.frt create mode 100644 amforth-6.5/msp430/lib/forth-2012/core-ext/marker.frt create mode 100644 amforth-6.5/msp430/lib/forth-2012/core.frt create mode 100644 amforth-6.5/msp430/lib/forth-2012/core/c-comma.frt create mode 100644 amforth-6.5/msp430/lib/forth-2012/core/environment-q.frt create mode 100644 amforth-6.5/msp430/lib/forth-2012/core/evaluate.frt create mode 100644 amforth-6.5/msp430/lib/forth-2012/core/star-slash-mod.frt create mode 100644 amforth-6.5/msp430/lib/forth-2012/core/value.frt create mode 100644 amforth-6.5/msp430/lib/forth-2012/double/d-invert.frt create mode 100644 amforth-6.5/msp430/lib/int-q.frt create mode 100644 amforth-6.5/msp430/lib/run-hayes.frt (limited to 'amforth-6.5/msp430/lib') diff --git a/amforth-6.5/msp430/lib/forth-2012/core-ext.frt b/amforth-6.5/msp430/lib/forth-2012/core-ext.frt new file mode 100644 index 0000000..a7ea6d6 --- /dev/null +++ b/amforth-6.5/msp430/lib/forth-2012/core-ext.frt @@ -0,0 +1,12 @@ +\ 'core-ext.frt' generated automatically, do not edit +#include case.frt +\ #include case-test.frt +\ #include exceptions.frt +#include marker.frt +\ #include 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/msp430/lib/forth-2012/core-ext/marker.frt b/amforth-6.5/msp430/lib/forth-2012/core-ext/marker.frt new file mode 100644 index 0000000..b4e47d3 --- /dev/null +++ b/amforth-6.5/msp430/lib/forth-2012/core-ext/marker.frt @@ -0,0 +1,3 @@ + +\ dummy marker +: marker create ; \ No newline at end of file diff --git a/amforth-6.5/msp430/lib/forth-2012/core.frt b/amforth-6.5/msp430/lib/forth-2012/core.frt new file mode 100644 index 0000000..f838dfc --- /dev/null +++ b/amforth-6.5/msp430/lib/forth-2012/core.frt @@ -0,0 +1,21 @@ +\ 'core.frt' generated automatically, do not edit +#include 2over.frt +#include 2swap.frt +#include blank.frt +#include c-comma.frt +#include char-plus.frt +#include chars.frt +#include dot-paren.frt +#include environment-q.frt +#include erase.frt +#include evaluate.frt +#include star-slash.frt +#include move.frt +#include source-id.frt +#include 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/msp430/lib/forth-2012/core/c-comma.frt b/amforth-6.5/msp430/lib/forth-2012/core/c-comma.frt new file mode 100644 index 0000000..8741509 --- /dev/null +++ b/amforth-6.5/msp430/lib/forth-2012/core/c-comma.frt @@ -0,0 +1,5 @@ + +\ only a dummy file for certain use cases like +\ the hayes tester. The actual definition is +\ already in the words/ directory + diff --git a/amforth-6.5/msp430/lib/forth-2012/core/environment-q.frt b/amforth-6.5/msp430/lib/forth-2012/core/environment-q.frt new file mode 100644 index 0000000..3ba440f --- /dev/null +++ b/amforth-6.5/msp430/lib/forth-2012/core/environment-q.frt @@ -0,0 +1,28 @@ +\ environment queries are placed in a +\ separate wordlist. + +: environment? \ addr len -- 0|x*i -1 + environment search-wordlist dup + if >r execute r> then +; + +\ 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/msp430/lib/forth-2012/core/evaluate.frt b/amforth-6.5/msp430/lib/forth-2012/core/evaluate.frt new file mode 100644 index 0000000..9f4cf3b --- /dev/null +++ b/amforth-6.5/msp430/lib/forth-2012/core/evaluate.frt @@ -0,0 +1,22 @@ +\ evaluate +\ temporarily redirect the input source +\ to string buffer. Return the the previous +\ input source afterwards and continue + +\ some helper words +variable strlen +variable str +: source-string str @ strlen @ ; + +: evaluate \ i*x addr len -- j*y + ['] source defer@ >r + >in @ >r + 0 >in ! + strlen ! + str ! + ['] source-string to source + ['] interpret catch + r> >in ! + r> to source + throw +; diff --git a/amforth-6.5/msp430/lib/forth-2012/core/star-slash-mod.frt b/amforth-6.5/msp430/lib/forth-2012/core/star-slash-mod.frt new file mode 100644 index 0000000..741b4cd --- /dev/null +++ b/amforth-6.5/msp430/lib/forth-2012/core/star-slash-mod.frt @@ -0,0 +1,6 @@ + +\ MSP has another division type + +: */mod ( ) + >r m* r> fm/mod +; diff --git a/amforth-6.5/msp430/lib/forth-2012/core/value.frt b/amforth-6.5/msp430/lib/forth-2012/core/value.frt new file mode 100644 index 0000000..41a7e70 --- /dev/null +++ b/amforth-6.5/msp430/lib/forth-2012/core/value.frt @@ -0,0 +1,9 @@ +\ the value (in RAM) + +: value ( n -- ) + (value) + here , \ compile the RAM address + ['] @ , + ['] ! , + here ! 2 allot +; diff --git a/amforth-6.5/msp430/lib/forth-2012/double/d-invert.frt b/amforth-6.5/msp430/lib/forth-2012/double/d-invert.frt new file mode 100644 index 0000000..c951d59 --- /dev/null +++ b/amforth-6.5/msp430/lib/forth-2012/double/d-invert.frt @@ -0,0 +1,4 @@ + +: dinvert + swap invert swap invert +; diff --git a/amforth-6.5/msp430/lib/int-q.frt b/amforth-6.5/msp430/lib/int-q.frt new file mode 100644 index 0000000..828562e --- /dev/null +++ b/amforth-6.5/msp430/lib/int-q.frt @@ -0,0 +1,3 @@ + +\ get the GIE flag from status register +: int? sr@ 8 and 0> ; diff --git a/amforth-6.5/msp430/lib/run-hayes.frt b/amforth-6.5/msp430/lib/run-hayes.frt new file mode 100644 index 0000000..c586e95 --- /dev/null +++ b/amforth-6.5/msp430/lib/run-hayes.frt @@ -0,0 +1,26 @@ +\ +\ process this file with amforth-upload.py and +\ the proper setting of $AMFORTH_LIB (basedir of +\ you amforth file tree) +\ WIN (untested, DOS Box) +\ cd c:\amforth-x.y +\ set AMFORTH_LIB=c:\amforth-x.y +\ python tools\amforth-upload.py -t com1: examples\run-hayes.frt +\ UNIX / MAC (Terminal) +\ cd $HOME/amforth-x.y +\ export AMFORTH_LIB=$HOME/amforth-x.y +\ tools/amforth-upload.py -t /dev/ttyUSB0 examples/run-hayes.frt +\ enjoy! +\ +\ it is meant to be run on a newly flashed +\ controller, e.g. all the dict_* are included +\ + +\ include all sources +#include core.frt +#include double.frt +#include marker.frt +#include tester-amforth.frt +\ and finally run all the tests + +#include core.fr -- cgit v1.2.3