Physics 413 Chapter 4 A Fork in the Road LDAB # $ 13 here :ADDA # $ 24 DEC B BNE here WAI BNE is the new instruction. Branch if not equal to zero.

Slides:



Advertisements
Similar presentations
Floyd, Digital Fundamentals, 10 th ed EET 2261 Unit 7 Indexed Addressing Mode Read Mazidi, Chapter 6. Homework #7 and Lab #7 due next week. Quiz next week.
Advertisements

EET 2261 Unit 6 The Stack; Subroutines
Microprocessors.
EECC250 - Shaaban #1 Lec # 2 Winter Addressing Modes  Addressing modes are concerned with the way data is accessed  Addressing can be.
Programming 68HC11.
1 Chapter 3 Jump, Loop, and Call Instructions. 2 Sections 3.1 Loop and Jump Instructions 3.2 Call Instructions 3.3 Time Delay Generation and Calculation.
Processor Function Topic 3.
EET 2261 Unit 5 Tables; Decision Trees & Logic Instructions
Design of Embedded Systems Using 68HC12(11) Microcontrollers - R. E. Haskell Subroutine and Stacks Chapter 2.
© 2010 Kettering University, All rights reserved..
Module 10 Adapted By and Prepared James Tan © 2001.
© 2010 Kettering University, All rights reserved..
Physics 413 Chapter 1: Introduction to the HCS 12 Microcontroller.
ME4447/6405 The George W. Woodruff School of Mechanical Engineering ME4447/6405 Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics.
Computer Architecture Lecture 13 – part 2 by Engineer A. Lecturer Aymen Hasan AlAwady 7/4/2014 University of Kufa - Information Technology Research and.
EECC250 - Shaaban #1 Lec # 20 Winter Microcontroller Basics A microcontroller is a small, low-cost computer-on-a-chip which usually includes:
Stacks and Subroutines. Some example stacks Stacks and subroutine usage The stack is a special area of the random access memory in the overall memory.
ECE 265 – LECTURE 8 The M68HC11 Basic Instruction Set The remaining instructions 10/20/ ECE265.
ME4447/6405 The George W. Woodruff School of Mechanical Engineering ME4447/6405 Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
ECE 265 – LECTURE 5 The M68HC11 Basic Instruction Set 12/8/ ECE265.
Lecture Set 4 Programming the 8051.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
1 Stacks, Subroutines, I/O Routines Today: First Hour: Stacks, Subroutines –Section 3.9,3.10 of Huang’s Textbook –In-class Activity #1 Second Hour: I/O.
Motorola MC68HC811E2 Microcontrollers
Addressing Modes MTT CPU08 Core Motorola CPU08 ADDRESSING MODES.
1 ECE 372 – Microcontroller Design Assembly Programming HCS12 Assembly Programming Addressing Modes Stack Operations Subroutines.
ELE22MIC Lecture 24 Course Review 1 –Review Addressing Modes operation –Instruction Set Categories & instructions Review of Assignment 1 & 2 Assignment.
EE 345 Class Notes EE345 Midterm Review Dr. Jane Dong.
1 Introduction to Microcontroller Microcontroller Fundamentals & Programming.
ECE Lecture 21 Typical Assembly Language Program Bugs.
1 Microcontroller Fundamentals & Programming Addressing Modes.
Microcontroller Fundamentals & Programming Arithmetic Instructions.
Advanced Assembly Language Programming
ECE 447: Lecture 11 Introduction to Programming in Assembly Language.
Embedded Systems Lecture 5 January 25 th, 2016.
Subroutines and Stacks. Stack The stack is a special area in memory used by the CPU to store register information or general data information during program.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
Physics 413 Chapter 4: Advanced Assembly Programming.
1 Subroutines Advanced Programming. 2 Top-Down approach to problem solving Algorithm step by step description of how to solve a problem Divide and Conquer.
1 Stack Advanced Programming. 2 The Stack It is a special area of memory used as temporary storage A stack is a LIFO data structure Putting data into.
1 ECE 372 – Microcontroller Design Basic Assembly Programming for(j=0; j
Revised: Aug 1, EE4390 Microprocessors Lessons 11, 12 Advanced Assembly Programming.
ELE22MIC Lecture 17 Writing 68HC11 software 68HC11 Main Timer System –Output Compare –What is different about TOC1?
EE345 Chapter 2 Lecture 3 April Instruction and addressing modes 1.Extended Addressing 2.Direct Addressing 3.Inherent Addressing 4.Immediate Addressing.
5-1 EE 319K Introduction to Microcontrollers Lecture 5: Conditionals, Loops, Modular Programming, Sub- routines, Parameter passing.
CPEN 231: Microcomputer Architecture and Assembly Programming Lecture 10: Stack and Subroutines John Tadrous, Ph.D. ECE Rice University
EET 2261 Unit 6 The Stack; Subroutines
Programmable System on Chip
ECE 3430 – Intro to Microcomputer Systems
Addressing Modes in Microprocessors
ECE 3430 – Intro to Microcomputer Systems
ECE 3430 – Intro to Microcomputer Systems
ECE 3430 – Intro to Microcomputer Systems
8051 Addressing Modes The way, using which the data source or destination addresses are specified in the instruction mnemonic for moving the data, is.
CS 301 Fall 2002 Control Structures
ME4447/6405 Microprocessor Control of Manufacturing Systems and
Branching and Loops.
Registers in the CPU Inside the CPU.
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
Stack Relative Deferred (sf) Indexed (x) Stack Indexed (sx)
8085 MICROPROCESSOR 8085 CPU Registers and Status Flags S Z AC P C A B
Stack Relative Deferred (sf) Indexed (x) Stack Indexed (sx)
Physics 413 Chapter 2.
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
EET 2261 Unit 6 The Stack; Subroutines
Indexing Through Memory
Accum A: Index X: CCR Bit Z: $0100 $0101 $0102 $0103 $0104 $0105
ECE511: Digital System & Microprocessor
Presentation transcript:

Physics 413 Chapter 4

A Fork in the Road LDAB # $ 13 here :ADDA # $ 24 DEC B BNE here WAI BNE is the new instruction. Branch if not equal to zero.

Branch Address Calculation LDAB # $ 13C6 13 here :ADDA # $ 248B 24 DEC B5A BNE here26 ?? WAI3E

Backward and Forward FFGo back 1 step FEGo back 2 steps FBGo back 5 steps 80Go back 128 steps 01Go forward 1 step 05Go forward 5 steps 7FGo forward 127 steps

Branch Address Calculation LDAB # $ 13C6 13 here :ADDA # $ 248B 24 DEC B5A BNE here26 FB WAI3E Note: PC (Program Counter) is pointing at the next instruction so count backward from 3E. Incidentally, CPU uses the Z - bit (zero flag) in CCR to ascertain whether accumulator B is indeed zero.

Branches Galore MnemonicDescription of Criteria BCCBranch if Carry Clear BCSBranch if Carry Set BEQBranch if Equal to Zero BNEBranch if Not Equal to Zero BRABranch Always Note: Familiarize yourself with other related instructions like JMP, BSR, and JSR

Dare to Compare ! here:LDAA # $ E3 CMPA $ 50 BNE here WAI Temperature sensor reading is stored at memory location 0050 and compared with a danger limit of E3.

Delay Loop Subroutine here:JSR DELAY LDAA # $ E3 CMPA $ 50 BNE here WAI. DELAY: LDX # $ FFFF AGAIN : DEX BNE AGAIN RTS

Indexed Addressing Mode LDX # $ 0050 CLRA up :ADDA $ 00, X INX CPX # $ 0070 BNE up WAI Program adds numbers stored in memory locations 0050 through 006F. Index register is a “pointer” which is incremented. The offset, 00, can be changed if necessary.

Push and Pull PSHAA M SP SP - 1 SP PULASP + 1 SPM SP A

Predict the Outcome! PSHA PSHB PULA PULB

Solution Congratulations, if you said the contents of A and B will be swapped and, perhaps more importantly, the value of the stack pointer will be restored to its original value before this program segment was run. 00D6 00D5 00D4 00D3

Detailed Explanation Suppose that SP was pointing at 00D6 (stack). PUSHA stores A into 00D6. Then PUSHB stores B into 00D5. At this point SP = 00D4. Then PULA pulls 00D5 (which contains B) and stores it into A. Finally, PULB pulls 00D6 (which contains A) and stores it into B. We end up swapping A and B. At this point SP = 00D6, its original value. 00D6 00D5 00D4 00D3