CDP ECE 291 -- Spring 2000 ECE 291 Spring 2000 Lecture 4: The 80x86 Instruction Set Architecture Registers-Instructions Constantine D. Polychronopoulos.

Slides:



Advertisements
Similar presentations
Intel 8086.
Advertisements

Jump Condition.
Register In computer architecture, a processor register is a small amount of storage available on the CPU whose contents can be accessed more quickly than.
Registers of the 8086/ /2002 JNM.
Micro-Computer Applications: Jumping and Loop Dr. Eng. Amr T. Abdel-Hamid ELECT 707 Fall 2011.
Princess Sumaya Univ. Computer Engineering Dept. د. بســام كحـالــه Dr. Bassam Kahhaleh.
Department of Computer Science and Software Engineering
ACOE2511 Assembly Language Arithmetic and Logic Instructions.
80x86 Instruction Set Dr. Qiang Lin.
Addressing modes – 1 The way in which an operand is specified is called the Address Mode.
The CPU Revision Typical machine code instructions Using op-codes and operands Symbolic addressing. Conditional and unconditional branches.
Princess Sumaya University
1 Hardware and Software Architecture Chapter 2 n The Intel Processor Architecture n History of PC Memory Usage (Real Mode)
1 ICS 51 Introductory Computer Organization Fall 2006 updated: Oct. 2, 2006.
3-1 ECE 424 Design of Microprocessor-Based Systems Haibo Wang ECE Department Southern Illinois University Carbondale, IL Intel 8088 (8086) Microprocessor.
Flow Control Instructions
Microcomputer & Interfacing Lecture 3
Microprocessor Systems Design I
Microprocessor Systems Design I Instructor: Dr. Michael Geiger Spring 2013 Lecture 4: 80386DX memory, addressing.
CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 1 Intel IA-32 vs Motorola
An Introduction to 8086 Microprocessor.
1/2002JNM1 Positional Notation (Hex Digits). 1/2002JNM2 Problem The 8086 has a 20-bit address bus. Therefore, it can access 1,048,576 bytes of memory.
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR1 Addressing Mode.
Types of Registers (8086 Microprocessor Based)
CE302 MICROPROCESSORS Levent EREN Izmir University of Economics.
Dr. José M. Reyes Álamo 1.  Review: ◦ of Comparisons ◦ of Set on Condition  Statement Labels  Unconditional Jumps  Conditional Jumps.
ECE291 Computer Engineering II Lecture 3 Josh Potts University of Illinois at Urbana- Champaign.
(Flow Control Instructions)
1 ICS 51 Introductory Computer Organization Fall 2009.
UHD:CS2401: A. Berrached1 The Intel x86 Hardware Organization.
Microprocessors The ia32 User Instruction Set Jan 31st, 2002.
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.
ECE291 Computer Engineering II Lecture 3 Dr. Zbigniew Kalbarczyk University of Illinois at Urbana- Champaign.
LEA instruction The LEA instruction can be used to get the offset address of a variable Example ORG 100h MOV AL, VAR1 ; check value of VAR1 by moving it.
Review of Assembly language. Recalling main concepts.
Conditional Loop Instructions, Conditional Structures
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.
Assembly 06. Outline cmp (review) Jump commands test mnemonic bt mnemonic Addressing 1.
2/20/2016CAP 2211 Flow Control Instructions. 2/20/2016CAP 2212 Transfer of Control Flow control instructions are used to control the flow of a program.
Jumps, Loops and Branching. Unconditional Jumps Transfer the control flow of the program to a specified instruction, other than the next instruction in.
Internal Programming Architecture or Model
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
Selection and Iteration Chapter 8 S. Dandamudi To be used with S. Dandamudi, “Introduction to Assembly Language Programming,” Second Edition, Springer,
CS-401 Computer Architecture & Assembly Language Programming
CSC 221 Computer Organization and Assembly Language
Assembly language programming
Format of Assembly language
Introduction to 8086 Microprocessor
Today we are going to discuss about,
Instruksi Set Prosesor 8088
ADDRESSING MODES.
Microprocessor and Assembly Language
EE3541 Introduction to Microprocessors
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Assembly IA-32.
INSTRUCTION SET.
Assembly Language Programming Part 2
ADDRESSING MODES.
Intel 8088 (8086) Microprocessor Structure
Microprocessor and Assembly Language
Processor Processor characterized by register set (state variables)
Introduction to Assembly Language
Data Addressing Modes • MOV AX,BX; This instruction transfers the word contents of the source-register(BX) into the destination register(AX). • The source.
Flags Register & Jump Instruction
Intel 8088 (8086) Microprocessor Structure
CS-401 Computer Architecture & Assembly Language Programming
Flow Control Instructions
Intel 8086.
Chapter 8: Instruction Set 8086 CPU Architecture
Computer Architecture and Assembly Language
Presentation transcript:

CDP ECE Spring 2000 ECE 291 Spring 2000 Lecture 4: The 80x86 Instruction Set Architecture Registers-Instructions Constantine D. Polychronopoulos

CDP ECE Spring 2000 Instruction Format ALL instructions have the following specifiers: –OPCODE: a field that specifies the operation to be done –OPERAND(S): one or more fields giving the operands or the location where the operands can be found –DESTINATION: a field that specifies the location (register or memory) where the result of the operation is to be stored –[Descriptor fields]: Special bit specifiers that allow for different interpretation of the same field (e.g. register or offset specifier) ASSEMBLY INSTRUCTIONS: symbolic (mnemonic) versions of machine instructions MACHINE INSTR. Or BINARY CODE: Binary codes that give the specific value for each of the above fields Assembly program ==> ASSEMBLER (MASM) ==> Machine code

CDP ECE Spring 2000 Instruction Format: x86 In 80x86 instructions can vary in length from 8-bits (1b) to more than 100-bits (13b) REAL MODE: –Default instruction size is 16-bits 16-bit registers & 16-bit offset fields RPOTECTED MODE: –Default instruction size is 32-bits (x386 and above) 32-bit registers & 32-bit offset fields –D-bit in descriptor specifies real or protected mode: D=0: (real-mode) 16-bit instructions, register values and addresses D=1: (protected mode) 32-bit instructions, reg. values and addresses

CDP ECE Spring 2000 Addressing Modes Immediate: Move an immediate value (in the field itself) to the destination register or memory location: –MOVAX, 7F55H Register: Move a byte or word from the source register to the destination register or memory location: –MOVAX, BX Direct: Move a byte/word from a memory location to a register or memory location: –MOVAX, [7777H]

CDP ECE Spring 2000 Addressing Modes Base-relative or indexed: Move a byte/word between a register and mem. Location specified by an index (DI or SI) or base register (BP or BX): –MOVAX, [BX] Register-relative: Move a byte/word between a register and mem. Location specified by an index OR base register + offset: –MOVAX, [DI H] Base-relative and indexed: Move a byte/word between a register and mem. Location specified by a base register PLUS an index register PLUS offset: –MOVAX, [SP + DI H]

CDP ECE Spring 2000 Addressing Modes: Register Instruction CommentAddr. Mode Memory Cont. OP Dest Source MOV AX, BX Move to AX the 16-bit value in BX Register 89 D8 MOV AX, DI Move to AX the 16-bit value in DI Register89F8 MOV AH, AL Move to AH the 8-bit value in AL Register88C4

CDP ECE Spring 2000 Addressing Modes - Immediate Instruction Comment Addr. Mode Memory Cont. OP Dest Source MOV AH, 12H Move to AH the byte value 12HImmediateB412 MOV AX, 1234H Move to AX the value 1234H ImmediateB MOV AX, CONST Move to AX the constant CONSTImmediate B8LSB MSB MOV AX, OFFSET x Move to AX the address (offset) of Immediate B 8 LSB MSB variable x MASM Notation

CDP ECE Spring 2000 Addressing Modes: Direct & Indexed Instruction Comment Addr. Mode Memory Cont. OP Dest Source MOV AX, [1234H] Move to AX the value at memoryDirect A location 1234H (uses default segment, DS) MOV AX, x Move to AX the value of M[x] Direct A1 LSB MSB (uses default segment, DS) MASM Notation MOV x, AX Move to M[x] the value of AXDirect A3 LSB MSB (uses default segment, DS) MASM Notation MOV AX, [DI] Move to AX the value at M[DI]Indexed8B 05 (uses default segment, DS) MOV [DI], AX Move to M[DI] the value AXIndexed89 05 (uses default segment, DS)

CDP ECE Spring 2000 Instruction Comment Addr. Mode Memory Cont. OP Dest Source MOV AX, [BX] Move to AX the value M[BX] Base-relative8B 07 (uses default segment, DS) MOV [BX], AX Move to M[BX] the value AX Base-relative (uses default segment, DS) MOV AX, [BP] Move to AX the value of M[BP] Base-relative 8B 46 (uses stack segment, SS) MOV [BP], AX Move to M[BP] the value of AX Base-relative (uses stack segment, SS) Addressing Modes: Base-relat.

CDP ECE Spring 2000 Instruction CommentAddr. ModeMemory Contents OP Dest Source MOV AX, offs[BX] Move to AX the value M[offs+BX] Base-relative 8B 87 LSB MSB (uses default segment, DS) Direct MOV offs[BX], AX Move to M[offs+BX] the value AX Base-relative LSB MSB (uses default segment, DS) Direct MOV AX, [BX+DI] Move to AX the value M[BX+DI] Base-relative 8B 01 (uses default segment, DS) Direct MOV [BX+DI], AX Move to M[BX+DI] the value Base-relative AX (uses default segment, DS) Indexed MOV AX, [BX+DI+1234H] Move to AX the value pointed to by Base-relative 8B M[BX+DI+1234H] Indexed Direct (uses default segment, DS) Addressing Modes: Base-relat./Direct/Indexed-Direct

CDP ECE Spring 2000 Memory Model: Real & Protected Modes Due to downward compatibility with previous generations all x86 processors support real address mode which allows direct addressing of only 1Mb of memory (20 bits) - recall that: –Memory address = segment register + offset where segment reg. Is 16-bits left-shifted by 4 bits - hence a 20- bit address. Protected mode allows extended memory of 4Gb or even 64Gb: An SDT (segment description table) is used to get the starting address of memory segment to be addressed. The original DS or CS register is used as an index into SDT whose entry points to actual memory segment. Offset is added to latter to form address: –Memory addr. = SDT[segment register] + offset

CDP ECE Spring 2000 Memory Model (Cont.) ALL memory is allocated and managed in units of 64Kb segments Segments are used to organize different partitions of memory for different objects (with different access restrictions): –user code & user data –user stack area –system code and data –memory-mapped I/O devices and other peripherals The segment starting address must first be loaded to DS or CS before any access to that segment via x86 mem. Instructions. Before x386 only real memory addressing was available. But protected mode was introduced starting with the 32-bit architectures. Default is always real mode for all x86 processors.

CDP ECE Spring 2000 Instruction Format ALL instructions have the following specifiers: –OPCODE: a field that specifies the operation to be done –OPERAND(S): one or more fields giving the operands or the location where the operands can be found –DESTINATION: a field that specifies the location (register or memory) where the result of the operation is to be stored –[Descriptor fields]: Special bit specifiers that allow for different interpretation of the same field (e.g. register or offset specifier) ASSEMBLY INSTRUCTIONS: symbolic (mnemonic) versions of machine instructions MACHINE INSTR. Or BINARY CODE: Binary codes that give the specific value for each of the above fields Assembly program ==> ASSEMBLER (MASM) ==> Machine code

CDP ECE Spring 2000 Instruction Format: x86 In 80x86 instructions can vary in length from 8-bits (1b) to more than 100-bits (13b) REAL MODE: –Default instruction size is 16-bits 16-bit registers & 16-bit offset fields RPOTECTED MODE: –Default instruction size is 32-bits (x386 and above) 32-bit registers & 32-bit offset fields –D-bit in descriptor specifies real or protected mode: D=0: (real-mode) 16-bit instructions, register values and addresses D=1: (protected mode) 32-bit instructions, reg. values and addresses

CDP ECE Spring 2000 Unconditional Jump (JMP) Short jump: 2-byte jump instr. - allows short jumps within memory locations [-128:+127] from the location following the jump instr.: –JMP SHORT Target_Label Near jump: 3-byte jump instr. - supports jumps within [- 32K:+32K] bytes from current location: –JMP Label Far jump: 5-byte instruction allowing jumps anywhere within 4Gb of address space: –JMP Label OPCODE DISP. OPCODE DISP-lowDISP-high OPCODE DISP-lowDISP-high CS low CS high

CDP ECE Spring 2000 Conditional Jumps A conditional Jump instruction tests a condition bit (FLAGS) and sets the IP to a specified address (given in a field of the instruction). Otherwise, IP is left unchanged and the next instruction is fetched from IP+1 (in byte addressable mode) Hence: A conditional jump is materialized by TWO instructions: –One that “compares” values or does an arith./logic op and sets bits of FLAGS accordingly, and –One that carries out the Jump based on the outcome of the operation or the bit value of selected FLAGS FLAGS used by conditional branches: –S (sign) –Z (zero) –C (carry) –P (parity) –O (overflow)

CDP ECE Spring 2000 The CMP is used to compare two values in signed or unsigned form and sets one or more of the previous FLAG bits based on the outcome of the comparison: CMP Operand_1 Operand_2 CMP (Comparison)

CDP ECE Spring 2000 Comparing Signed Integers CMP AX, BX –Sign bit (S) will be set if AX-BX has a 1 in MSB –Overflow bit (O) is set if AX-BX result is out of range (-2 15, ) JS Target_label: –Check S bit and if set then jump to Target_label (i.e. sign bit is 1) JL (Jump on less than): –JL takes the jump if (S XOR O) is 1 (jump is taken even on an overflow because overflow in a CMP or SUB instruction can happen only when first operand is a negative number and second operand is a positive number - hence their SUB becomes an addition that may overflow)

CDP ECE Spring 2000 Jump Instruction Semantics If num_1 & num_2 are unsigned we say num_1 is above num_2 if num_1 > num_2 (otherwise it’s below). If num_1 & num_2 are signed, num_1 is greater than num_2 if num_1 > num_2 (otherwise it’s less). Notation of jump instructions: –J = JUMP –N= Not –E= Equal –A/B= Above/below –G/L= greater/less

CDP ECE Spring 2000 Jump Instructions InstructionDescriptionCondition JA=JNBEJump if aboveC=0 & Z=0 Jump if not below or equal JBE=JNAJump if below or equalC=1 | Z=1 Jump if not above JAE=JNB=JNCJump if above or equalC=0 Jump if not below Jump if no Carry JB=JNA=JCJump if belowC=1 Jump if not above Jump if Carry JE=JZJump if equalZ=1 Jump if Zero (set) JNE=JNZJump if not equalZ=0 Jump if not Zero JSJump if SignS=1

CDP ECE Spring 2000 Jump Instructions (Cont.) InstructionDescriptionCondition JNSJump Not SignS=0 JOJump if Overflow O=1 JNOJump if No OverflowO=0 JG=JNLEJump if greaterS=0 & Z=0 Jump if not less or equal JGE=JNLJump if greater or equalS=0 Jump if not less JL=JNGEJump if lessS XOR O Jump if Not greater or eq. JLE=JNGJump if less or equalS XOR O | z=1 Jump if not greater JCXZJump if reg. CX=0CX=0

CDP ECE Spring 2000 Branch Instructions

CDP ECE Spring 2000 Case Statements

CDP ECE Spring 2000 Repeat/Until & While Looping

CDP ECE Spring 2000 Multiplication in x86

CDP ECE Spring 2000 Multiplication

CDP ECE Spring 2000 Division

CDP ECE Spring 2000 Stack

CDP ECE Spring 2000 Stack Frame Organization

CDP ECE Spring 2000 Stack Frame Layout