ECE 353 Introduction to Microprocessor Systems Michael G. Morrow, P.E. Week 5.

Slides:



Advertisements
Similar presentations
Instruction Set of 8086 Engr. M.Zakir Shaikh
Advertisements

Registers of the 8086/ /2002 JNM.
SOFTWARE ARCHITECTURE OF THE 8088 AND 8086 MICROPROCESSORS
Gursharan Singh Tatla 21-Nov-20101www.eazynotes.com.
8086 : INSTRUCTION SET By, Pramod Sunagar Assistant Professor
TK 2633 Microprocessor & Interfacing
Room: E-3-31 Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language.
8-1 ECE 424 Design of Microprocessor-Based Systems Haibo Wang ECE Department Southern Illinois University Carbondale, IL x86 Instructions Part.
9-1 ECE 424 Design of Microprocessor-Based Systems Haibo Wang ECE Department Southern Illinois University Carbondale, IL x86 Instructions Part.
1 Homework Reading –PAL, pp Machine Projects –MP2 due at start of Class 12 Labs –Continue labs with your assigned section.
Gursharan Singh Tatla Block Diagram of Intel 8086 Gursharan Singh Tatla 19-Apr-17.
Unit-1 PREPARED BY: PROF. HARISH I RATHOD COMPUTER ENGINEERING DEPARTMENT GUJARAT POWER ENGINEERING & RESEARCH INSTITUTE Advance Processor.
The 8086 Microprocessor The 8086, announced in 1978, was the first 16-bit microprocessor introduced by Intel Corporation 8086 is 16-bit MPU. Externally.
An Introduction to 8086 Microprocessor.
Microprocessor Programming II
Ch. 7 Logic, Shift and Rotate instr.
3.7 String Instructions Specifying the Operands’ Size and Address and the String Direction STRING = a data collection in memory. String ELEMENTS can be:
Electrical Engineering Department Engineering College Prince Sattam bin Abdul Aziz University Text Book: - Triebel and Singh, "The 8088 and 8086 Microprocessors",
Low Level Programming Lecturer: Duncan Smeed Low Level Program Control Structures.
Types of Registers (8086 Microprocessor Based)
Lecture 4 ( Assembly Language).
Microprocessors Monday, Apr. 13 Dr. Asmaa Farouk Faculty of Engineering, Electrical Department, Assiut University.
Lecture 5 Presented By Dr. Shazzad Hosain Asst. Prof. EECS, NSU.
Executing and Linking an assembly program. Lesson plan Review Program logic and control Practice exercise Assembling, Linking and Executing Programs Practice.
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.
ECE 353 Introduction to Microprocessor Systems Michael G. Morrow, P.E. Week 7.
Microprocessor Programming II To discuss more complicated programming techniques Flag control instructions Compare and jump Subroutines Loop and string.
EEL 3801 Part V Conditional Processing. This section explains how to implement conditional processing in Assembly Language for the 8086/8088 processors.
ECE 353 Introduction to Microprocessor Systems Michael G. Morrow, P.E. Week 5.
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.
Introduction to Microprocessors Chapter 3. Programming Model (8086)  Shows the various internal registers that are accessible to the programmer.
1 Intel 8086 MICROPROCESSOR ARCHITECTURE. 2 Features It is a 16-bit μp has a 20 bit address bus can access up to 2 20 memory locations (1 MB). It.
Computer and Information Sciences College / Computer Science Department CS 206 D Computer Organization and Assembly Language.
Intel 8086 MICROPROCESSOR ARCHITECTURE
SOFTWARE ARCHITECTURE OF THE 8088 AND 8086 MICROPROCESSORS
Chapter 8 String Operations. 8.1 Using String Instructions.
Chapter 12 Processor Structure and Function. Central Processing Unit CPU architecture, Register organization, Instruction formats and addressing modes(Intel.
Microprocessor Systems Design I
Chapter Nov-2010
Data Transfers, Addressing, and Arithmetic
Assembly Language Programming of 8085
UNIT Architecture M.Brindha AP/EIE
Homework Reading Labs PAL, pp
Introduction to 8086 Microprocessor
8086 Microprocessor.
Instruksi Set Prosesor 8088
Microprocessor and Assembly Language
Intel 8086 MICROPROCESSOR Architecture.
EE3541 Introduction to Microprocessors
EE3541 Introduction to Microprocessors
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Machine control instruction
INSTRUCTION SET.
More on logical instruction and
Assembly Language Programming Part 2
ECE 353 Introduction to Microprocessor Systems
Intel 8088 (8086) Microprocessor Structure
Lecture 4 ( Assembly Language).
Flags Register & Jump Instruction
Intel 8088 (8086) Microprocessor Structure
Lecture 1 Instruction set of 8086 Лектор: Люличева И.А. 1.
CS 301 Fall 2002 Computer Organization
Shift & Rotate Instructions)
University of Gujrat Department of Computer Science
Homework Reading Machine Projects Labs PAL, pp
Shift & Rotate Instructions)
EECE.3170 Microprocessor Systems Design I
CNET 315 Microprocessor & Assembly Language
Chapter 8: Instruction Set 8086 CPU Architecture
Presentation transcript:

ECE 353 Introduction to Microprocessor Systems Michael G. Morrow, P.E. Week 5

Flags Register Bit manipulation Logical Instructions Shift/Rotate Instructions Branching Conditional Unconditional Looping Structured Programming Stack Allocation and Operation Objectives

FLAGS Register aka the Processor Status Word (PSW) A ‘flag’ is generally a marker used to indicate or record some condition. PSW contains 6 status flags … AF, CF, OF, PF, SF, ZF … and 3 control flags DF, IF, TF 80C188EB Processor Status Word (PSW) OFDFIFTFSFZF--AF--PF--CF

PSW Status Flags The status flags reflect the result of the previous logical or arithmetic operation. AF – indicates a carry or borrow between the high and low nibbles of the accumulator, used for BCD. CF – indicates a carry from, or a borrow to, the MSb of an arithmetic result  Can also modify directly with CLC / CMC / STC to use as a Boolean status bit. OF – an arithmetic overflow has occurred PF – set if the operation resulted in even parity SF – set if the result is negative (i.e. MSb = 1) ZF – set if the result is zero

Control Flags The control flags control certain aspects of the processor’s execution DF – direction flag  Determines the direction of pointer modifications in string operations. If DF=0, then increment pointers, otherwise decrement. IF – interrupt enable flag  If set, the processor can recognize maskable interrupts. TF – trap flag  If set, the processor will execute in single-step mode.

Logical Instructions Logical instructions operate bit-wise. NOT does not affect flags. MnemonicOperandsFunction OSZAPC NOTdst Logical complement ANDdst,src Logical AND 0  ?  0 ORdst,src Logical OR 0  ?  0 XORdst,src Logical exclusive OR 0  ?  0 TESTdst,src Non-destructive AND 0  ?  0

Bit Manipulation Clearing bit(s) - AND Set desired bits to 0 in mask All other bits in mask to 1 Setting bit(s) - OR Set desired bits to 1 in mask All other bits in mask to 0 Toggling bit(s) - XOR Set desired bits to 1 in mask All other bits in mask to 0 Read-modify-write issuesissues

Shift Instructions Arithmetic versus logical shifts Shift count source 1 CL Immediate byte (new to instruction set) MnemonicOperandsFunction OSZAPC SHLdst, cnt Shift logical left **  ?  SALdst, cnt Shift arithmetic left **  ?  SHRdst, cnt Shift logical right **  ?  SARdst, cnt Shift arithmetic right **  ? 

Rotate Instructions Rotate count sources Using rotate instruction to swap nibbles Execution time dependent on count MnemonicOperandsFunction OSZAPC ROLdst, cnt Rotate left ** ----  RORdst, cnt Rotate right ** ----  RCLdst, cnt Rotate through carry left ** ----  RCRdst, cnt Rotate through carry right ** ---- 

Unconditional Jumps Redirect program flow by loading a new IP (and possibly a new CS) value. Syntax: jmp target Label attributes Target by direct addressing Target by indirect addressing Jump tables Be sure index is bounds-checked! FAR versus NEAR jump tables

Conditional Jumps Allow program flow to change in response to conditions. Action is based on current state of flags. Syntax: j short-label is mnemonic for condition to test.condition All conditional jumps are short.  Can use double jumps if target out of range. Prior instruction must be used to set flags Examples

Looping Can use backwards conditional jumps to create a loop that can be terminated - By a condition After a predetermined number of iterations Or a combination of both MnemonicOperandsFunction OSZAPC INCdst Increment  - DECdst Decrement  - CMPdst, src Compare (dst – src, nondestructive)  -

Looping Can use the LOOP instructions CX is loop control variable GPP: Don’t modify CX in loop MnemonicOperandsFunction OSZAPC LOOPshrt_lbl DEC CX JNZ LOOPE LOOPZ shrt_lbl Loop while CX <> 0 and ZF = 1 (last operation was zero) LOOPNE LOOPNZ shrt_lbl Loop while CX <> 0 and ZF = 0 (last operation was not zero)

Implementing Structured Programming Constructs Structured programming basics One entry point, one exit point per procedure (subroutine) Based on three basic control structures  Repetition  Selection If, If/Else, Switch/Case  Repetition While Do-While Flowchart Basics

Repeated String Instructions String instructions become very useful when used with the REP prefix REP, REPE/REPZ, REPNE/REPNZ Pointer modification based on DF (CLD, STD). CX is always loop variable for repeated string instructions CMPS order of evaluation is reversed from CMP! MnemonicOperandsFunction OSZAPC SCASdst_s Scan string (AL – ES:DI)  CMPSdst_s Compare string (DS:SI – ES:DI) 

Records Provides a syntax for creating and accessing bit-encoded data structures. Syntax name RECORD field_name:exp[=init_val][,…] Operations MASK  Creates a mask for the bit-field identified Shift  Using the bit-field name is interpreted as a right shift count to move that field to the LSB WIDTH  Returns number of bits in a record or field

Stack Implementation Stack is a LIFO data structure. Who uses the stack? Subroutine return addresses Passed parameters Temporary memory allocation Two basic operations PUSH POP Hardware stacks vs. memory stacks Stack pointer  A dedicated register to use exclusively to access the stack

80C188EB Stack Operation Stack is defined by SS:SP Allocating stack space Stack operations All stack operations are 16-bit transfers PUSH / PUSHA / PUSHF POP / POPA / POPF CALL / RETURN ENTER / LEAVE Example

Wrapping Up Homework #3 due Friday, October 12 th Exam 1 will be held on Thursday, October 18, 2001 from 7:15 to 8:45 PM in 132 Noland

Exercise Write a code fragment that implements the C function strchr, which finds a given character in an ASCIIZ string. strchr scans the string in the forward direction, looking for the specified character and finds the first occurrence of the character in the string. The null-terminator is considered to be part of the string. Assume the following conditions: AL - character to search for DS:DI - address of null-terminated string to search (string must not start at offset of zero!) If found, set AX = equal offset of first occurrence, otherwise set AX = 0.

MnemonicJump if conditionFlags for condition JA/JNBEAbove / not below or equal(CF OR ZF) = 0 JAE/JNBAbove or equal / not belowCF = 0 JB/JNAEBelow / not above or equalCF = 1 JBE/JNABelow or equal / not above(CF OR ZF) = 1 JCCarryCF = 1 JCXZJump if CX equal 0CX = 0 (uses register) JE/JZEqual / zeroZF = 1 JB/JLNEBelow / not less nor equal((SF XOR OF) OR ZF) = 0 JGE/JNLGreater or equal / not less(SF XOR OF) = 0 JL/JNGELess / not greater nor equal(SF XOR OF) = 1 JNCNo carryCF = 0 JNE/JNZNot equal / not zeroZF = 0 JNONot overflowOF = 0 JNP/JPONot parity / parity oddPF = 0 JNSNot sign (positive)SF = 0 JOOverflowOF = 1 JP/JPEParity / parity evenPF = 1 JSSign (negative)SF = 1

Read-Modify-Write Issues Remove bubbles for memory- mapped I/O.