25 - Machine-Level Representation of Programs (x86-64) 1...

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Machine-Level Representation of Programs (x86-64)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Outline Data Representation Register Instruction Procedures and Stack Alignment Byte Ordering x86-64 Machine-Level Programming
Background image of page 2
3 Size of Data Type Data Types in C Language Data Type IA32 (Linux) x86-64 (Linux) char 1 1 short 2 2 int 4 4 long int 4 8 long long 8 8 float 4 4 double 8 8 long double 12 16 pointer  (e.g. char *) 4 8
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Integer Register %eax %ebx %ecx %edx %esi %edi %esp %ebp %al %ah %bl %bh %cl %ch %dl %dh IA32
Background image of page 4
Integer Register Extend exist registers to 64bits %rbp %rsp %rdi %rsi %rdx %rcx %rbx %rax %eax %edx %ecx %ebx %esi %edi %esp %ebp %al %ah %dl %dh %cl %ch %bl %bh
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Integer Register Add  8 new 64bits registers %rbp %rsp %rdi %rsi %rdx %rcx %rbx %rax %eax %ebx %ecx %edx %esi %edi %esp %ebp %al %ah %dl %dh %cl %ch %bl %bh %r15 %r14 %r13 %r12 %r11 %r10 %r9 %r8 %r8d %r9d %r10d %r11d %r12d %r13d %r14d %r15d
Background image of page 6
%rbp %ebp Integer Register Make  %ebp/%rbp  %ebp/%rbp general purpose %rsp %rdi %rsi %rdx %rcx %rbx %rax %eax %ebx %ecx %edx %esi %edi %esp %al %ah %dl %dh %cl %ch %bl %bh %r15 %r14 %r13 %r12 %r11 %r10 %r9 %r8 %r8d %r9d %r10d %r11d %r12d %r13d %r14d %r15d
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
8 Instructions Long word l (4 Bytes)   Quad word q (8 Bytes) New Instructions  movl → movq addl → addq sall → salq etc. 32 bit instructions generate 32 bit results Set higher order bits of destination register to 0 Example:  addl
Background image of page 8
9 Switch Statements long switch(long x) { switch(x) { . . . } . . . } .section .rodata .align 4 .L8: .long .L1 # x = 0 .long .L2 # x = 1 .long .L3 # x = 2 .long .L4 # x = 3 .long .L5 # x = 4 .long .L6 # x = 5 .long .L7 # x = 6 switch: pushl %ebp # Setup movl %esp, %ebp # Setup movl 8(%ebp), %edx # edx = x cmpl $6, %edx # x:6 ja .L1 # if > goto default jmp *.L8(,%edx,4) # goto JTab[x] Jump Table
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
10 Switch Statements x86-64 Same general idea, adapted to 64-bit code Table entries 64 bits (pointers) .section .rodata .align 4 .L8: .long .L1 # x = 0 .long .L2 # x = 1 .long .L3 # x = 2 .long .L4 # x = 3 .long .L5 # x = 4 .long .L6 # x = 5 .long .L7 # x = 6 .section .rodata .align 8 .L8: .quad .L1 # x = 0 .quad .L2 # x = 1 .quad .L3 # x = 2 .quad .L4 # x = 3 .quad .L5 # x = 4 .quad .L6 # x = 5 .quad .L7 # x = 6 x86-64 IA32
Background image of page 10
IA32 Example: swap() void swap (int *xp, int *yp) { int t0 = *xp; int t1 = *yp; *xp = t1; *yp = t0; } swap: pushl %ebp movl %esp,%ebp pushl %ebx movl 12(%ebp),%ecx movl 8(%ebp),%edx movl (%ecx),%eax movl (%edx),%ebx
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 33

25 - Machine-Level Representation of Programs (x86-64) 1...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online