[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.
Actually the above is a good example - imagine if you for some reason want to
move some of the variables within the structures around a bit (maybe to optimize
the code that manages it). Then you wouldn't have to change the code that
locates, copies or initializes the struct... just load a pointer with struct(pc)
or #struct, and use a #define or variable to keep the size of it.
--
/ Niklas Brunlid
Check out Prosit for the TI-89 / TI-92+ at http://prosit.ticalc.org
Random PQF v5.1 Quote follows:
- "I think there may be one or two steps in your logic that I have failed
to grasp, Mister Stibbons," said the Archchancellor coldly. "I suppose
you're not intending to shoot your own grandfather, by any chance?"
- "Of course not!" snapped Ponder, "I don't even know what he looked like.
He died before I was born."
- "Ah-*hah*!"
-- The faculty members of Unseen University discuss time travel
(Terry Pratchett, The Last Continent)
References: