Machine Programming Basics

References

Outline

Intel x86 Processors

Intel x86 Evolution: Milestones

Name Date Transistors MHz Notes
8086 1978 29K 5-10 16-bit
386 1985 275K 16-33 32-bit
Pentium 4E 2004 125M 2800-3800 64-bit
Core 2 2006 291M 1060-3333 multi-core
Core i7 2008 731M 1600-4400 four cores

x86 Clones: Advanced Micro Devices (AMD)

Intel’s 64 bit History

Definitions

Assembly/Machine Code View

Assembly Characteristics

x86-64 Integer Registers

8-byte register bytes 0-3 bytes 0-1 byte 0
%rax %eax %ax %al
%rcx %ecx %cx %cl
%rdx %edx %dx %dl
%rbx %ebx %bx %bl
%rsi %esi %si %sil
%rdi %edi %di %dil
%rsp %esp %sp %spl
%rbp %ebp %bp %bpl

x86-64 Integer Registers (continued)

8-byte register bytes 0-3 bytes 0-1 byte 0
%r8 %r8d %r8w %r8b
%r9 %r9d %r9w %r9b
%r10 %r10d %r10w %r10b
%r11 %r11d %r11w %r11b
%r12 %r12d %r12w %r12b
%r13 %r13d %r13w %r13b
%r14 %r14d %r14w %r14b
%r15 %r15d %r15w %r15b

x86-64 Integer Registers (continued)

Assembly Characteristics: Operations

Moving Data

movq Operand Combinations

Source Destination Example C Analog
Imm Reg movq $0x4, %rax temp = 0x04;
Imm Mem movq $-147, (%rax) *p = -147;
Reg Reg movq %rax, %rdx temp2 = temp1;
Reg Mem movq %rax, (%rdx) *p = temp;
Mem Reg movq (%rax), %rdx temp = *p;

Memory Addressing Modes

Memory Addressing Modes (continued)

Memory Addressing Modes (continued)

Addressing Modes Example

Addressing Modes Example

Address Computation Examples

Address Computation Instruction

Some Arithmetic Operations

Some Arithmetic Operations

Arithmetic Expression Example

Arithmetic Expression Example

Turning C into Object Code

Assembly

Summary