Here, the constant NANO is true. When the interpreter meets this sequence NANO ?\ PORTB %00100000 defPIN: LED, the part of code after ?\ is processed by the interpreter.
With the word ?\, the final executable code would no longer be cluttered with unusable parts of code.
Whether you are on Arduino NANO or MEGA, we can now test the ignition and extinction of the integrated LED connected to pin 13. Test from the terminal in interpreted mode:
I think a more modern version would use 0= and POSTPONE.
0= always leaves a well formed flag on the stack. INVERT inverts the bits of the cell.
Also the FF optimiser can optimize the 0= away by inverting the machine level conditional statement.
:?\(fl---)0=ifpostpone\
then; immediate
I wonder how difficult it would be to implement [IF][ELSE][THEN] for more advanced conditional compilation ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
The word \ is used to mark the rest of the line as a comment.
The idea is to create a word ?\ which acts as a comment if a false Boolean flag precedes this word. Code of this word:
Here is how this new word can be used:
Here, the constant NANO is true. When the interpreter meets this sequence NANO ?\ PORTB %00100000 defPIN: LED, the part of code after ?\ is processed by the interpreter.
With the word ?\, the final executable code would no longer be cluttered with unusable parts of code.
Whether you are on Arduino NANO or MEGA, we can now test the ignition and extinction of the integrated LED connected to pin 13. Test from the terminal in interpreted mode:
With conditional compilation, you can write FORTH code adaptable to hardware and options available on the various Arduino boards.
Link: https://arduino-forth.com/article/FORTH_FlashForth_development_conditionalCompilation
Last edit: PETREMANN 2020-06-23
Great idea.
I think a more modern version would use 0= and POSTPONE.
0= always leaves a well formed flag on the stack. INVERT inverts the bits of the cell.
Also the FF optimiser can optimize the 0= away by inverting the machine level conditional statement.
I wonder how difficult it would be to implement [IF] [ELSE] [THEN] for more advanced conditional compilation ?
Thanks for this version.
Le mer. 24 juin 2020 à 10:26, Mikael Nordman oh2aun@users.sourceforge.net
a écrit :