Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // gcc -O0 -m32 -march=i586 -mtune=i586 -o foo foo.c
- #include <stdint.h>
- static volatile uint16_t foo = 6;
- static uint16_t start = 4;
- uint16_t get_foo(void)
- {
- return foo;
- }
- int main(void)
- {
- uint16_t diff = (get_foo() - start) + 1;
- return 0;
- }
- // objdump -d foo
- 080483cb <get_foo>:
- 80483cb: 55 push %ebp
- 80483cc: 89 e5 mov %esp,%ebp
- 80483ce: 66 a1 a8 96 04 08 mov 0x80496a8,%ax
- 80483d4: 5d pop %ebp
- 80483d5: c3 ret
- 080483d6 <main>:
- 80483d6: 55 push %ebp
- 80483d7: 89 e5 mov %esp,%ebp
- 80483d9: 83 ec 10 sub $0x10,%esp
- 80483dc: e8 ea ff ff ff call 80483cb <get_foo>
- 80483e1: 89 c2 mov %eax,%edx
- 80483e3: 66 a1 aa 96 04 08 mov 0x80496aa,%ax
- 80483e9: 29 c2 sub %eax,%edx
- 80483eb: 89 d0 mov %edx,%eax
- 80483ed: 40 inc %eax
- 80483ee: 66 89 45 fe mov %ax,-0x2(%ebp)
- 80483f2: b8 00 00 00 00 mov $0x0,%eax
- 80483f7: c9 leave
- 80483f8: c3 ret
- 80483f9: 66 90 xchg %ax,%ax
- 80483fb: 66 90 xchg %ax,%ax
- 80483fd: 66 90 xchg %ax,%ax
- 80483ff: 90 nop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement