On Tue, 16 Oct 2001, Dan Sugalski wrote:
> We sort of do, if you treat string contents as a buffer of bytes rather
> than characters. Raw memory sort of lives a step below the interpreter at
> the moment, though I can see uses for that not being the case.
Hm.  So you're thinking that allocating n bytes should consist of creating
a string with n characters.  Reading would be:
SUBSTR [dest S register], ["memory" S register], [address], [number of
bytes to read]
<somehow convert from string to bunch-o-bytes (which makes us implicitly
have the MSB first)>
I don't see any good way to write without resorting to two substrs and a
concat.

Also, this doesn't really feel like ram.  (Mostly because you have to
preallocate thie string, but also because an address is not a number, it's
a string register and an index into it.)

> >I see how it
> >could be emulated fairly easily, by creating a pad with one-byte PMCs,
> > [yadda yadda]
Hm.  I'm no longer certan what I was thinking.  However, here's somthing
like it:
Create a PMC type, call it MEM for now.  It's sort of a lazy array of
bytes.
For memory access, you'd have to load one of the P registers with your
memory.  (Remember that when you pass a function a "pointer", it's really
an index into that PMC, so you'd have to either pass the memory PMC
around, or you'd have to have a global memory PMC.  (Assume we load into
P1.)

To read:
Then, you'd do find_method P2, P1, "getmem" (Assuming that a t here is
really s|sc.)
Then call_method P2, <value>, <index>, <size>.  (Assuming that a t here is
really any number of arguments.)

To write:
find_method P2, P1, "setmem"
call_method P2, <value>, <index>, <size>

The MEM PMC type would have to have the following characteristics:
getmem P2, I1, I2, 2 makes I1 get the value MEM[I2]<<8+MEM[I2+1],
setmem P2, I2, I1, 2 makes MEM[I2] = I1>>8 and MEM[I2+1] = I1&&0xFF

If MEM[x] does not exist on a write to it, create it.
If MEM[x] does not exist on a read from it, die.  (?)  (Catches read of
uninitlised value, which in a normal memory system is almost always a bug.
I can't think of a reason why it wouldn't be, but I'm sure that there is
one.)

(And I havn't even discussed reading/writing strings or numbers.)

This all seems very inneficent.

        -=- James Mastros
-- 
Put bin Laden out like a bad cigar: http://www.fieler.com/terror
"You know what happens when you bomb Afghanastan?  Thats right, you knock
over the rubble."       -=- SLM

Reply via email to