Sujet : Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]
De : dxforth (at) *nospam* gmail.com (dxf)
Groupes : comp.lang.forthDate : 16. Sep 2024, 13:47:10
Autres entêtes
Organisation : Ausics - https://newsgroups.ausics.net
Message-ID : <66e828ce$1@news.ausics.net>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
User-Agent : Mozilla Thunderbird
On 16/09/2024 8:13 pm, mhx wrote:
[..]
FORTH> tnb
\ no locals: 5ns/call.
\ locals: 18.2ns/call.
\ globals: 6ns/call.
\ no locals2: 21.9ns/call. ok
This appears not to be a good idea.
The root cause is piling up too many
items on the F-stack (exceeding the
hardware FPU stack limits).
FVALUEs may be the way to go for hardware stack.
Is this any better?
: tri_mf ( f: x a b c -- mv)
3 fpick ( x) 3 fpick ( x a) f>=
3 fpick ( x) 2 fpick ( x b) f< and if
fdrop \ x a b
frot 2 fpick f- \ a b x-a
fswap frot f- \ x-a b-a
f/ exit
then
3 fpick ( x) 2 fpick ( x b) f>=
3 fpick ( x) 1 fpick ( x c) f< and if
frot fdrop \ x b c
frot fover fswap f- \ b c c-x
fswap frot f- \ c-x c-b
f/ exit
then
fdrop fdrop fdrop fdrop 0e
;