除了用 gcc -S 來產生 *.s 的 assembly code之外. 也可以用
objdump +
strace 的 command 來做 assemble && system call trace.
sample code @ c
TT *get_TTNode(TT *p,int Id){
TT *tPtr = p;
while(tPtr!=NULL){
if( tPtr->Id == Id ){
return tPtr; break;
}
tPtr = tPtr->Nxt;
}
return NULL;
}
objdump -d (disassemble)
080484d3 <get_TTNode>:
80484d3: 55 push %ebp
80484d4: 89 e5 mov %esp,%ebp // store current stack pointer
80484d6: 83 ec 14 sub $0x14,%esp
80484d9: 8b 45 08 mov 0x8(%ebp),%eax // get "TT *p"
80484dc: 89 45 fc mov %eax,-0x4(%ebp) // "TT *tPtr = p"
80484df: eb 1b jmp 80484fc <get_TTNode+0x29> // jump to while loop
80484e1: 8b 45 fc mov -0x4(%ebp),%eax // "tPtr->Id"
80484e4: 8b 00 mov (%eax),%eax // mov to eax register
80484e6: 3b 45 0c cmp 0xc(%ebp),%eax // cmp (tPtr->Id == Id )? true : false;
80484e9: 75 08 jne 80484f3 <get_TTNode+0x20>
80484eb: 8b 45 fc mov -0x4(%ebp),%eax
80484ee: 89 45 ec mov %eax,-0x14(%ebp) // return tPtr
80484f1: eb 16 jmp 8048509 <get_TTNode+0x36> // break
80484f3: 8b 45 fc mov -0x4(%ebp),%eax
80484f6: 8b 40 0c mov 0xc(%eax),%eax // tPtr = tPtr->Nxt
80484f9: 89 45 fc mov %eax,-0x4(%ebp)
80484fc: 83 7d fc 00 cmpl $0x0,-0x4(%ebp) // while loop
8048500: 75 df jne 80484e1 <get_TTNode+0xe> // cmp (tPtr!=NULL)? true : false;
8048502: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
8048509: 8b 45 ec mov -0x14(%ebp),%eax //return NULL
804850c: c9 leave
804850d: c3 ret
Refs :
objdump
strace
沒有留言:
張貼留言