Re: using MISC (post 1987 Forth hardware) opcodes
- From: John Doty <jpd@xxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 10 Jul 2006 12:09:18 -0600
Bernd Paysan wrote:
Jeff Fox wrote:
Thanks for the overview.
But it may be important to note that it is not the same as null
just as the non-destructive IF is not the same as DUP IF
because DUP is destructive.
Yes, that's obvious. That means you can't use DUP IF if you have a full
stack and want to branch on the top of stack element. That's the up side:
you save one stack element. The cost is that you lose the destructive IF,
and you need to DROP the flags when you don't need them (maybe it's my
programming style, but that's the majority). Finally, on my code, the
coincidence of having a DUP IF and a full stack at the same time was zero,
so I reverted to a destructive IF in the two b16 variants that are used in
our products.
Have either of you guys considered a flag *register* rather than a flag in the stack? I think it has some serious advantages.
1. You don't have to worry about either DUP or DROP of flags: the flag persists until the next test.
2. Explicit arithmetic with flag values is relatively rare, and "short-circuit evaluation" is often a good (and more efficient!) substitute anyway.
3. A persistent flag register makes it easy to return success or failure up through several levels of code, handling it appropritely at each level without stack gymnastics.
Nondestructive IF seems to me to fight with the stack data flow: it leaves the flag blocking your other operands so you're almost always going to need stack gymnastics immediately after. But the need to reuse the flag is fairly common in my code, so a register allows me to have my cake and eat it too. The thing I hardly ever want is a stack of flags: one at a time is usually enough.
--
---
John Doty, Noqsi Aerospace, Ltd.
---
His diagnosis of the hostility ... reflects the willful blindness of the invader who assures himself that the natives are only made unfriendly by some other provocation than his own. -Barbara W. Tuchman
.
- Follow-Ups:
- Re: using MISC (post 1987 Forth hardware) opcodes
- From: Jeff Fox
- Re: using MISC (post 1987 Forth hardware) opcodes
- From: Jerry Avins
- Re: using MISC (post 1987 Forth hardware) opcodes
- References:
- using MISC (post 1987 Forth hardware) opcodes
- From: Jeff Fox
- Re: using MISC (post 1987 Forth hardware) opcodes
- From: Bernd Paysan
- using MISC (post 1987 Forth hardware) opcodes
- Prev by Date: Re: SEAforth Instruction Set
- Next by Date: Re: SEAforth Instruction Set
- Previous by thread: Re: using MISC (post 1987 Forth hardware) opcodes
- Next by thread: Re: using MISC (post 1987 Forth hardware) opcodes
- Index(es):
Relevant Pages
|
Loading