1 IA-32

Slides:



Advertisements
Similar presentations
1 Real-World Instruction Set Architectures Focus on IA-32 Course website:
Advertisements

Chapter 2 (cont.) An Introduction to the 80x86 Microprocessor Family Objectives: The different addressing modes and instruction types available The usefulness.
Computer Organization and Assembly Languages Yung-Yu Chuang
C Programming and Assembly Language Janakiraman V – NITK Surathkal 2 nd August 2014.
Lect 3: Instruction Set and Addressing Modes. 386 Instruction Set (3.4) –Basic Instruction Set : 8086/8088 instruction set –Extended Instruction Set :
Lecture 6 Machine Code: How the CPU is programmed.
Chapter 1 Background System Software Chih-Shun Hsu
Assembly Language for Intel-Based Computers Chapter 5: Procedures Kip R. Irvine.
PC hardware and x86 3/3/08 Frans Kaashoek MIT
1 ICS 51 Introductory Computer Organization Fall 2006 updated: Oct. 2, 2006.
1 Lecture 5: Procedures Assembly Language for Intel-Based Computers, 4th edition Kip R. Irvine.
CS2422 Assembly Language & System Programming November 28, 2006.
Assembly Language for Intel-Based Computers Chapter 2: IA-32 Processor Architecture Kip Irvine.
ICS312 Set 3 Pentium Registers. Intel 8086 Family of Microprocessors All of the Intel chips from the 8086 to the latest pentium, have similar architectures.
Pentium Addressing Modes
Microprocessor Systems Design I Instructor: Dr. Michael Geiger Spring 2014 Lecture 4: x86 memory.
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers, Stack Operations Runtime Stack PUSH Operation POP.
Lect 4: Instruction Set and Addressing Modes. 386 Instruction Set (3.4)  Basic Instruction Set : 8086/8088 instruction set  Extended Instruction Set.
CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 1 Intel IA-32 vs Motorola
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 2: IA-32 Processor Architecture (c) Pearson Education, All rights reserved. You.
6.828: PC hardware and x86 Frans Kaashoek
Computer Architecture and Operating Systems CS 3230 :Assembly Section Lecture 7 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Intel Pentium II Processor Brent Perry Pat Reagan Brian Davis Umesh Vemuri.
Code Generation Gülfem Savrun Yeniçeri CS 142 (b) 02/26/2013.
Low Level Programming Lecturer: Duncan Smeed Overview of IA-32 Part 1.
Fall 2012 Chapter 2: x86 Processor Architecture. Irvine, Kip R. Assembly Language for x86 Processors 6/e, Chapter Overview General Concepts IA-32.
The x86 Architecture Lecture 15 Fri, Mar 4, 2005.
IA32 (Pentium) Processor Architecture. Processor modes: 1.Protected (mode we will study) – 32-bit mode – 32-bit (4GB) address space 2.Virtual 8086 modes.
Today’s topics Procedures Procedures Passing values to/from procedures Passing values to/from procedures Saving registers Saving registers Documenting.
1 ICS 51 Introductory Computer Organization Fall 2009.
Sahar Mosleh California State University San MarcosPage 1 Stack operations, Applications and defining procedures.
Microprocessors The ia32 User Instruction Set Jan 31st, 2002.
26-Nov-15 (1) CSC Computer Organization Lecture 6: Pentium IA-32.
Oct. 25, 2000Systems Architecture I1 Systems Architecture I (CS ) Lecture 9: Alternative Instruction Sets * Jeremy R. Johnson Wed. Oct. 25, 2000.
In1211/04-PDS 1 TU-Delft IA-32. In1211/04-PDS 2 TU-Delft IA family l IA (Intel Architecture) is a family of processors (1985), (1989), -Pentium-line.
Introduction to Assembly II Abed Asi Extended System Programming Laboratory (ESPL) CS BGU Fall 2013/2014.
Compiler Construction Code Generation Activation Records
X86 Assembly Language We will be using the nasm assembler (other assemblers: MASM, as, gas)
Introduction to Intel IA-32 and IA-64 Instruction Set Architectures.
1 Assembly Language: Function Calls Jennifer Rexford.
CSC 221 Computer Organization and Assembly Language Lecture 16: Procedures.
Assembly Language Data Movement Instructions. MOV Instruction Move source operand to destination mov destination, source The source and destination are.
Carnegie Mellon Midterm Review : Introduction to Computer Systems October 15, 2012 Instructor:
CSC 221 Computer Organization and Assembly Language Lecture 15: STACK Related Instructions.
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
The Microprocessor & Its Architecture A Course in Microprocessor Electrical Engineering Department Universitas 17 Agustus 1945 Jakarta.
Assembly Language Addressing Modes. Introduction CISC processors usually supports more addressing modes than RISC processors. –RISC processors use the.
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
Chapter Overview General Concepts IA-32 Processor Architecture
A job ad at a game programming company
Stack Operations Dr. Hadi AL Saadi.
Assembly language.
Credits and Disclaimers
IA32 Processors Evolutionary Design
Aaron Miller David Cohen Spring 2011
Computer skills CPU Jakub Yaghob.
Chapter 4 Data Movement Instructions
Basic Microprocessor Architecture
Assembly IA-32.
# include < stdio.h > v oid main(void) { long NUM1[5]; long SUM; long N; NUM1[0] = 17; NUM1[1] = 3; NUM1[2] =  51; NUM1[3] = 242; NUM1[4] = 113; SUM =
BIC 10503: COMPUTER ARCHITECTURE
Introduction to Intel IA-32 and IA-64 Instruction Set Architectures
MIPS Procedure Calls CSE 378 – Section 3.
Week 2: Buffer Overflow Part 1.
Computer Architecture CST 250
X86 Assembly Review.
Low-Level Thread Dispatching on the x86
Other Processors Having learnt MIPS, we can learn other major processors. Not going to be able to cover everything; will pick on the interesting aspects.
CSC 497/583 Advanced Topics in Computer Security
Computer Architecture and System Programming Laboratory
Presentation transcript:

1 IA-32

TU-Delft TI1400/11-PDS 2 IA family IA (Intel Architecture) is a family of processors Each processor—same architecture, but different organization -same instruction set -different performance 32-bit memory addresses and variable length instructions Very large instruction set (not RISC)

TU-Delft TI1400/11-PDS 3 Floorplan IA-32

TU-Delft TI1400/11-PDS 4 Other Example: PowerPC Floating-point unit Integer unit Instruction unit instructions Cache main memory

TU-Delft TI1400/11-PDS 5 Floorplan PowerPC

TU-Delft TI1400/11-PDS 6 FPU Data Cache Instr. Cache Registers MMU Load/Store Unit Floorplan PowerPC

TU-Delft TI1400/11-PDS 7 IA-32 1.Introduction 2.Registers 3.Memory Layout 4.Instructions 5.Examples of Assembler Code for IA-32 6.Subroutines

TU-Delft TI1400/11-PDS 8 IA register structure FP0 FP7 floating - point registers R0 R7 general- purpose registers

TU-Delft TI1400/11-PDS 9 Special registers Code Segment CS Stack Segment SS DS ES FS GS Data Segments

TU-Delft TI1400/11-PDS 10 Status Register OFIF Status Register CFTFSFZF 6789 CFCarry ZFZero SFSign IOPLI/O privilege level OFOverflow IFInterrupt enable IOPL

TU-Delft TI1400/11-PDS 11 Register Naming R0EAX R1EBX R2ECX R3EDX R4 ESP R5 EBP R6 ESI R7 EDI EIP EFLAGS Data registers Pointer registers Index registers Instruction Pointer Status Register

TU-Delft TI1400/11-PDS 12 IA-32 1.Introduction 2.Registers 3.Memory Layout 4.Instructions 5.Examples of Assembler Code for IA-32 6.Subroutines

TU-Delft TI1400/11-PDS 13 Memory Memory is byte addressable Doublewords can start at any byte location Data Operands are 8 or 32 bits wide Mode is little-endian scheme (vs big-endian PowerPC)

TU-Delft TI1400/11-PDS 14 Addressable data units byte 3byte 0 310Bit Byte Doubleword 0

TU-Delft TI1400/11-PDS 15 IA-32 1.Introduction 2.Registers 3.Memory Layout 4.Instructions 5.Examples of Assembler Code for IA-32 6.Subroutines

TU-Delft TI1400/11-PDS 16 Instructions Variable length instructions 1-12 bytes Five type of instructions -Copy instructions (MOV) -Arithmetic and logic instructions -Flow control -Processor control instructions -I/O instructions Format: INSTR Rdst,Rsrc

TU-Delft TI1400/11-PDS 17 Instruction Format OpcodeAddressingDisplacementImmediate 1 or 2 bytes 1 or 4 bytes variable opcode length

TU-Delft TI1400/11-PDS 18 Addressing modes Many addressing modes: -Immediatevalue -DirectM(value) -Register[reg] -Register IndirectM([reg]) -Base with displacementM([reg]) +Disp -Index with displacementM([reg]  S +Disp) -Base with indexM([reg1]+[reg2]  S) -Base with index and M([reg1]+[reg2]  S+Disp) displacement S=1,2,4 or 8Disp= 8 or 32-bit signed number

TU-Delft TI1400/11-PDS 19 Immediate and Direct Immediate MOV EAX, 25 [EAX]  #25 MOV EAX, 3FA00H [EAX]  # 3FA00H Direct MOV EAX, loc [EAX]  M(loc) or MOV EAX, [loc] [EAX]  M(loc)

TU-Delft TI1400/11-PDS 20 Register indirect Register MOV EBX,OFFSET loc [EBX]  #loc or LEA EBX,loc [EBX]  #loc Register indirect MOV EAX,[EBX] [EAX]  M(EBX)

TU-Delft TI1400/11-PDS 21 Base with Index and Displacement MOV EAX,[EBP+ESI*4+200] EAX  M([EBP] + [ESI]*4 + #200) Operand EBP ESI

TU-Delft TI1400/11-PDS 22 Arithmetic instructions May have one or two operands ADD dst,scr meaning [dst]  [dst] + [src]

TU-Delft TI1400/11-PDS 23 Compare Used to compare values and leave register contents unchanged CMPdst, src[dst] - [src]

TU-Delft TI1400/11-PDS 24 Flow control Two basic branch instructions: JMP[loc]Branch unconditionally JG, JZ, JS, etc Branch if condition is satisfied

TU-Delft TI1400/11-PDS 25 IA-32 1.Introduction 2.Registers 3.Memory Layout 4.Instructions 5.Examples of Assembler Code for IA-32 6.Subroutines

TU-Delft TI1400/11-PDS 26 Summation example LEAEBX, NUM1[EBX]  #NUM1 MOVECX, N[EXC]  M(N) MOVEAX, 0[EAX]  #0 MOVEDI, 0[EDI]  #0 L:ADDEAX, [EBX+EDI*4]Add next number to EAX INCEDI[EDI]  [EDI] +1 DECECX[ECX]  [ECX] -1 JGLBranch if [ECX]>0 MOVSUM, EAXM(SUM)  [EAX]

TU-Delft TI1400/11-PDS 27 Sorting example int[] listarray = new list[n]; int temp; for(j=n-1, j>0, j--){ for(k=j-1, k>=0, k--){ if(list[j] > list[k]) { temp = list[k]; list[k] = list[j]; list[j] = temp; }

TU-Delft TI1400/11-PDS 28 Assembler code LEAEAX, list[EAX]  #list MOVEDI, N[EDI]  n DECEDI [EDI]  n-1 init(j) outer:MOVECX, EDI[ECX]  j DECECX [ECX]  j-1 init (k) MOVDL, [EAX+EDI]load list(j) into DL inner:CMP[EAX+ECX], DLcompare list(k) to list(j) JLEnextif list(j) >= list(k) XCNG[EAX+ECX], DLswap MOV[EAX+ECX], DL new list(j) in DL next:DECECXdecrement k JGEinnerrepeat or terminate DECEDIdecrement j JGEouterrepeat or terminate

TU-Delft TI1400/11-PDS 29 Question Why is this assembler program an incorrect translation of the Java program?

TU-Delft TI1400/11-PDS 30 IA-32 1.Introduction 2.Registers 3.Memory Layout 4.Instructions 5.Examples of Assembler Code for IA-32 6.Subroutines  really long

TU-Delft TI1400/11-PDS 31 Subroutines CALL sub Return address is saved on stack (ESP register) Return is RET [EIP]  #sub [EIP]  [ESP] [ESP]  [ESP]+4

TU-Delft TI1400/11-PDS 32 Stack instructions ESP register is used as stack pointer PUSH src [ESP]  [ESP] - #4 M([ESP])  [src] POP dst [dst]  M([ESP]) [ESP]  [ESP] + #4 PUSHAD (POPAD) push (pop) all 8 registers on (from) stack

TU-Delft TI1400/11-PDS 33 Stack frames.... PUSH NParameter n on stack 2000CALLSub1Call subroutine at N ESP EIP Note: Sub1 starts at address 2400 Stack Pointer Stack program counter stack pointer

TU-Delft TI1400/11-PDS 34 Subroutine Sub1 Sub1:PUSHEAXSave EAX PUSHEBXSave EBX MOVEAX, [EDI + 12]n to EAX DECEAX.... PUSHEAXLoad n-1 on stack L:CALLSub2Call subroutine POPNPut result in M(N) POPEBXRestore EBX POPEAXRestore EAX RETreturn

TU-Delft TI1400/11-PDS 35 Stack frame in Sub1 [EBX] [EAX] Return Address n ? ESP EIP Stack frame at arrow :PUSHEAX PUSHEBX MOVEAX, [EDI + 12] DECEAX Q What is the value op EIP? After PUSH EBX

TU-Delft TI1400/11-PDS 36 Subroutine Sub1 2400PUSHEAXSave EAX PUSHEBXSave EBX MOVEAX, [EDI + 12]n to EAX DECEAX.... PUSHEAXLoad n-1 on stack L:CALLSub2Call subroutine POPNPut result in M(N) POPEBXRestore EBX POPEAXRestore EAX RETreturn After DEC EAX

TU-Delft TI1400/11-PDS 37 Stack frame in Sub1 Stack frame at arrow [EBX] [EAX] Return Address n ? EIP n-1 EAX ESP 2400:PUSHEAX PUSHEBX MOVEAX, [EDI + 12] DECEAX After DEC EAX

TU-Delft TI1400/11-PDS 38 Subroutine Sub1 2400:PUSHEAXSave EAX PUSHEBXSave EBX MOVEAX, [EDI + 12]n to EAX DECEAX.... PUSHEAXLoad n-1 on stack L:CALLSub2Call subroutine POPNPut result in M(N) POPEBXRestore EBX POPEAXRestore EAX RETreturn After PUSH EAX

TU-Delft TI1400/11-PDS 39 Stack frame in Sub1 Stack frame at arrow n-1 [EBX] [EAX] Return Address n ? EIP n-1 EAX ESP 2400:PUSHEAX PUSHEBX MOVEAX, [EDI + 12] DECEAX.... PUSHEAX After PUSH EAX

TU-Delft TI1400/11-PDS 40 Stack frame in Sub2 Stack frame at arrow Return Address n-1 [EBX] [EAX] Return Address n ? EIP n-2 EAX ESP Sub2:MOVEAX, [EDI+4] DECEAX MOV[EDI+4], EAX RET After DEC EAX

TU-Delft TI1400/11-PDS 41 Stack frame in Sub2 Stack frame at arrow Return Address n-2 [EBX] [EAX] Return Address n ? EIP n-2 EAX ESP Sub2:MOVEAX, [EDI+4] DECEAX MOV[EDI+4], EAX RET After MOV…