[Coco] A bug in Basic09/RunB
Wayne Campbell
asa.rand at gmail.com
Tue Dec 8 03:58:28 EST 2009
Willard,
I think it is just the way I've learned to see how data is organized in
I-Code. In I-Code, the data is all organized by address. This means that all
you have to know is the address and you have the location of that data. I
understand the way it is being put in the parameter list, even though I do
not know if the entry is a long, or 2 ints, each addressing a different
thing. I understand that, in Basic09, all of the data is arranged
sequentially, and the address of a variable is its offset relative to the
beginning of the data memory allocation. The first $16 bytes are reserved by
Basic09 for its variables. When a called procedure addresses a parameter,
it uses a pointer that tells it which entry in the parameter list is the
item to retrieve. It also passes its size. The address pointed to by the
parameter list points to the data memory address (as described above) in the
calling procedure where that variable's data is contained.
It reads the number of bytes provided by the called procedure as the size.
My knoweledge of the actual types of coding that are done, whether for type
checking or otherwise, is too limited to detail that process. I just know
that the way Basic09 handles data, passing anything to anything should be
possible, as long as the sum of the sizes is equal to the size requested by
the called procedure. That would seem, to me, to be the more efficient way
of dealing with parameters. But, I digress. I am grossly undereducated in
this matter.
Wayne
----- Original Message -----
From: "Willard Goosey" <goosey at virgo.sdc.org>
To: "CoCoList for Color Computer Enthusiasts" <coco at maltedmedia.com>
Sent: Monday, December 07, 2009 10:59 PM
Subject: Re: [Coco] A bug in Basic09/RunB
> On Mon, Dec 07, 2009 at 09:09:37PM -0800, Wayne Campbell wrote:
>> Willard,
>>
>> I understand. In most languages I have looked at this is true. I am
>> merely
>> testing the limits of what appeared to be a possibility, given that I can
>> pass a 32-byte array to a 32-character string, or vice-versa, and it
>> works
>> just fine.
>
> The difference between BASIC-09 strings and arrays always seemed like
> an artificial one to me. Especially since BASIC-09 strings can't vary
> in size like MS BASIC strings
>
>>No type checking. I thought, if this is true, then I should be
>> able to pass 3 parameters, the sum of whose lengths equal the size of the
>> expected variable. I guess the former is relegated to individual
>> parameters, and not the list as a whole.
>>
> Look, I don't know anything about the insides of the ICODE interpeter,
> but if the module interface there is the same as the binary module
> interface then there is no way that'll work.
>
> For a binary module, there is no such thing as pass by value. It's all
> pass by reference. The closest you get is what compiler theory calls
> "Pass by value-result". This is really pass-by-reference, but with
> checks to make sure you don't clobber the constant table. (BTW this
> hack was introduced in FORTRAN II).
>
> Given the strongly stack-oriented behavior of the ICODE engine, I'm
> pretty sure it works the same way.
>
> So look at your stack: (16-bit numbers)
> you call RUN foo(a,b,c)
> stack looks like:
> size of c
> address of c
> size of b
> address of b
> size of a
> address of a
> num of args
> return address
>
> you call RUN foo(array)
> stack looks like:
> size of array
> address of array
> num of args
> return address
>
> Whichever one foo() expects, it's going to do bad things when it gets
> the other.
>
> The lack of type checking goes both ways. The code doesn't catch it
> when you send a module the wrong arguments, and therefore can't do
> anything to turn them into sensible arguments.
>
> It's not all bad, though. This interface may not be particularly
> type-safe but it easly lends itself to subroutine modules in assembly
> and C. It makes it especially easy to write varaidic modules in
> assembly (such as GFX and GFX2).
>
> Willard
> --
> Willard Goosey goosey at sdc.org
> Socorro, New Mexico, USA
> I search my heart and find Cimmeria, land of Darkness and the Night.
> -- R.E. Howard
>
> --
> Coco mailing list
> Coco at maltedmedia.com
> http://five.pairlist.net/mailman/listinfo/coco
More information about the Coco
mailing list