26-Nov-15 (1) CSC2510 - Computer Organization Lecture 6: Pentium IA-32.

Slides:



Advertisements
Similar presentations
Machine Instructions Operations
Advertisements

COMP 2003: Assembly Language and Digital Logic
Microprocessors General Features To be Examined For Each Chip Jan 24 th, 2002.
C Programming and Assembly Language Janakiraman V – NITK Surathkal 2 nd August 2014.
Computer Organization & Assembly Language
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 6: Conditional Processing (c) Pearson Education, All rights reserved. You may modify.
1 ICS 51 Introductory Computer Organization Fall 2006 updated: Oct. 2, 2006.
Assembly Language for Intel-Based Computers
Microprocessors Introduction to ia32 Architecture Jan 31st, 2002.
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.
Microcomputer & Interfacing Lecture 3
Microprocessor Systems Design I
Unit-1 PREPARED BY: PROF. HARISH I RATHOD COMPUTER ENGINEERING DEPARTMENT GUJARAT POWER ENGINEERING & RESEARCH INSTITUTE Advance Processor.
CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 1 Intel IA-32 vs Motorola
Instruction Set Design by Kip R. Irvine (c) Kip Irvine, All rights reserved. You may modify and copy this slide show for your personal use,
1 IA-32
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR1 Addressing Mode.
CSC 221 Computer Organization and Assembly Language
Low Level Programming Lecturer: Duncan Smeed Overview of IA-32 Part 1.
Faculty of Engineering, Electrical Department,
Dr. José M. Reyes Álamo 1.  Review: ◦ Statement Labels ◦ Unconditional Jumps ◦ Conditional Jumps.
The x86 Architecture Lecture 15 Fri, Mar 4, 2005.
Module 3 Instruction Set Architecture (ISA): ISA Level Elements of Instructions Instructions Types Number of Addresses Registers Types of Operands.
Computer Architecture and Organization
1 ICS 51 Introductory Computer Organization Fall 2009.
Microprocessors The ia32 User Instruction Set Jan 31st, 2002.
Oct. 25, 2000Systems Architecture I1 Systems Architecture I (CS ) Lecture 9: Alternative Instruction Sets * Jeremy R. Johnson Wed. Oct. 25, 2000.
Computer Architecture Lecture 03 Fasih ur Rehman.
1 Logic, Shift, and Rotate Instructions Read Sections 6.2, 7.2 and 7.3 of textbook.
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.
Assembly Language. Symbol Table Variables.DATA var DW 0 sum DD 0 array TIMES 10 DW 0 message DB ’ Welcome ’,0 char1 DB ? Symbol Table Name Offset var.
3.4 Addressing modes Specify the operand to be used. To generate an address, a segment register is used also. Immediate addressing: the operand is a number.
MOV Instruction MOV destination,source  MOV AX,BX  MOV SUM,EAX  MOV EDX,ARRAY[EBX][ESI]  MOV CL,5  MOV DL,[BX]
Computer Organization & Assembly Language University of Sargodha, Lahore Campus Prepared by Ali Saeed.
Introduction to Intel IA-32 and IA-64 Instruction Set Architectures.
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
Intel MP Organization. Registers - storage locations found inside the processor for temporary storage of data 1- Data Registers (16-bit) AX, BX, CX, DX.
Chapter 8 String Operations. 8.1 Using String Instructions.
1-Oct-16 (1) CSC Computer Organization Lecture 6: Pentium IA-32 Additional slides.
1 CSCI 2510 Computer Organization Memory Addressing and Assembly Instruction Basics.
CSC 221 Computer Organization and Assembly Language
Computer Architecture and Assembly Language
William Stallings Computer Organization and Architecture 6th Edition
Data Transfers, Addressing, and Arithmetic
Chapter 11 Instruction Sets
Microprocessor Systems Design I
COMP2121: Microprocessors and Interfacing
Instruksi Set Prosesor 8088
Microprocessor and Assembly Language
Microprocessor Systems Design I
Assembly IA-32.
INSTRUCTION SET.
Assembly Language Programming Part 2
# 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 =
William Stallings Computer Organization and Architecture 8th Edition
Processor Processor characterized by register set (state variables)
Computer Organization and Assembly Language (COAL)
BIC 10503: COMPUTER ARCHITECTURE
Data Addressing Modes • MOV AX,BX; This instruction transfers the word contents of the source-register(BX) into the destination register(AX). • The source.
Introduction to Intel IA-32 and IA-64 Instruction Set Architectures
ECEG-3202 Computer Architecture and Organization
Shift, Multiply, and Divide
X86 Assembly Review.
CNET 315 Microprocessor & Assembly Language
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
Chapter 8: Instruction Set 8086 CPU Architecture
Computer Organization
Computer Architecture and System Programming Laboratory
Chapter 10 Instruction Sets: Characteristics and Functions
Presentation transcript:

26-Nov-15 (1) CSC Computer Organization Lecture 6: Pentium IA-32

26-Nov-15 (2) Introduction Intel is by far the most successful computer architecture to date Describe Intel architecture (IA) 32-bit machines (hence IA-32) First IA-32 was the (1985), then (1989), Pentium (1993), Pentium Pro (1995), Pentium II (1997), Pentium III (1999), Pentium 4 (2000), Intel Core (2006)

26-Nov-15 (3) Registers and Addressing Memory is byte addressable using 32-bit addresses Instructions operate on data operands of 8 or 32 bits (byte and doubleword) Little endian Multiple byte data operands may start at any byte address (no alignment necessary)

26-Nov-15 (4) 8x 32-bit general purpose registers 8x floating point registers (doubleword or quadword) with extension to 80-bits internally for increased accuracy Memory divided into segments and controlled by segment registers Instruction pointer = program counter IA-32 Registers

26-Nov-15 (5) Segments –Code segment holds program instructions –Data segment holds data operands –Stack segment holds processor stack Status register –Condition codes CF, ZF, SF, OF –Program execution mode bits (IOPL, IF, TF) associated with IO and interrupts

26-Nov-15 (6) Register Names Registers in early processors map to IA32 registers Grouped into data, pointer and index registers The E-prefix means a 32-bit version of the register We will use this naming convention Figure 3.38.Compatibility of the IA-32 register structure with earlier Intel processor register structures.

26-Nov-15 (7) IA-32 Addressing modes

26-Nov-15 (8) Examples Immediate –MOV EAX,25 (decimal) –MOV EAX,3FA00H (the H suffix means hexadecimal) –NUM EQU 25 MOV EAX,NUM –MOV EBX,OFFSET LOC (where LOC is an address label) Direct –MOV EAX,[LOC] (brackets not needed if LOC is an address label)

26-Nov-15 (9) Examples Register –MOV EAX,EBX Register indirect –MOV EAX,[EBX] Immediate, direct, register and register indirect are the basic addressing modes. The ones that follow give more flexibility.

26-Nov-15 (10) Other addressing modes Base with displacement –MOV EAX,[EBP+60] (doubleword) –MOV AL,[EBP+4] (byte) Base with index and displacement –MOV EAX,[EBP+ESI*4+200] Have both of these modes as base with displacement can be encoded with 1 less byte

26-Nov-15 (11) Base with index + disp = displacement 1000 doubleword 1060 Operand Main memory address Base register EBP Operand address (EA) = [EBP] + 60 (a) Base with displacement mode, expressed as [EBP + 60] * * * * * * = displacement Operand Base register EBP Operand address (EA) = [EBP] + [ESI]  (b) Base with displacement and index mode, expressed as [EBP + ESI * ] 1360 List of 4-byte (doubleword) data items 40 Index register ESI scale factor = = [Index register]  4 * * * * * * * * * * * * * * * * * * * * * * * *

26-Nov-15 (12) IA-32 Instructions MOV dst,src (dst ← [src]) ADD dst,src (dst ← [dst] + [src]) SUB dst,src (dst ← [dst] - [src]) JG LOOPSTART (G means greater than 0) MOV EBX,OFFSET LOCATION –Loads address of label LOCATION into EBX –What if it is not a fixed address? Use load effective address which is computed dynamically. LEA EBX,[EBP+12]

26-Nov-15 (13) Operands Note only one operand can be in memory so C ← [A] + [B] –MOV EAX,A ADD EAX,B MOV C,EAX

26-Nov-15 (14) A simple program LEAEBX,NUM1Initializebase(EBX)and MOVECX,Ncounter(ECX)registers. MOVEAX,0Clearaccumulator(EAX) MOVEDI,0andindex(EDI)registers. STARTADD:ADDEAX,[EBX+EDI4]AddnextnumberintoEAX. INCEDIIncrementindexregister. DECECXDecrementcounterregister. JGSTARTADDBranchbackif[ECX]>0. MOVSUM,EAXStoresuminmemory. *

26-Nov-15 (15) Improve program The LOOP instruction –LOOP STARTADD –Decrements ECX and branches to STARTADD if ECX≠0 –Equivalent to DEC ECX JNZ STARTADD Can use a single register rather than EDI,ECX –Should choose ECX as it can be used with LOOP –Do the loop backwards

26-Nov-15 (16) Improved version LEAEBX,NUM1LoadbaseregisterEBXand SUBEBX,4adjusttoholdNUM14. MOVECX,NInitializecounter/index(ECX). MOVEAX,0Cleartheaccumulator(EAX). STARTADD:ADDEAX,[EBX+ECX4]AddnextnumberintoEAX. LOOPSTARTADDDecrementECXandbranch backif[ECX]>0. MOVSUM,EAXStoresuminmemory. (b) More compact program * –

26-Nov-15 (17) Machine Instruction Format General format of instructions is as below Ranges from 1 to 12 bytes Most instructions only require 1 opcode byte Instructions that only use one register to generate effective address of operand only take 1 byte Need to be able to figure out length of instruction

26-Nov-15 (18) One byte instructions Instructions that only use one register to generate effective address of operand only take 1 byte –E.g. INC EDI, DEC ECX –Registers specified by 3-bit codes in the single opcode byte

26-Nov-15 (19) Immediate mode encoding MOV EAX,820 –5 bytes –One byte opcode to specify move operation, that a 32-bit operand is used and the name of the destination register –4-byte immediate value of 820 MOV DL,5 –2 bytes as immediate value is 8-bits MOV DWORD PTR [EBP+ESI*4+DISP],10 –DWORD PTR (doubleword) specifies a 32-bit operation

26-Nov-15 (20) Displacement fields One operand of a two-operand instruction usually a register. Other can be register or memory Two exceptions where both can be in memory –Source operand is immediate and destination is in memory –Push/pop When both operands are in registers, only one addressing mode byte needed –ADD EAX,EBX encoded in 2 bytes –One for opcode and the other for addressing mode (specifies the two registers)

26-Nov-15 (21) Displacement fields MOV ECX,N –6 bytes –Opcode –Addressing mode (specifies direct mode and destination register) –Four bytes for address N –A direction bit in the opcode specifies which operand is the source ADD EAX,[EBX+EDI*4] –3 bytes –Opcode –Two addressing mode bytes as two registers used to generate effective address of source operand

Summary Register and address Addressing modes IA-32 Instructions – Operands –MOE, ADD, LOOP etc. Machine Instruction format –OPCode, Immediate, addressing and displacement 26-Nov-15 (22)

26-Nov-15 (23) Conditional jumps DEC ECX JG STARTADD –JG relates to results of the most recently executed data manipulation instruction (in this case DEC ECX) –Jumps if result was > 0 (ECX > 0 in this case) –Assume STARTADD was 1000 and address after the JG is 1007, relative address is -7 and is stored in the instruction –Since only one byte is used, jump range is -128 to 127. A 4-byte offset is used if the address is outside this range –Other jumps such as jump if equal to 0 (JZ or JE), jump if sign bit is set (i.e. result was negative JS) etc

26-Nov-15 (24) Compare Instruction CMP dst,src –[dst]-[src] –Only used to set condition codes –Neither operand changed

26-Nov-15 (25) Unconditional jump JMP ADDR –One byte or four byte offset forms just list JG –More powerful addressing modes also allowed e.g. JMP [JUMPTABLE+ESI*4] (index with displacement)

26-Nov-15 (26) Logical/Shift/Rotate AND EBX,EAX –E.g. if EAX=0000FFFFH and EBX=02FA62CAH what is the result? NOT EBX SHL dst,count –Also SHR, SAL (same as SHL), SAR ROL, ROR, RCL, RCR

26-Nov-15 (27) Digit Packing LEAEBP,LOCEBPpointstofirstbyte. MOVAL,[EBP]LoadfirstbyteintoAL. SHLAL,4Shiftleftby4bitpositions. MOVBL,[EBP+1]LoadsecondbyteintoBL. ANDBL,0FHClearhigh-order4bitstozero. ORAL,BLConcatenatetheBCDdigits. MOVPACKED,ALStoretheresult.

26-Nov-15 (28) I/O Operations READWAITBT INSTATUS,3 JNC READWAIT MOV AL,DATAIN ; BT transfers INSTATUS bit 3 to the carry flag WRITEWAITBT OUTSTATUS,3 JNC WRITEWAIT MOV DATAOUT,AL

26-Nov-15 (29) MEMORY MAPPED I/O

26-Nov-15 (30) ISOLATED I/O IN and OUT instructions used only for I/O Addresses for these instructions are in a separate address space to other instructions IN REG,DADDR and OUT DEVADDR,REG –REG must be AL or EAX –16-bit address space, if 0-255, specified in the opcode (takes 2 bytes) –Otherwise use DX for DADDR e.g. IN REG,DX (IN REG,300 is not allowed because 300 > 255 and doesn’t fit in 8-bits)