Branching and Loops.

Slides:



Advertisements
Similar presentations
EECC250 - Shaaban #1 Lec # 2 Winter Addressing Modes  Addressing modes are concerned with the way data is accessed  Addressing can be.
Advertisements

Programming 68HC11.
EET 2261 Unit 5 Tables; Decision Trees & Logic Instructions
Revised: Aug 1, EE4390 Microprocessors Lesson 6,7 Instruction Set, Branch Instructions, Assembler Directives.
Assembler Programming Chapter 6. EEL-4746 Best Practices.
© 2010 Kettering University, All rights reserved..
Programming the HC12 in C. Some Key Differences – Note that in C, the starting location of the program is defined when you compile the program, not in.
1 ECE 372 – Microcontroller Design Basic Assembly Programming for(j=0; j
© 2010 Kettering University, All rights reserved..
The M68HC11 Basic Instruction Set Basic Arithmetic Instructions
Chapter 2: 68HC11 Assembly Programming
H. Huang Transparency No.2-1 The 68HC11 Microcontroller Chapter 2: 68HC11 Assembly Programming The 68HC11 Microcontroller.
Basic Microcontroller System
Assembly Language Programming for the MC68HC11. Assembly language programming  Recall the 4 design levels for software development: – Application – High.
ME4447/6405 The George W. Woodruff School of Mechanical Engineering ME4447/6405 Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics.
EECC250 - Shaaban #1 Lec # 20 Winter Microcontroller Basics A microcontroller is a small, low-cost computer-on-a-chip which usually includes:
ELN5622 Embedded Systems Class 2 Spring, 2003 Kent Orthner
ECE 265 – LECTURE 8 The M68HC11 Basic Instruction Set The remaining instructions 10/20/ ECE265.
ECE Lecture 13 Motorola 68HC11. Resources 68HC11 E-series Reference Guide and if necessary 68HC11 E-series Technical Data 68HC11 Reference Manual.
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.
© 2010 Kettering University, All rights reserved..
ECE 447: Lecture 12 Logic, Arithmetic, Data Test and Control Instructions of MC68HC11.
ME4447/6405 The George W. Woodruff School of Mechanical Engineering ME4447/6405 Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics.
ECE 265 Midterm Review 12/1/ ECE265. Administrivia  The grade for quiz 3 was not entered into to Carmen before I handed them back.  I realize.
3-1 EE 319K Introduction to Microcontrollers Lecture 3: Addressing modes, Memory Operations, Subroutines, I/O, Logical/Shift Operations.
ECE 265 – LECTURE 5 The M68HC11 Basic Instruction Set 12/8/ ECE265.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
Motorola MC68HC811E2 Microcontrollers
Machine Language ELEC 330 Digital Systems Engineering Dr. Ron Hayne.
1 ECE 372 – Microcontroller Design Assembly Programming HCS12 Assembly Programming Addressing Modes Stack Operations Subroutines.
EE 345 Class Notes EE345 Midterm Review Dr. Jane Dong.
The Serial Communication Interface (SCI) MC9S12-C32
ECE Lecture 21 Typical Assembly Language Program Bugs.
1 Microcontroller Fundamentals & Programming Addressing Modes.
Microcontroller Fundamentals & Programming Arithmetic Instructions.
ECE 447: Lecture 16 Common Errors & Good Programming Style.
Embedded Systems Lecture 5 January 25 th, 2016.
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 ECE 372 – Microcontroller Design Basic Assembly Programming for(j=0; j
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.
The 68HC11 Microcontroller Minnesota State University, Mankato
Slide 7 Mikroprosesor Sub. Algoritma Program___
Addressing Modes in Microprocessors
Status Register Status = system byte (supervisor only) + user byte = system status + condition code register usually, it is not important to know.
HC11 Programming.
ECE 3430 – Intro to Microcomputer Systems
ECE 3430 – Intro to Microcomputer Systems
ECE 3430 – Intro to Microcomputer Systems
Computer Architecture & Operations I
ECE 3430 – Intro to Microcomputer Systems
Wed. Sept 6 Announcements
Data Processing Instructions
Branching and Looping Lecture L3.2.
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME4447/6405 Microprocessor Control of Manufacturing Systems and
Introduction to Micro Controllers & Embedded System Design Addressing Mode Department of Electrical & Computer Engineering Missouri University of Science.
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
Under Address Modes Source: under
Write a program to calculate x**y, given x and y.
Interrupt-Driven State Machine
Under Address Modes Source: under
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
Indexing Through Memory
Instruction Set Summary
Branch & Call Chapter 4 Sepehr Naimi
Accum A: Index X: CCR Bit Z: $0100 $0101 $0102 $0103 $0104 $0105
ECE511: Digital System & Microprocessor
An Introduction to the ARM CORTEX M0+ Instructions
Presentation transcript:

Branching and Loops

Jumping Jump instruction causes a change in the program flow to any location within the addressable range of the processor. ORG $0200 0200 86 AC LDAA #$AC 0202 7E 02 0B JMP STORE 0205 4F CLRA 0206 5F CLRB 0207 7F 02 00 CLR $0200 020A 47 ASRA 020B B7 02 50 STORE STAA $0250 020E 7E 02 0E END JMP END

Jump ORG $0200 0200 86 AC LDAA #$AC 0202 7E 02 0B JMP $020b 0205 4F CLRA 0206 5F CLRB 0207 7F 02 00 CLR $0200 020A 47 ASRA 020B B7 02 50 STAA $0250 020E 7E 02 0E JMP $020e

Branching and Relative Address Mode Branch instructions differ from the jump instructions in that they do not supply the absolute address of the next instruction.

Branching and Relative Address Mode BCC BCS BEQ BMI BNE BPL BVC BVS BHS BLO

Branching and Relative Address Mode ORG $0200 0200 96 AC LDAA $AC 0202 2A 05 BPL POS 0204 B7 02 51 STAA $0251 0207 20 03 BRA END 0209 B7 02 50 POS STAA $0250 020C 20 FE END BRA END

Destination address calculation Problem: Calculate the destination address (DA) for each of the following branch instructions. ADDRESS MACHINE CODE SOURCE CODE 0200 20 6C BRA PAST O1F7 20D3 BRA LOOP 063A 20 9B BRA AGAIN

RELATIVE ADRESS (rr) CALCULATION Calculate the relative address (rr) for each of the following branch instuctions a. ORG $0200 0200 96 AC LDAA $AC 0202 2A ?? BPL POS 0204 B7 02 51 STAA $0251 0207 20 ?? BRA END 0209 B7 02 50 POS STAA $0250 020C 20 ?? END BRA END

RELATIVE ADRESS (rr) CALCULATION ORG $0300 0300 96 AC LDAA $AC 0302 9B AD ADDA $AD 0304 29 ?? BVS ERROR 0306 25 ?? BCS CARRY 0308 B7 02 01 STAA $0201 030B 20 ?? BRA END 030D 86 01 CARRY LDAA #$01 030F B7 02 50 STAA $0250 0312 20 ?? BRA END 0314 CC FF FF ERROR LDD #$FFFF 0317 FD 02 50 STD $0250 031A 20 ?? END BRA END

Compare Instructions CMPA CMPB CPD CPX CPY CBA

Test Instructions TSTA TSTB TST

IF-THEN-ELSE ORG $0200 LDAA $03FA BPL PAST NEGA PAST STAA $03FA

WHILE AND UNTIL LOOPS

TIMING LOOPS $0200 LDX #100 LOOP DEX BNE LOOP

TIMING LOOPS LDAA #30 STAA $1000 LDAA #00 STAA $1001 BACK DEC $1001                 ORG     $0200                 LDAA     #30                 STAA        $1000                 LDAA     #00                 STAA     $1001 BACK     DEC     $1001                 BNE     BACK                 DEC     $1000