ECE 3430 – Intro to Microcomputer Systems

Slides:



Advertisements
Similar presentations
Control Structures in ARM Implementation of Decisions Similar to accumulator instructions One instruction sets the flags, followed by another instruction.
Advertisements

CPS3340 COMPUTER ARCHITECTURE Fall Semester, /15/2013 Lecture 11: MIPS-Conditional Instructions Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER.
Deeper Assembly: Addressing, Conditions, Branching, and Loops
Lecture 5: Decision and Control CS 2011 Fall 2014, Dr. Rozier.
CEG 320/520: Computer Organization and Assembly Language ProgrammingFlow Control 1 Flow Control.
ECE 265 – LECTURE 8 The M68HC11 Basic Instruction Set The remaining instructions 10/20/ ECE265.
Making Decision – Microprocessor
Lecture 8. MIPS Instructions #3 – Branch Instructions #1 Prof. Taeweon Suh Computer Science Education Korea University 2010 R&E Computer System Education.
11/02/2009CA&O Lecture 03 by Engr. Umbreen Sabir Computer Architecture & Organization Instructions: Language of Computer Engr. Umbreen Sabir Computer Engineering.
Chapter 10 The Assembly Process. What Assemblers Do Translates assembly language into machine code. Assigns addresses to all symbolic labels (variables.
ECE 447: Lecture 12 Logic, Arithmetic, Data Test and Control Instructions of MC68HC11.
17 - Jumps & Branches. The PC PC marks next location in Fetch, Decode, Execute cycle.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 11 Conditional Operations.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
Lecture 6: Decision and Control CS 2011 Spring 2016, Dr. Rozier.
ARM Instructions ARM instructions are written as an operation code (opcode), followed by zero or more operands Operands may be constants (8-bit value),
Computer Architecture & Operations I
Deeper Assembly: Addressing, Conditions, Branching, and Loops
ECE 3430 – Intro to Microcomputer Systems
Slide 7 Mikroprosesor Sub. Algoritma Program___
Status Register Status = system byte (supervisor only) + user byte = system status + condition code register usually, it is not important to know.
MIPS Instruction Set Advantages
Chapter 15: Higher Level Constructs
Control Unit Lecture 6.
ECE 3430 – Intro to Microcomputer Systems
Assembly Language Programming of 8085
Homework Reading Labs PAL, pp
The University of Adelaide, School of Computer Science
ARM Registers Register – internal CPU hardware device that stores binary data; can be accessed much more rapidly than a location in RAM ARM has.
ECE 3430 – Intro to Microcomputer Systems
3.Instruction Set of 8085 Consists of 74 operation codes, e.g. MOV
ECE 3430 – Intro to Microcomputer Systems
SUBJECT:COMPUTER ORGANISATION SUBJECT CODE: B.E. 4th SEMESTER
/ Computer Architecture and Design
Making Decisions and Writing Loops
ECE 3430 – Intro to Microcomputer Systems
Decision Making.
Conditional Branches What distinguishes a computer from a simple calculator is its ability to make decisions Decisions are made using the if statement,
Morgan Kaufmann Publishers Computer Organization and Assembly Language
More on logical instruction and
ECE 3430 – Intro to Microcomputer Systems
ECE 3430 – Intro to Microcomputer Systems
Microprocessor and Assembly Language
Chapter 5 The LC-3.
Pick up the handout on your way in!!
Flags Register & Jump Instruction
ARM Control Structures
CSC 3210 Computer Organization and Programming
ECE232: Hardware Organization and Design
Topic 5: Processor Architecture Implementation Methodology
ECE 3430 – Intro to Microcomputer Systems
Program Logic and Control
Program Logic and Control
Homework Reading Machine Projects Labs PAL, pp
Write a program to calculate x**y, given x and y.
The University of Adelaide, School of Computer Science
Topic 5: Processor Architecture
ECE 3430 – Intro to Microcomputer Systems
ARM Control Structures
Control units In the last lecture, we introduced the basic structure of a control unit, and translated our assembly instructions into a binary representation.
ECE 352 Digital System Fundamentals
March 2006 Saeid Nooshabadi
Overheads for Computers as Components 2nd ed.
Review: The whole processor
Chapter 7 –Program Logic and Control
Chapter 7 –Program Logic and Control
Branch & Call Chapter 4 Sepehr Naimi
ECE511: Digital System & Microprocessor
An Introduction to the ARM CORTEX M0+ Instructions
Presentation transcript:

ECE 3430 – Intro to Microcomputer Systems ECE 3430 – Introduction to Microcomputer Systems University of Colorado at Colorado Springs Lecture #10 Agenda Today 1) Branch Instructions/Conditional Execution 2) Status register flags: N,Z,V,C 3) Compare Instructions 4) IT Instruction (If-Then, Else) Lecture #10 ECE 3430 – Intro to Microcomputer Systems Fall 2015

Branch Instructions We need a way to alter the flow of program execution when specific conditions exist. This allows our programs to dynamically adjust to input. The Program Status Register provides the status of the CPU. V = Signed Overflow N = Negative Result Z = Zero Result C = Carry/Borrow START <op> <loop op> <cond> x == y? NO YES Only these flags affect behavior of conditional jump instructions <op> END Lecture #10 ECE 3430 – Intro to Microcomputer Systems Fall 2015

ECE 3430 – Intro to Microcomputer Systems Branch Instructions PSR[31:28] = {N,Z,C,V} - These flags are altered upon execution of an instruction if requested (S-bit). - We can use a conditional branch instruction depending on these flags to set the new value of the PC. - A branch occurs when the PC is set to different place in the code (besides the next sequential instruction). - Branches in the ARM processor always use n-bit relative addressing. This gives a finite branch distance. The forward and backward distance are always (almost) the same. - Labels provide an easy way to mark the destination of a branch. This way, the assembler can calculate the branch distance for you! - Unconditional Branch – “B(AL)” is an instruction that will always branch when executed regardless of what bits are set in the PSR. “B(AL)” is the only unconditional branch instructions in ARM instruction set. - Conditional Branch – When executed, it will check the PSR and evaluate a logical condition. If the branch condition is true, it will set the PC to the new address location. If the branch condition is false, it will increment the PC to the next instruction code as in normal operation. All branch instructions other than “B(AL)” are conditional. Lecture #10 ECE 3430 – Intro to Microcomputer Systems Fall 2015

Conditional Branches (Single Flag Test) Carry Flag Branches BCC = if carry clear, C=0 BCS = if carry set, C=1 BHS = if higher or same, C=1 BLO = if lower, C=0 Zero Flag Branches BEQ = if equal to zero, Z=1 BNE = if NOT equal to zero, Z=0 Negative Flag Branches BMI = if minus, N=1 BPL = if positive or zero, N=0 Two’s Complement Overflow Branches BVS = if signed overflow, V=1 BVC = if NO signed overflow, V=0 aliases Lecture #10 ECE 3430 – Intro to Microcomputer Systems Fall 2015

Conditional Branches (Multi-Flag Test) C and Z flags: > BHI: if higher (unsigned), C = 1 and Z = 0 <= BLS: if lower or same (unsigned), C = 0 or Z = 1 N and V flags: >= BGE: if greater than or equal (signed), N  V = 0, N and V equal < BLT: if less than (signed), N  V = 1, N and V not equal N, V, and Z flags: > BGT: if greater than (signed), Z = 0 and N  V = 0 <= BLE: if less than or equal (signed), Z = 1 or N  V = 1 Lecture #10 ECE 3430 – Intro to Microcomputer Systems Fall 2015

Signed vs. Unsigned Branch Instructions (Summary) Symbol: Boolean Equation: (evaluates to true) Unsigned branch instructions: BHI = if higher than > (C * !Z) BHS = if higher than or the same >= C BLO = if lower than < !C BLS = if lower than or the same <= (!C + Z) Signed branch instructions: BGT = if greater than > !Z * !(N  V) BGE = if greater than or equal >= !(N  V) BLT = if less than < N  V BLE = if less than or equal <= Z + (N  V) Neither: BEQ = if equal == Z BNE = if not equal != !Z BAL = always (unconditional jump) ! : NOT 1) Take note of the number of logic levels. * : AND 2) Note the use of DeMorgan’s Law in complementary pairs. + : OR 3) Processors don’t have to implement both parts of a pair.  : exclusive OR Lecture #10 ECE 3430 – Intro to Microcomputer Systems Fall 2015

ECE 3430 – Intro to Microcomputer Systems Conditional Branches Compare Instructions CMP/CMN : General compare (compare negative) Typically, the above compare instructions should immediately precede a conditional branch instruction! If a data movement instruction uses the S-bit to adjust the condition code flags, it may not be necessary to use an explicit compare. Lecture #10 ECE 3430 – Intro to Microcomputer Systems Fall 2015

IT instruction (If-Then, Else) In pipelined architectures, it is desirable to eliminate branch instructions to keep the pipeline full. If (R0 < 100) { R0 += 1 } Else {R0 = -100} In the traditional ARM instruction set, this can be done using conditionals on each instruction. But conditional instructions aren’t allowed in Thumb. So the IT instruction comes to the rescue. CMP R0, #100 ITE LT ADDLT R0,R0,#1 MOVGE R0,#-100 Format: I**** where * can be T or E. Up to four. Each subsequent instruction in block needs to be declared conditional and agree with T or E. The IT instruction is real, subsequent instructions are encoded as unconditional. All instructions are fetched and decoded—but not necessarily executed (pipeline stays full). Lecture #10 ECE 3430 – Intro to Microcomputer Systems Fall 2015

Using Compare Instructions to Influence Jump Instruction Behavior In-class example of N, Z, V, and C flag calculation by CMP instruction. BGE (signed) takes branch if “N  V = 0” evaluates as true. BHS (unsigned) takes branch if “C = 1” evaluates as true. What numbers can we subtract to yield: N = 1? V = 1? C = 1? Lecture #10 ECE 3430 – Intro to Microcomputer Systems Fall 2015