| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| hi : 0 DUP DUP XOR ; : -1 0 NOT ; any more? just as a code compaction exercise. |
|
#2
| |||
| |||
| jacko wrote: > hi > > : 0 DUP DUP XOR ; Fails when the stack is empty and the implementation has no guard cell. > : -1 0 NOT ; > > any more? just as a code compaction exercise. Jerry -- Engineering is the art of making what you want from things you can get. ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ |
|
#3
| |||
| |||
| On Aug 4, 11:43 am, Jerry Avins <j...@ieee.org> wrote: > jacko wrote: > > hi > > > : 0 DUP DUP XOR ; > > Fails when the stack is empty and the implementation has no guard cell. This will only fail if the stack is designed to make it fail. The way some implement stacks, there is no top or bottom and duping an "empty" stack will produce a valid result for this case. However, I don't see the purpose of defining 0 this way. A means has to be provided for arbitrary literals and there is no reason that 0 can't be one of these. My understanding is this exercise is a way to minimize the instruction set. How does defining 0 and -1 this way save op codes? Rick |
|
#4
| |||
| |||
| On 4 Aug, 16:54, rickman <gnu...@gmail.com> wrote: > On Aug 4, 11:43 am, Jerry Avins <j...@ieee.org> wrote: > > > jacko wrote: > > > hi > > > > : 0 DUP DUP XOR ; > > > Fails when the stack is empty and the implementation has no guard cell. > > This will only fail if the stack is designed to make it fail. *The way > some implement stacks, there is no top or bottom and duping an "empty" > stack will produce a valid result for this case. > > However, I don't see the purpose of defining 0 this way. *A means has > to be provided for arbitrary literals and there is no reason that 0 > can't be one of these. *My understanding is this exercise is a way to > minimize the instruction set. *How does defining 0 and -1 this way > save op codes? > > Rick It doesn't really. as LIT val EXIT is three cells for any literal to compact into 1 word to call by xt. Does make me wonder about how an auto LIT compactor may work though. cheers jacko |
|
#5
| |||
| |||
| On Aug 4, 7:10 pm, jacko <jackokr...@gmail.com> wrote: > On 4 Aug, 16:54, rickman <gnu...@gmail.com> wrote: > > > > > On Aug 4, 11:43 am, Jerry Avins <j...@ieee.org> wrote: > > > > jacko wrote: > > > > hi > > > > > : 0 DUP DUP XOR ; > > > > Fails when the stack is empty and the implementation has no guard cell. > > > This will only fail if the stack is designed to make it fail. The way > > some implement stacks, there is no top or bottom and duping an "empty" > > stack will produce a valid result for this case. > > > However, I don't see the purpose of defining 0 this way. A means has > > to be provided for arbitrary literals and there is no reason that 0 > > can't be one of these. My understanding is this exercise is a way to > > minimize the instruction set. How does defining 0 and -1 this way > > save op codes? > > > Rick > > It doesn't really. as LIT val EXIT is three cells for any literal to > compact into 1 word to call by xt. Does make me wonder about how an > auto LIT compactor may work though. An auto LIT compactor...??? I think my brother has one of those in his kitchen. He uses it to smash the garbage into a small cube to go to the curb. ;^) Rick |
|
#6
| |||
| |||
| On Aug 4, 4:10*pm, jacko <jackokr...@gmail.com> wrote: > hi > > : 0 DUP DUP XOR ; > : -1 0 NOT ; > > any more? just as a code compaction exercise. The easiest way (as done in Fig Forth and other older Forths) is; 0 CONSTANT 0 1 CONSTANT 1 2 CONSTANT 2 why reinvent the wheel? George Hubert |
|
#7
| |||
| |||
| On 5 Aug, 09:56, George Hubert <georgeahub...@yahoo.co.uk> wrote: > On Aug 4, 4:10*pm, jacko <jackokr...@gmail.com> wrote: > > > hi > > > : 0 DUP DUP XOR ; > > : -1 0 NOT ; > > > any more? just as a code compaction exercise. > > The easiest way (as done in Fig Forth and other older Forths) is; > > 0 CONSTANT 0 > 1 CONSTANT 1 > 2 CONSTANT 2 > > why reinvent the wheel? > > George Hubert This is the most compact at: saving = usages-2 cheers jacko |
|
#8
| |||
| |||
| George Hubert <georgeahubert@yahoo.co.uk> writes: > On Aug 4, 4:10*pm, jacko <jackokr...@gmail.com> wrote: >> hi >> >> : 0 DUP DUP XOR ; >> : -1 0 NOT ; >> >> any more? just as a code compaction exercise. > > The easiest way (as done in Fig Forth and other older Forths) is; > > 0 CONSTANT 0 > 1 CONSTANT 1 > 2 CONSTANT 2 Maybe in some others, but definitly not in FIG Forth, where 0, 1, and 2 are primitive. -- CE3OH... |
|
#9
| |||
| |||
| On Aug 6, 6:16*pm, Albert van der Horst <alb...@spenarnc.xs4all.nl> wrote: > In article <b62033ec-0e09-4584-a1ef-6fcf3dc54...@e39g2000hsf.googlegroups..com>, > George Hubert *<georgeahub...@yahoo.co.uk> wrote: > > >On Aug 4, 4:10=A0pm, jacko <jackokr...@gmail.com> wrote: > >> hi > > >> : 0 DUP DUP XOR ; > >> : -1 0 NOT ; > > >> any more? just as a code compaction exercise. > > >The easiest way (as done in Fig Forth and other older Forths) is; > > >0 CONSTANT 0 > >1 CONSTANT 1 > >2 CONSTANT 2 > > >why reinvent the wheel? > > Why generate special case that may confuse an optimiser? > Since constants already exist in standard Forth then wouldn't an optimiser handle them anyway (most seem to treat them the same as literals). The original question was producing an xt for specific literals, which IMO is exactly what CONSTANT does. George Hubert |
|
#10
| |||
| |||
| In article <b62033ec-0e09-4584-a1ef-6fcf3dc54712@e39g2000hsf.googlegroups.com>, George Hubert <georgeahubert@yahoo.co.uk> wrote: >On Aug 4, 4:10=A0pm, jacko <jackokr...@gmail.com> wrote: >> hi >> >> : 0 DUP DUP XOR ; >> : -1 0 NOT ; >> >> any more? just as a code compaction exercise. > >The easiest way (as done in Fig Forth and other older Forths) is; > >0 CONSTANT 0 >1 CONSTANT 1 >2 CONSTANT 2 > >why reinvent the wheel? Why generate special case that may confuse an optimiser? > >George Hubert -- -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- like all pyramid schemes -- ultimately falters. albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.