On 1/31/2015 5:02 AM, Albert van der Horst wrote:
> In article <
4bbd1451-fcb2-4e48...@googlegroups.com>,
> <
fort...@gmail.com> wrote:
>> On Friday, January 30, 2015 at 8:56:46 AM UTC-6, empty-buffers wrote:
>>> Maybe someone knows the meaning of Mr. Moore's word proposals @+ and !+ ?
>>> No idea about their meaning ("fetch then increment"? Maybe, but the other
>>> one: "store, then increment"? What should be incremented?).
>>>
>>> Somehow I can't find their definitions.
>>> --
>>> "Yes, this is the bad end you've come to, and two and two is - as it always
>>> was..." - began Trurl, but just then the machine made a faint, barely audible
>>> croaking noise and said, for the last time: "SEVEN".
>>
>> Bernd has a @+ primitive in his b16-small. It simply leaves the address on the
>> stack after using it to fetch the data. It could be handy if incrementing thru a
>> range of addresses, but I suspect it's mostly done so that the CPU doesn't have
>> to drop two locations from the stack in one clock cycle.
>>
>> : @ @+ drop ;
>
> That is not the prime use of @+
> It is best known under its ALIAS $@.
> $@ is the equivalent of COUNT, but for a string whose count
> occupies a whole cell.
>
> "AAP" PAD $!
>
> PAD $@ TYPE
>
> AAP OK
I find it a bit odd to have a two stack machine (not terribly different
from a two register machine) and to only process info from the data
stack. In my two stack CPU I use the return stack as an address stack.
It also has auto increment modes which do not automatically drop the
address, but it doesn't drop the address from the return stack which
interferes less with data accesses on the data stack. This makes some
other instructions simpler since the address is always on the return
stack and the same mechanism can be used for things like return or jump
to an address on the stack (computed or otherwise). They are actually
the same thing, no?
I have different instructions for immediate mode address such as would
be used to implement control flow instructions like IF or WHILE. This
is because I used a one bit opcode to indicate the literal used for
immediate mode addressing when the value is more than the few bits that
fit in the basic instruction. Depending on the use of an 8 or 9 bit
instruction opcode, the jump/call instructions have 4/5 bits of signed
relative address. This is extended by preceding the jump/call by
literal instruction(s) prepending 7/8 bits to the address. The first
literal loads its value to the return stack with sign extension and each
subsequent literal shifts the current value left loading the additional
bits. The literal instruction sets a "literal" flag to distinguish this
condition. The jump/call instruction does the same shifting before
using the value on the return stack if the literal flag is set,
otherwise it uses the immediate value directly.
I don't know that this works out any better than other methods. The
little bit of comparison I did to RISC instruction sets showed the
instruction density was about the same since the instructions do a lot
less. At one point I was looking at an instruction format that allowed
for offsets in accessing data on the stack which seems to save a lot of
the stack juggling instructions. Think of it as a hybrid between a
stack machine and a register machine. I never followed through with
that to produce an implementation. I may return to that once I finish
the other tasks I have at hand.
--
Rick