In article <tjrfu2$tcc$
[email protected]>, dxforth <
[email protected]> wrote: >On 2/11/2022 12:58 am, Alvaro Gomes Sobral Barcellos wrote:
how better implement BRANCH, by offset or by absolute,
or just use best of ISA ?
If you mean threaded-code, there's probably little reason to use relative. >There was an article in Forth Dimensions V5N2 on absolute branches. It >included the following editorial footnote:
"There is a trade-off between absolute and relative branches. As the author
points out, absolute branches are faster. Relative branches are used in the
FIG model in order to make the LATEST definition relocatable. In practice,
this feature is almost never used (see Schleisiek, FORML-1980. on separated
heads). For most users, speed is probably more valuable. As for BACK, it
is probably good to retain it for uniformity with other systems, even if it
is only a synonym for COMMA." - Michael Perry
IIRC polyFORTH used 8-bit relative branches - presumably to save space.
What is ISA ?
Relative branches make virtually all indirect threaded code relocatable.
This has more advantages, this is an example of an inliner in ciforth.
\ Alias of :, define a word that inlines it code.
: :I CREATE IMMEDIATE ] LATEST HIDDEN !CSP
DOES> STATE @ IF BEGIN $@ DUP '(;) <> WHILE , REPEAT 2DROP
ELSE >R THEN ;
It creates an immediate word that get some code into the body.
When executed it copies the body until an EXIT into the word that is
defined.
These can also be used as a macro,
:I R+! R> + >R ; \ Add something to the return stack.
It is safer than
: R+! "R> + R>" EVALUATE ; IMMEDIATE
With the overhead involved in branching, I don't buy the speed advantage.
Groetjes Albert
--
"in our communism country Viet Nam, people are forced to be
alive and in the western country like US, people are free to
die from Covid 19 lol" duc ha
albert@spe&ar&c.xs4all.nl &=n
http://home.hccnet.nl/a.w.m.van.der.horst
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)