I'm taking this course, and I'm really struggling understanding the directive .align
concept.
Here's an example, which I couldn't understand:
I know that inside the data segment, there are addresses, starting with 0x10010000,0x10010020,etc.
And I know, that inside each address, there are 8 memory fields, each has 32bit.
Now, what I don't understand is, how and why var2
inside the address 0x10010010? str1
is inside the address 0x10010003 because we reserved 3 bits for the var1
.
The last thing is, what exactly the directive .align
doing? When I tested it in Mars4, it only shifted the data into the next memory field when I used align 3
and up, but I don't really get it.
.align
works in classic-MIPS assemblers like MARS, e.g. magically affecting previous labels, unlike in modern assemblers like GAS and clang: MARS MIPS simulator's built-in assembler aligns more than requested? – Peter Cordes