1 ECE 372 – Microcontroller Design Basic Assembly Programming for(j=0; j<10; j++) { // do something } For Loop Example: 1.Initialize J 2.Compare J to 10.

Slides:



Advertisements
Similar presentations
H. Huang Transparency No.1-1 The HCS12/MC9S12 Microcontroller Copyright © 2010 Delmar Cengage Learning HCS12 Instruction Examples The LOAD and STORE Instructions.
Advertisements

Microprocessors.
REGISTER TRANSFER LANGUAGE (RTL)
ARITHMETIC LOGIC SHIFT UNIT
2.3) Example of program execution 1. instruction  B25 8 Op-code B means to change the value of the program counter if the contents of the indicated register.
68HC11 Polling and Interrupts
H. Huang Transparency No.1-1 The 68HC11 Microcontroller Chapter 1: Introduction to 68HC11 The 68HC11 Microcontroller.
ECE 372 – Microcontroller Design Parallel IO Ports - Interrupts
Assembly Language for Intel-Based Computers Chapter 2: IA-32 Processor Architecture Kip Irvine.
1 ECE 372 – Microcontroller Design Basic Assembly Programming for(j=0; j
EET 2261 Unit 2 HCS12 Architecture
Smarter systems and the PIC® 18FXX2 Chapter One 12.1 – 12.5 Dr. Gheith Abandah1.
Computer Architecture
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.
CEG 320/520: Computer Organization and Assembly Language ProgrammingFlow Control 1 Flow Control.
Rabel Talpur:12BME#025.  40-pin chip  Developed by Motorola in 1975  16 address lines and 8 data lines  Used only +5V.
The M68HC11 Basic Instruction Set Basic Arithmetic Instructions
Computer Science 210 Computer Organization The Instruction Execution Cycle.
Module 10 Adapted By and Prepared James Tan © 2001.
ME4447/6405 The George W. Woodruff School of Mechanical Engineering ME4447/6405 Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics.
9/20/6Lecture 3 - Instruction Set - Al Instruction Set (2)
ECE 265 – LECTURE 8 The M68HC11 Basic Instruction Set The remaining instructions 10/20/ ECE265.
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.
Revised: Aug 1, ECE263 Embedded System Design Lesson 4 Programming Model, Assembly Language, Instruction Execution Cycle.
Lecture 14 Today’s topics MARIE Architecture Registers Buses
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 448 – FPGA and ASIC Design with VHDL George Mason University Lab 1 Introduction to Aldec Active HDL Implementing Combinational Logic in VHDL.
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.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
1 ECE 372 – Microcontroller Design Assembly Programming HCS12 Assembly Programming Addressing Modes Stack Operations Subroutines.
1 Introduction to Microcontroller Microcontroller Fundamentals & Programming.
1 Microcontroller Fundamentals & Programming Addressing Modes.
Microcontroller Fundamentals & Programming Arithmetic Instructions.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
Chapter 3 : Top Level View of Computer Functions Basic CPU function, Interconnection, Instruction Format and Interrupt.
CHAPTER 6 ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS.
Execution Architecture MTT CPU08 Core M CPU08 INTRODUCTION.
ECE 447: Lecture 11 Introduction to Programming in Assembly Language.
An Adder A Subtractor. A and B are the inputs of the adder/ subtractor R is the output of the adder/ subtractor F is the control to tell it to add or.
MICROPROCESSOR DETAILS 1 Updated April 2011 ©Paul R. Godin prgodin gmail.com.
Embedded Systems Lecture 5 January 25 th, 2016.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
1 ECE 372 – Microcontroller Design Assembly Programming – Arrays unsigned short a[10]; for(j=0; j
8085 Microprocessor Architecture
Status Register Status = system byte (supervisor only) + user byte = system status + condition code register usually, it is not important to know.
ECE 3430 – Intro to Microcomputer Systems
Gunjeet Kaur Dronacharya Group of institutions
ECE 3430 – Intro to Microcomputer Systems
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
ECE 3430 – Intro to Microcomputer Systems
Arithmetic operations Programming
ME4447/6405 Microprocessor Control of Manufacturing Systems and
Design of the Control Unit for One-cycle Instruction Execution
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
University of Gujrat Department of Computer Science
Chapter 4 Instruction Set.
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
Branch & Call Chapter 4 Sepehr Naimi
Computer Architecture Assembly Language
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
Presentation transcript:

1 ECE 372 – Microcontroller Design Basic Assembly Programming for(j=0; j<10; j++) { // do something } For Loop Example: 1.Initialize J 2.Compare J to 10 3.If Not Less than 10, 1.End Loop 4.Else 1.do something 2.Increment J 3.Repeat Loop (Step 2) Programming Steps: Assembly Code: ldaa #0 ; Initialize j Loop: cmpa #10 ; Compare j to 10 bge EndLoop ; Else !(j<10) ; do something adda #1 ; Increment j bra Loop ; Repeat Loop EndLoop: ; do something else

2 ECE 372 – Microcontroller Design Basic Assembly Programming $4000$86LDAA immediate addressing $4001$00Value to be stored in A $4002$CMPA immediate addressing $4003$0ACompare Value 10 $4004$BGE (Branch if greater then or equal to zero) $4005$04PC=PC+2+Rel $4006$ADDA immediate addressing $4007$01Value to add to A $4008$Branch Always $4009$F8PC=PC+2+Rel … Assembly Code: ldaa #0 ; Initialize j Loop: cmpa #10 ; Compare j to 10 bge EndLoop ; Else !(j<10) ; do something adda #1 ; Increment j bra Loop ; Repeat Loop EndLoop: ; do something else How do we determine these values?

3 ECE 372 – Microcontroller Design HCS12 Instruction Set Summary Overview … … … …

4 ECE 372 – Microcontroller Design HCS12 Instruction Glossary

5 ECE 372 – Microcontroller Design HCS12 Opcode Table

6 ECE 372 – Microcontroller Design Basic Assembly Programming $4000$86LDAA immediate addressing $4001$00Value to be stored in A $4002$81CMPA immediate addressing $4003$0ACompare Value 10 $4004$2CBGE (Branch if greater then or equal to zero) $4005$04PC=PC+2+Rel $4006$8BADDA immediate addressing $4007$01Value to add to A $4008$20Branch Always $4009$F8PC=PC+2+Rel … Assembly Code: ldaa #0 ; Initialize j Loop: cmpa #10 ; Compare j to 10 bge EndLoop ; Else !(j<10) ; do something adda #1 ; Increment j bra Loop ; Repeat Loop EndLoop: ; do something else

7 ECE 372 – Microcontroller Design Execution Time Analysis $4000$86LDAA immediate addressing1 $4001$00Value to be stored in A $4002$81CMPA immediate addressing1 $4003$0ACompare Value 10 $4004$2CBGE (Branch if greater then or equal to zero)3/1 $4005$04PC=PC+2+Rel $4006$8BADDA immediate addressing1 $4007$01Value to add to A $4008$20Branch Always3 $4009$F8PC=PC+2+Rel … How long does this loop take to execute? Cycles Loop Cycles = ( )*10 + (1+3) Loop Cycles = 64 cycles Core Clock = 4 MHz Execution Time = 64 * 250 ns = ns Execution Time = 16 us Loop

8 ECE 372 – Microcontroller Design HCS12 Registers

9 ECE 372 – Microcontroller Design HCS12 Registers - Accumulators ldaa #$5 Accumulators Source and destination of arithmetic operations A, B are 8-bit registers D is the combination of A and B Forms a 16-bit register A is the MSB and B is the LSB Used for 16-bit operations

10 ECE 372 – Microcontroller Design HCS12 Registers - Accumulators ldaa #$50 ldab #$01 ldd #$0150 Is there any difference between the following assembly code examples? vs. ldd #$5001 vs. ldaa #$00 ldab #$0A ldd #10 vs. clra ldab #$0A vs.

11 ECE 372 – Microcontroller Design HCS12 Registers - CCR Condition Code Register (CCR) C – Carry/Borrow Set when a carry occurs during addition or a borrow occurs during subtraction O – Overflow Set in the event of an overflow during an arithmetic operation Z – Zero Set when all the bits of the result are 0s N – Negative Shows the state of the MSB of the result N is most commonly used in two’s complement arithmetic (more on this later) H – Half Carry Indicates a carry from accumulator A bit 3 during an addition operation DAA instruction uses the value of the H bit

12 ECE 372 – Microcontroller Design HCS12 Registers - CCR Condition Code Register (CCR) S – Enable/Disable STOP instruction Clearing the S bit enables the STOP instruction Setting the S bit will treat a STOP instruction like a NOP I, X – Mask IRQ/XIRQ Interrupts More on these later

13 ECE 372 – Microcontroller Design Time for Fun (or maybe not?)

14 ECE 372 – Microcontroller Design MC9S12C Block Diagram

15 ECE 372 – Microcontroller Design MC9S12C Block Diagram Internal System Bus

16 ECE 372 – Microcontroller Design Instruction Execution Timing - Reset ECLK ADDR 15:0 R/W DATA 15:0 $FFFE $4000 $8600 $4000$86LDAA immediate addressing $4001$00Value to be stored in A $4002$81CMPA immediate addressing $4003$0ACompare Value 10 $4004$2CBGE (Branch if greater then or equal to zero) $4005$04PC=PC+2+Rel $4006$8BADDA immediate addressing $4007$01Value to add to A $4008$20Branch Always $4009$F8PC=PC+2+Rel $810A $4002 Triggered by Reset Read initial PC address Read ldaa instruction and immediate value

17 ECE 372 – Microcontroller Design Instruction Execution Timing – Initial Loop Execution ECLK ADDR 15:0 R/W DATA 15:0 $FFFE $4000 $8600 $4000$86LDAA immediate addressing $4001$00Value to be stored in A $4002$81CMPA immediate addressing $4003$0ACompare Value 10 $4004$2CBGE (Branch if greater then or equal to zero) $4005$04PC=PC+2+Rel $4006$8BADDA immediate addressing $4007$01Value to add to A $4008$20Branch Always $4009$F8PC=PC+2+Rel $810A $4002$4004 A = 0 $2C04 $4006 $8B01 Branch not taken, requires only 1 cycles A = 1

18 ECE 372 – Microcontroller Design Instruction Execution Timing – BRA Execution ECLK ADDR 15:0 R/W DATA 15:0 $4006$4008 $8B01 $4000$86LDAA immediate addressing $4001$00Value to be stored in A $4002$81CMPA immediate addressing $4003$0ACompare Value 10 $4004$2CBGE (Branch if greater then or equal to zero) $4005$04PC=PC+2+Rel $4006$8BADDA immediate addressing $4007$01Value to add to A $4008$20Branch Always $4009$F8PC=PC+2+Rel $20F8 $4002 $810A $4004 $2C04 Branch always (BRA) requires 3 cycles PC = $ $F8(-8) = $4002 A = 1

19 ECE 372 – Microcontroller Design Instruction Execution Timing – Final Loop Execution ECLK ADDR 15:0 R/W DATA 15:0 $4002$4004 $810A $4000$86LDAA immediate addressing $4001$00Value to be stored in A $4002$81CMPA immediate addressing $4003$0ACompare Value 10 $4004$2CBGE (Branch if greater then or equal to zero) $4005$04PC=PC+2+Rel $4006$8BADDA immediate addressing $4007$01Value to add to A $4008$20Branch Always $4009$F8PC=PC+2+Rel $2C04 $4010 $???? PC = $ $04 = $4010 A = 10 A>=10, Branch taken, requires 3 cycles