Obsah

C versus Assembler

CAssemblerZásobník
int main(int argc, char **argv){



  int i, j, k;

  i = inb(port);




  return i + j + k;




}
main:
push ebp
mov ebp, esp

sub esp, 12 ; 12 = sizeof(i) + sizeof(j) + sizeof(k)

mov dx, port
in al, dx
movzx eax, al
mov [ss:ebp - 4], eax

mov eax, [ss:ebp - 4]
add eax, [ss:ebp - 8]
add eax, [ss:ebp - 12]
mov esp, ebp
pop ebp
ret 8 ; 8 = sizeof(argc) + sizeof(argv)
argv
argc
return_address
old_ebp
i
j
k