Totally Dominate Computer Market Evolutionary Design Starting in 1978 with 8086 Added more features as time goes on Still support old features although obsolete Topics Complex Instruction Set Computer CISC Assembly Programmer s Execution Model Accessing Information Many different instructions with many different formats But only small subset encountered with Linux programs Hard to match performance of Reduced Instruction Set Computers RISC But Intel has done just that Registers Memory Arithmetic operations class05 ppt Name 8086 0 Date Transistors 1978 29K Name 16 bit processor Basis for IBM PC DOS Limited to 1MB address space DOS only gives you 640K 80286 1982 134K 1985 Date Transistors 1989 1 9M Pentium 1993 3 1M Pentium MMX 1997 4 5M Added special collection of instructions for operating on 64bit vectors of 1 2 or 4 byte integer data PentiumPro 275K 1995 6 5M Added conditional move instructions Big change in underlying microarchitecture Extended to 32 bits Added flat addressing Capable of running Unix Linux gcc uses no instructions introduced in later models 3 0 486 Added elaborate but not very useful addressing scheme Basis for IBM PC AT and Windows 386 15 213 S 04 2 15 213 S 04 4 Page 1 15 213 S 04 Name Pentium III 0 Date Transistors 1999 8 2M 2001 Historically AMD has followed just behind Intel A little bit slower a lot cheaper Recently Recruited top circuit designers from Digital Equipment Corp Exploited fact that Intel distracted by IA64 Now are close competitors to Intel 42M Added 8 byte formats and 144 new instructions for streaming SIMD mode Developing own extension to 64 bits 15 213 S 04 5 Advanced Micro Devices AMD Added streaming SIMD instructions for operating on 128 bit vectors of 1 2 or 4 byte integer or floating point data Our fish machines Pentium 4 15 213 S 04 6 1 0 2 Transmeta Name Date Transistors Itanium 2001 10M Recent start up Employer of Linus Torvalds Radically different approach to implementation Translates x86 code into Very Long Instruction Word VLIW code High degree of parallelism Extends to IA64 a 64 bit architecture Radically new instruction set designed for high performance Will be able to run existing IA32 programs Shooting for low power market On board x86 engine Joint project with Hewlett Packard Itanium 2 2002 221M Big performance boost 7 15 213 S 04 8 Page 2 15 213 S 04 34 0 CPU Registers Object Code Program Data OS Data Data Condition Codes 536 Code in files p1 c p2 c Compile with command gcc O p1 c p2 c o p Memory Addresses E I P Use optimizations O Put resulting binary in file p Instructions text C program p1 c p2 c Compiler gcc S Stack Programmer Visible State EIP text Asm program p1 s p2 s Program Counter Assembler gcc or as Address of next instruction Register File Byte addressable array Code user data some OS data s e ro u d c tp k a lIn procedures Condition Codes Store status information about most recent arithmetic operation Used for conditional branching C Code int sum int x int y int t x y return t Static libraries a Linker gcc or ld binary 15 213 S 04 9 binary Memory Heavily used program data Object program p1 o p2 o Executable program p 15 213 S 04 10 34 34 Minimal Data Types Generated Assembly Integer data of 1 2 or 4 bytes sum pushl ebp movl esp ebp movl 12 ebp eax addl 8 ebp eax movl ebp esp popl ebp ret Data values Addresses untyped pointers Floating point data of 4 8 or 10 bytes No aggregate types such as arrays or structures Just contiguously allocated bytes in memory Primitive Operations Perform arithmetic function on register or memory data Obtain with command Transfer data between memory and register gcc O S code c Load data from memory into register Store register data into memory Produces file code s Transfer control Unconditional jumps to from procedures Conditional branches 11 15 213 S 04 12 Page 3 15 213 S 04 536 Assembler Code for sum int t x y Translates s into o 0x401040 sum Binary encoding of each instruction 0x55 Total of 13 0x89 Nearly complete image of executable bytes 0xe5 code Each 0x8b instruction 1 Missing linkages between code in 0x45 2 or 3 bytes different files 0x0c Starts at 0x03 address Linker 0x45 0x401040 0x08 Resolves references between files 0x89 Combines with static run time libraries 0xec E g code for malloc printf 0x5d 0xc3 Some libraries are dynamically linked Assembly 536 push mov mov add mov pop ret lea x y Operands x y t int eax int ebp eax ebp 2 0x401046 03 45 08 Register eax Memory M ebp 8 Register eax Return function value in eax Object Code 3 byte instruction Stored at address 0x401046 15 213 S 04 14 8 ebp esp ebp 0xc ebp eax 0x8 ebp eax ebp esp ebp 0x0 esi esi objdump d p Useful tool for examining object code Analyzes bit pattern of series of instructions Produces approximate rendition of assembly code Can be run on either a out complete executable or o file 34 Disassembled Object 0x401040 0x55 0x89 0xe5 0x8b 0x45 0x0c 0x03 0x45 0x08 0x89 0xec 0x5d 0xc3 Disassembler 15 Long words in GCC parlance Same instruction whether signed or unsigned Or Disassembled 00401040 sum 0 55 1 89 e5 3 8b 45 0c 6 03 45 08 9 89 ec b 5d c c3 d 8d 76 00 Add 2 4 byte integers Similar to expression 15 213 S 04 13 3 Add two signed integers addl 8 ebp eax Linking occurs when program begins execution 8 7 C Code 0x401040 0x401041 0x401043 0x401046 0x401049 0x40104b 0x40104c 0x40104d sum sum 1 sum 3 sum 6 sum 9 sum 11 sum 12 sum 13 push mov mov add mov pop ret lea ebp esp ebp 0xc ebp eax 0x8 ebp eax ebp esp ebp 0x0 esi esi Within gdb Debugger gdb p disassemble sum Disassemble procedure x 13b sum Examine the 13 bytes starting at sum 15 213 S 04 16 Page 4 15 213 S 04 9 3 8 3 8 eax edx objdump d WINWORD EXE WINWORD EXE Moving Data edi push mov push push push movl Dest 3 Src Dest Register One of 8 integer registers But esp and ebp reserved for special use Others have special uses for particular instructions Memory 4 consecutive bytes of memory Various address modes 2 C Analog Normal R Mem Reg R Register R specifies memory address Reg movl 0x4 eax Mem movl 147 eax temp 0x4 Reg Reg movl eax edx Mem movl eax edx temp2 temp1 Reg temp p movl eax edx 15 213 S 04 18 Imm Mem ebp Like C constant but prefixed with E g 0x400 533 Encoded with 1 2 or 4 bytes 15 213 S 04 esp Immediate Constant integer data ebp esp ebp 0xffffffff 0x30001090 0x304cdc91 17 Source esi Operand Types Anything that can be interpreted as executable code Disassembler examines bytes and reconstructs assembly source movl 5 ebx Move …
View Full Document