c++ - Studying a simplistic code disassembly output and memory map -
can explain me happening below? questions:
why doesn't variable remain in register? why register rbp contain address of memory cache line , not address of (i.e. 4 bytes)? what mean?movl $0x5,-0x4(%rbp); % , negative 0x4 mean? int main(int argc, char* argv[]) { int = 5; // line 25 ++; // line 26 } ----------------------------------------------------- disassembly: 25 int = 5; 00000000004014f4: movl $0x5,-0x4(%rbp) 26 ++; 00000000004014fb: addl $0x1,-0x4(%rbp) ----------------------------------------------------- register values: rbp: 0x23fe60 ----------------------------------------------------- memory map @ line 25: address | 0-3 | 4-7 | 8-b | c-f | 0x23fe60 |00000000|00000000|00000000|05000000| memory map @ line 26: address | 0-3 | 4-7 | 8-b | c-f | 0x23fe60 |00000000|00000000|00000000|06000000| note: above generated eclipse, compiling using mingw on 64 bit machine.
why doesn't variable remain in register?
because compiler didn't sense it. decided place variable i on stack.
rbp doesn't contain address of memory cache. rbp base pointer, points bottom of stack. -0x4(%rbp) location of variable i in memory (on stack). means value of rbp minus 4. why 4? because i takes 4 bytes. is address of i.
see http://en.wikibooks.org/wiki/x86_disassembly/the_stack
what mean?movl $0x5,-0x4(%rbp); % , negative 0x4 mean? there 2 mutual assembly syntaxes
at&t, unreadable mess "regular" intel syntaxyour code in at&t unfortunately. % how variables referenced in at&t syntax. -0x4 hex representation of number -4 (see reply above).
see http://en.wikipedia.org/wiki/x86_assembly_language#syntax
c++ memory assembly
No comments:
Post a Comment