Tuesday, February 3, 2009

What that mysterious %al means in gdb

If you're looking at Xcode's instruction pane in gdb, and you're on an Intel platform, %al is the least significant byte of the EAX register. So code that looks like this:
0x0000661a  <+0251>  call   0x3c21a <>0x0000661f  <+0256>  test   %al,%al0x00006621  <+0258>  jne    0x6650 < -[ConfCallStatusTableViewController mergeConfCallStatusViaNotification:]+305 >
Translates to:
  1. Call dyld_stub_objc_msgSend
  2. AND the least significant byte of the EAX register with itself. The point of this is the side effect - it sets the bits in the EFLAG register that will be used in the jne instruction that's coming next.
  3. Jump-if-not-equal to -[ConfCallStatusTableViewController mergeConfCallStatusViaNotification:]. jne looks at 'equal' bit that was set in the previous step, and if that bit is set, it jumps. If it's not set, just continue on to the next instruction.
Check out Wikipedia for a decent simple into to Intel assembly. I found the note about what %al in a course tutorial.

No comments: