I'm looking at the disassembler output of an XCode C file and I get the following:
Showing that:
int a=2;
Translates into this:
0x100000f88 <+8>: movl $0x0, -0x4(%rbp)
-> 0x100000f8f <+15>: movl $0x2, -0x8(%rbp)
Now I get (I think?) the point of this in that it's clearing the higher four bytes and then moving the number 2 into the lower four bytes so it looks like:
--------------- 0
0
--------------- -1
0
--------------- -2
0
--------------- -3
0
--------------- -4
0
--------------- -5
0
--------------- -6
0
--------------- -7
2
--------------- -8
But why does it do that and not just movq $2, -8(%rbp) ? Finally, why does it do a subq $0x10 instead of subq $0x8 on the line above? I've never seen offsets of ten used before? (<-- Answering my own second question, I see the x in there now, so it's an offset of 16 not 10)
By the way, this is on a mac Mojave 10.14.6 using XCode for debugging -- is there a particular tag I should put into the question, or is x86 and assembly enough?
