mikaelpatel / arduino-fvm Goto Github PK
View Code? Open in Web Editor NEWByte Token Threaded Forth Virtual Machine (FVM) for Arduino
Home Page: https://mikaelpatel.github.io/Arduino-FVM
Byte Token Threaded Forth Virtual Machine (FVM) for Arduino
Home Page: https://mikaelpatel.github.io/Arduino-FVM
This issue is a list of missing words (Forth94 Core).
' NAME ( -- xt )
['] NAME ( -- xt )
unloop ( -- )
*/mod ( n1 n2 n3 -- n4 n5 )
2! ( x1 x2 a-addr -- )
2@ ( a-addr -- x1 x2 )
2>r ( x1 x2 -- )
2r> ( -- x1 x2 )
2r@ ( -- x1 x2 )
cell+ ( a-addr1 -- a-addr2 )
count ( c-addr1 -- c-addr2 u )
c>s ( c-char -- n )
fill ( c-addr u char -- )
fm/mod ( d1 n1 -- n2 n3 )
m* ( n1 n2 -- d )
um* ( u1 u2 -- ud )
um/mod ( ud u1 -- u2 u3 )
scan => word ( char -- )
compile NAME => postpone NAME
lookup => find ( c-addr -- c-addr 0 | xt 1 | xt -1 )
>number ( ... )
:noname ( -- xt )
marker NAME ( -- )
value NAME ( x -- )
[compile] NAME
Support 32-bit MCU based on ARM core such as Arduino Due. These have the advantage of much more memory and allow symmetrical memory model (i.e. data structures in RAM).
Add virtual machine instruction to allow call of C/C++ function. Use same structure as for CREATE-DOES>, VARIABLE and CONSTANT.
Performance optimization: jump to function instead of call, avoid exit to exit return. See also https://en.wikipedia.org/wiki/Tail_call.
The AVR is a Harvard Architecture with separate memory spaces (SRAM, EEMEM, PROGMEM). To allows threaded code in all memory spaces a synthetic unified address spaces is needed. This will impose a run-time penalty on the inner interpreter and any operation that access the instruction pointer, i.e. branch, literals, etc.
This project looks like it could be useful - what license are you using?
tos is pushed and poped from parameter stack on context switch. ip is not, it is stored in the context struct, but should for symmetry be also pushed and poped from the return stack.
The current token mapping allows for at most 128 kernel and 128 application words. Byte positive values (0..127) are for kernel implementation and negative (-128..-1) for application.
The screenshots in the README have broken links.
/home/ga/Arduino/sketches/libraries/FVM/src/FVM.cpp: In function 'int8_t fetch_byte(FVM::code_P)':
/home/ga/Arduino/sketches/libraries/FVM/src/FVM.cpp:105:31: internal compiler error: in type_hash_canon, at tree.c:7158
if (ip < (FVM::code_P) FVM::CODE_P_MAX)
^~~~~~~~~~
Please submit a full bug report,
The bug has been logged with GCC: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94437
In the meantime, I have a patch available to work around it.
Arduino have defined a new architecture, megaavr, for the ATmega4809 chip on this board.
There are some minor code changes needed to make it work. Patch available.
Allow the scanner to be configured to echo all characters read during the parsing of a word.
Compile forth statements to virtual machine instructions (in C++).
Use the Compiler to generate code for some of the example sketches, i.e. Blink.
The VM is byte coded and allows for 256 tokens. The inner interpreter uses signed byte to determine if the token is executed direct (C++) or threaded call. To extend two special tokens are used. These allow the token value to exceed -128..127.
Kernel tokens are 0..127 direct, 128..255 extended.
User tokens are 256..383 direct (mapped to -1..-128), 384..511 extended.
The token space is not continues. There exists illegal tokens that needs to be captured.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.