Skip to content

Vectored I/O, Number modifiers (%, &), Y=TOS, smaller binary size

Compare
Choose a tag to compare
@TG9541 TG9541 released this 20 Dec 21:26
· 851 commits to master since this release

New Features

The release 2.2.2 brings some important changes:

Vectored I/O

New are the words 'EMIT '?KEY that provide vectors for the words ?KEY and the and EMIT, e.g. for background task, but also for text output through the Forth console.

Here is an example for a custom EMIT word:

stm8eForth v2.2
: funEMIT ( c -- ) DUP 64 72 WITHIN -32 * + TX! ;  ( change A..G to lowercase ) ok
' funEMIT 'EMIT ! ok 
words
 funeMIT ReSeT RaM NVM adc` adc! OUT! LOcK ULOcK 2c` 2c! bSR WORdS .S dUMP VaRIabLe dOeS> cReaTe IMMedIaTe : 
caLL, ] ; ." abORT" afT RePeaT WHILe eLSe THeN If agaIN UNTIL begIN +LOOP LOOP dO NeXT fOR LITeRaL c, , aLLOT 
' [ \ ( .( ? . U. TYPe U.R .R cR SPaceS SPace NUf? KeY decIMaL HeX eRaSe fILL cMOVe HeRe 2` 2! +! PIcK 0= abS
 NegaTe NOT 2/ 1- 1+ 2* 2- 2+ */ */MOd M* * UM* / MOd /MOd M/MOd UM/MOd WITHIN MIN MaX < U< = dNegaTe 2dUP RO
T ?dUP fILe HaNd bg TIM -1 1 0 bL OUT '?KeY 'eMIT baSe UM+ - 0< OR aNd XOR + OVeR SWaP dUP >R R` 2dROP dROP I
 R> c! c` ! ` eXecUTe LeaVe TX! eMIT ?RX ?KeY hi 'bOOT cOLd ok

The word '?KEY works similar for ?KEY. Using these words it's even possible to redirect the console to any "device driver"!

Improved NUMBER string conversion

New modifiers that work like $:

  • % for base 2 and
  • & for base 10.

The number strings %-111 and -%111 both result in -7.

Here is an example for valid number strings:

DECIMAL ok
$10 $-10 -$20 20 -20 %1111 -%1111 .S
 16 -16 -32 20 -20 15 -15 <sp  ok
HEX &16 . 10 ok

Significant binary size reduction and coding improvements

  • Code size Refactoring of most core words to Y=TOS, which means that assembly and STC code can be mixed more easily
  • Rewrite of many routines in assembly, new coding method for ( n -- n ) primitives with DOXCODE
  • CORE binary size is below 4 KiB
  • MINDEV binary size is below 5 KiB
  • the size of a binary with a fully linked vocabulary is below 5.5 KiB