I notice that the GreenArrays chips have an opcode called "exec" that swaps the P and R registers.
Are there other tricks that "exec" can do besides slightly improving "execute"?
Brad Eckert <hwfwguy@gmail.com> writes:
I notice that the GreenArrays chips have an opcode called "exec" that swaps the P and R registers.
So in more traditional terms I guess this is:
: exec r> r> swap >r >r ;
Are there other tricks that "exec" can do besides slightly improving
"execute"?
A number of people have used return-address-manipulating words for >implementing control-flow in some form. E.g., I remember Bernd
Paysan's LIST>, which is used like this:
: foo ... ( list ) list> code ;
where CODE is executed once for every element of the list, and that
element is pushed before every time. IIRC he also had a word that
changed the standard output device to stderr, and when the colon
definition ended, the standard output device was changed back. These
days we instead pass an xt (e.g., of a quotation) to a word that
executes the xt: once per stack element in case of the LIST>
replacement, or that changes the user output device, then executes the
xt, then changes it back afterwards.
So while return-address manipulation has a certain cuteness factor, it
can be replaced with standard code, and I guess that's why the
suggestions to standardize it never led to a Forth 200x proposal (I
remember something that was close to what one would expect in such a >proposal, but I think that was before Forth 200x started).
- anton
I notice that the GreenArrays chips have an opcode called "exec" that
swaps the P and R registers. I suppose this is for "execute", which
would be a "push exec" macro. One could just as easily call a word
"execute" whose definition is
: execute push ;
Are there other tricks that "exec" can do besides slightly improving "execute"?
--
Brad
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 300 |
Nodes: | 16 (2 / 14) |
Uptime: | 36:45:25 |
Calls: | 6,707 |
Files: | 12,239 |
Messages: | 5,353,438 |