Chapter 8: Instruction Set 8086 CPU Architecture

Slides:



Advertisements
Similar presentations
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.
Advertisements

Registers of the 8086/ /2002 JNM.
Introduction to 8086 Microprocessor
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#3) By Dr. Syed Noman.
Princess Sumaya Univ. Computer Engineering Dept. د. بســام كحـالــه Dr. Bassam Kahhaleh.
ACOE2511 Assembly Language Arithmetic and Logic Instructions.
Gursharan Singh Tatla 21-Nov-20101www.eazynotes.com.
Princess Sumaya University
1 ICS 51 Introductory Computer Organization Fall 2006 updated: Oct. 2, 2006.
9-1 ECE 424 Design of Microprocessor-Based Systems Haibo Wang ECE Department Southern Illinois University Carbondale, IL x86 Instructions Part.
An Introduction to 8086 Microprocessor.
Types of Registers (8086 Microprocessor Based)
Faculty of Engineering, Electrical Department,
Arithmetic Flags and Instructions
Executing and Linking an assembly program. Lesson plan Review Program logic and control Practice exercise Assembling, Linking and Executing Programs Practice.
Click to add Title Comunicación y Gerencia Click To add Subtitle Click to add Text Fundamentals of Assembly Language.
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.
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.
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.
Microprocessor MA Rahim Khan Computer Engineering and Networks Department.
Introduction to Microprocessors Chapter 3. Programming Model (8086)  Shows the various internal registers that are accessible to the programmer.
Assembly Language Wei Gao. Assembler language Instructions.
ΜComputer Structure μProcessor Memory Bus System I/O Ports.
Practical Session 2 Computer Architecture and Assembly Language.
Chapter 12 Processor Structure and Function. Central Processing Unit CPU architecture, Register organization, Instruction formats and addressing modes(Intel.
Format of Assembly language
Chapter Nov-2010
Data Transfers, Addressing, and Arithmetic
UNIT Architecture M.Brindha AP/EIE
Introduction to 8086 Microprocessor
Practical Session 2.
8086 Microprocessor.
Instruksi Set Prosesor 8088
ADDRESSING MODES.
Microprocessor and Assembly Language
EE3541 Introduction to Microprocessors
Morgan Kaufmann Publishers Computer Organization and Assembly Language
INSTRUCTION SET.
Assembly IA-32.
INSTRUCTION SET.
More on logical instruction and
Assembly Language Programming Part 2
ADDRESSING MODES.
Intel 8088 (8086) Microprocessor Structure
Processor Processor characterized by register set (state variables)
Assembly Lang. – Intel 8086 Addressing modes – 1
Defining Types of data expression Dn [name] expression Dn [name]
Symbolic Instruction and Addressing
CS 301 Fall 2002 Assembly Instructions
Introduction to Assembly Language
Flags Register & Jump Instruction
Intel 8088 (8086) Microprocessor Structure
8086 Registers Module M14.2 Sections 9.2, 10.1.
CS-401 Computer Architecture & Assembly Language Programming
اصول اساسی برنامه نویسی به زبان اسمبلی
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Symbolic Instruction and Addressing
CS 301 Fall 2002 Computer Organization
Shift & Rotate Instructions)
Program Logic and Control
Program Logic and Control
Symbolic Instruction and Addressing
Computer Architecture CST 250
UNIT-II Assembly Language Programs Involving Logical
Chapter 6 –Symbolic Instruction and Addressing
CNET 315 Microprocessor & Assembly Language
Chapter 7 –Program Logic and Control
Chapter 7 –Program Logic and Control
Computer Architecture and Assembly Language
Presentation transcript:

Chapter 8: Instruction Set 8086 CPU Architecture EMT 475/3 Computer Organization & Architecture Chapter 8: Instruction Set 8086 CPU Architecture Wan Mokhdzani Wan Nor Haimi Mohd Natasha Norizan PPK Mikroelektronik wanmokhkdzani@unimap.edu.my natasha@unimap.edu.my

Assembly Language Assembly language is a low level programming language. The computer architecture must be understood before using the assembly language.

8086 Structure

8086 Architecture

8 General Purpose Registers AX - the accumulator register (divided into AH / AL). BX - the base address register (divided into BH / BL). CX - the count register (divided into CH / CL). DX - the data register (divided into DH / DL). SI - source index register. DI - destination index register. BP - base pointer. SP - stack pointer.

Segment Register CS - points at the segment containing the current program. DS - generally points at segment where variables are defined. ES - extra segment register, it's up to a coder to define its usage. SS - points at the segment containing the stack

8086 Architecture

MOV Instruction copies the second operand (source) to the first operand (destination). the source operand can be an immediate value, general-purpose register or memory location. the destination register can be a general-purpose register, or memory location. both operands must be the same size, which can be a byte or a word

MOV Instruction MOV REG, memory MOV memory, REG MOV REG, REG MOV memory, immediate MOV REG, immediate REG: AX, BX, CX, DX, AH, AL, BL, BH, CH, CL, DH, DL, DI, SI, BP, SP.

MOV Instruction for segment registers only these types of MOV are supported: MOV SREG, memory MOV memory, SREG MOV REG, SREG MOV SREG, REG SREG: DS, ES, SS, and only as second operand: CS.

Variables Variables is a memory location. Syntax for variable declaration name DB value name DW value DB - stays for Define Byte. DW - stays for Define Word.

Arrays Arrays can be seen as chains of variables Syntax for variable declaration To access the value of any element in array, use square brackets, for example: MOV AL, a[3]  You can also use any of the memory index registers BX, SI, DI, BP, for example: MOV SI, 3 MOV AL, a[SI]

Obtaining Address of Variable There is LEA (Load Effective Address) instruction and alternative OFFSET operator. Both OFFSET and LEA can be used to get the offset address of the variable. LEA is more powerful because it also allows you to get the address of an indexed variables. Getting the address of the variable can be very useful in some situations, for example when you need to pass parameters to a procedure. 

Index Register The pointer and index group are all 16-bit registers (you cannot access the low or high bytes alone). These registers are used as memory pointers. Sometimes a pointer register will be interpreted as pointing to a memory byte and at other times a memory word. As you will see, the 8086 always stores words with the high-order byte in the high-order word address.

ARITHMETIC & LOGIC INSTRUCTIONS Carry Flag (CF) - set to 1 when there is an unsigned overflow. For example when you add bytes 255 + 1 (result is not in range 0...255). When there is no overflow this flag is set to 0.  Zero Flag (ZF) - set to 1 when result is zero. For none zero result this flag is set to 0.  Sign Flag (SF) - set to 1 when result is negative. When result is positive it is set to 0. Actually this flag take the value of the most significant bit.  Overflow Flag (OF) - set to 1 when there is a signed overflow. For example, when you add bytes 100 + 50 (result is not in range -128...127).  Parity Flag (PF) - this flag is set to 1 when there is even number of one bits in result, and to 0 when there is odd number of one bits. Even if result is a word only 8 low bits are analyzed!  Auxiliary Flag (AF) - set to 1 when there is an unsigned overflow for low nibble (4 bits).  Interrupt enable Flag (IF) - when this flag is set to 1 CPU reacts to interrupts from external devices.  Direction Flag (DF) - this flag is used by some instructions to process data chains, when this flag is set to 0 - the processing is done forward, when this flag is set to 1 the processing is done backward.   

Processor Status Register .

ARITHMETIC & LOGIC INSTRUCTIONS First group: ADD, SUB,CMP, AND, TEST, OR, XOR These types of operands are supported: REG, memory memory, REG REG, REG memory, immediate REG, immediate REG: AX, BX, CX, DX, AH, AL, BL, BH, CH, CL, DH, DL, DI, SI, BP, SP. After operation between operands, result is always stored in first operand. CMP and TEST instructions affect flags only and do not store a result (these instruction are used to make decisions during program execution).   

ARITHMETIC & LOGIC INSTRUCTIONS These instructions affect these flags only:  CF, ZF, SF, OF, PF, AF. ADD - add second operand to first.  SUB - Subtract second operand to first.  CMP - Subtract second operand from first for flags only.  AND - Logical AND between all bits of two operands. TEST - The same as AND but for flags only.  OR - Logical OR between all bits of two operands. XOR - Logical XOR (exclusive OR) between all bits of two operands.      

ARITHMETIC & LOGIC INSTRUCTIONS Second group: MUL, IMUL, DIV, IDIV MUL and IMUL instructions affects flags CF and OF   For DIV and IDIV flags are undefined. MUL - Unsigned multiply: when operand is a byte: AX = AL * operand. when operand is a word: (DX AX) = AX * operand. IMUL - Signed multiply: when operand is a byte: AX = AL * operand. when operand is a word: (DX AX) = AX * operand. . .      

ARITHMETIC & LOGIC INSTRUCTIONS DIV - Unsigned divide: when operand is a byte: AL = AX / operand AH = remainder (modulus).  when operand is a word: AX = (DX AX) / operand DX = remainder (modulus).  IDIV - Signed divide: when operand is a word: AX = (DX AX) / operand DX = remainder (modulus). .    

ARITHMETIC & LOGIC INSTRUCTIONS Third group: INC, DEC, NOT, NEG INC, DEC instructions affect these flags only:        ZF, SF, OF, PF, AF. NOT instruction does not affect any flags! NEG instruction affects these flags only:        CF, ZF, SF, OF, PF, AF. NOT - Reverse each bit of operand.  NEG - Make operand negative (two's complement). Actually it reverses each bit of operand and then adds 1 to it. For example 5 will become -5, and -2 will become 2.    

Program Flow Control Unconditional Jumps The basic instruction that transfers control to another point in the program is JMP.  The basic syntax of JMP instruction: JMP label To declare a label in your program, just type its name and add ":" to the end, label cannot start with a number, for example here are 3 legal label definitions: label1: label2: a: Short Conditional Jumps Short Conditional Jumps are divided in three groups, first group just test single flag, second compares numbers as signed, and third compares numbers as unsigned.      

Program Flow Control Short Conditional Jumps Jump instructions that test single flag      Instruction Description Condition Opposite Instruction JZ , JE Jump if Zero (Equal). ZF = 1 JNZ, JNE JC , JB, JNAE Jump if Carry (Below, Not Above Equal). CF = 1 JNC, JNB, JAE JS Jump if Sign. SF = 1 JNS JO Jump if Overflow. OF = 1 JNO JPE, JP Jump if Parity Even. PF = 1 JPO JNZ , JNE Jump if Not Zero (Not Equal). ZF = 0 JZ, JE JNC , JNB, JAE Jump if Not Carry (Not Below, Above Equal). CF = 0 JC, JB, JNAE Jump if Not Sign. SF = 0 Jump if Not Overflow. OF = 0 JPO, JNP Jump if Parity Odd (No Parity). PF = 0

Software Website: http://emu8086.com/   Website: http://emu8086.com/ Download the demo version and try it out….  

Exercise I mov al, 0011B mov bl, 0101B not al a) What are the contents of Al and al,bl; b) what are the contents of Al mov al, 0011B; mov bl, 0101B; or al,bl; c) what are the contents of Al? xor al,bl d) what are the contents of Al?    

Exercise II Given that Al contains 010b and Bl contains 011b:   Given that Al contains 010b and Bl contains 011b: Evaluate the contents of Al after Add Al, BL  

NOW DO THIS!!!!!!!! An array of numbers are declared as vec1: 1h, 2h, 5h, 6h. Evaluate the sum of all the numbers in the array using condition JNZ. Hint: Apply define byte as the array of numbers.    

NOW DO THIS!!!!!!!! Two arrays of numbers are vec1 db 1h, 2h, 5h, 6h Evaluate the sum of vec1 and vec2 and store the sum in Vec3. Hint: use lea si, vec1 Lea bx, vec2 lea di, vec3    

Assignment 2 The correct thickness of a silicon oxide number is 17. Four students obtained the number as 12, 17, 18 and 17. Develop and construct a system that can determine the number of correct thickness of the silicon oxide by using the Intel 8086 architecture.   Hint: a) Apply define byte as the numbers guessed. b) Use 4 as the loop counter. (Cl or Ch) c) Use Dl as the count number. Short Introduction Must include results of emulator Brief methodology Brief results Brief Conclusion