[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.
> Not always. Small temporary variables should be allocated on the stack
(easier
> in C than in asm, of course)
True. . .
> but when moving variables in and out of the BSS
> block I've noiticed that the program can shrink when moving in both
directions.
What do you mean by that?
> You must use "move.l" with BSS variables though, since they aren't
relative to
> your code. I actually had to ask David about this once - still annoyed
that I
> couldn't figure it out myself :)
You can also use lea without the "(pc)" (ie: "lea data,a0"), although I'm
not sure if this retains any benefits over "move.l #data" except for
aesthetics (easier to distinguish what the code is actually doing).
-Scott
Follow-Ups: