Re: defered word options
- From: stephenXXX@xxxxxxxxxxxx (Stephen Pelc)
- Date: Sat, 24 Nov 2007 17:47:42 GMT
On Fri, 23 Nov 2007 11:48:14 -0800 (PST), foxchip
<fox@xxxxxxxxxxxxxxxxxxx> wrote:
Nested decsions trees may introduce the greatest overhead.
Traditional Forth code might look like outside the loop:
VARIABLE 'FUNCTION
' MYFUCTION 'FUNCTION !
and inside the loop
'FUNCTION @ PUSH ;
Portable ANSI Forth cannot rely on the existence of an
actual return stack and has added a layer of abstraction:
'FUNCTION @ EXECUTE
(some systems provide an @EXECUTE function similar to
the operation of the machineforth sequence
IF PUSH ; THEN DROP ;
DEFERed words are not part of the standard but are
common practice. Similar to the traditional style
'FUNCTION @EXECUTE
in their implementation they are often used with syntax
' MYFUCTION IS THEFUNCTION
I have argued for many years that the most efficient
implementation of defered words is simply a jump opcode.
It is of course an example of using self-modifying code
to implement DEFER.
DEFER FOO
: t ... FOO ... ;
Are you are talking about the implementation of FOO or the
code laid by referencing FOO ? If the latter, it's really
architecture dependent. On the i32, 68k and MSP430
architectures and other CISC machines it often just reduces
to an indirect call.
defer foo ok
: t ... foo ... ; ok
dis t
T
....
( FF1510AA4A00 ) CALL [004AAA10] FOO
....
( C3 ) NEXT,
ok
variable poo ok
: t2 ... poo @ execute ... ; ok
dis t2
T2
....
( 004AAA80 FF1560AA4A00 ) CALL [004AAA60] POO
....
( 004AAA86 C3 ) NEXT,
ok
The code density vs speed tradeoff is also dependent on CPU and
memory architecture, as well as on application demands.
Stephen
--
Stephen Pelc, stephenXXX@xxxxxxxxxxxx
MicroProcessor Engineering Ltd - More Real, Less Time
133 Hill Lane, Southampton SO15 5AF, England
tel: +44 (0)23 8063 1441, fax: +44 (0)23 8033 9691
web: http://www.mpeforth.com - free VFX Forth downloads
.
- Follow-Ups:
- Re: defered word options
- From: foxchip
- Re: defered word options
- References:
- defered word options
- From: foxchip
- defered word options
- Prev by Date: Re: defered word options
- Next by Date: Re: defered word options
- Previous by thread: Re: defered word options
- Next by thread: Re: defered word options
- Index(es):
Relevant Pages
|