[A89] Re: dumb assembly questions


[Prev][Next][Index][Thread]

[A89] Re: dumb assembly questions




-------------------
> 
> > > And "ds.w 0" will never reserve a blank word (at least it never
should...
> > I
> > > guess it's implementation-specific). "ds.x 7" will reserve a
memory area
> > of 7
> > > x:es, (bytes, words or longwords).
> >
> > No, I meant that the problem with "ds.w 0" is that there's no
logical reason
> > to reserve zero bytes, and it only leads to mistakes like this:
> >
> >  BSS
> > var1:    ds.w 0
> > var2:    ds.w 1
> >
> > The modifying var1 modifies var2, and vice versa, because they're
really the
> > same byte.
> 
> I'm sure someone can figure out some way that could be useful :)
> I sure can't though.

I am not 100% familiar with how BSS sections allocate memory, but if
they allocate it in sequential blocks, it would still be useful in
finding certain segments of a memory block. Like, suppose you wanted
the end of a memory block for some functions, and the beginning of
that same block for others. For example, a structure should be
accessible by the entire structure, or by the structures members. So,
you could allocate memory for a big block, then label the individual
parts of that structure, like this:

struct:  ds.w 0
int_member:  ds.w 1
long_member: ds.l 1
string_member ds.b 20

I'm not sure how useful this would be. I couldn't think of a good
example off-hand, but if the memory blocks are allocated sequentially,
we could pass the address of the structure as struct. I guess we could
use the address of the first member, too, but as I said, I couldn't
think of a good example.

Perhaps my inability to come up with an example proves that this is a
useless feature... A warning would still be a good idea, but I'd
hesistate on treating it like an error.

Something in my 68k class did something with labels within memory
blocks to address different parts of the memory block, but for what
reason, I cannot remember.

John David Ratliff
jdratlif@cs.indiana.edu




Follow-Ups: References: