© 2010 Kettering University, All rights reserved..

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

© 2010 Kettering University, All rights reserved..
H. Huang Transparency No.1-1 The HCS12/MC9S12 Microcontroller Copyright © 2010 Delmar Cengage Learning HCS12 Instruction Examples The LOAD and STORE Instructions.
EECC250 - Shaaban #1 Lec # 2 Winter Addressing Modes  Addressing modes are concerned with the way data is accessed  Addressing can be.
EET 2261 Unit 3 Assembly Language; Load, Store, & Move Instructions  Read Almy, Chapters 5 and 6.  Homework #3 and Lab #3 due next week.  Quiz next.
Programming 68HC11.
EE 362 Microprocessor Systems and Interfacing © 1-1 Lecture 1: Introduction to Microprocessor Based Systems Microprocessor Architecture Microprocessor.
© 2010 Kettering University, All rights reserved..
EET 2261 Unit 5 Tables; Decision Trees & Logic Instructions
Revised: Aug 1, EE4390 Microprocessors Lesson 6,7 Instruction Set, Branch Instructions, Assembler Directives.
Addressing Modes & Instruction Set By: Prof. Mahendra B. Salunke Asst. Prof., Department of Computer Engg., SITS, Pune-41 URL:
© 2010 Kettering University, All rights reserved..
© 2010 Kettering University, All rights reserved..
Assembler Programming Chapter 6. EEL-4746 Best Practices.
The 68HC11 Microcontroller Minnesota State University, Mankato
H. Huang Transparency No.1-1 The 68HC11 Microcontroller Chapter 1: Introduction to 68HC11 The 68HC11 Microcontroller.
© 2010 Kettering University, All rights reserved..
TK 2633 Microprocessor & Interfacing Lecture 3: Introduction to 8085 Assembly Language Programming (2) 1 Prepared By: Associate Prof. Dr Masri Ayob.
Chapter 1 Introduction to HCS12/MC9S12. Computer Hardware Organization What is a Computer? Software Hardware.
Room: E-3-31 Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language.
EET 2261 Unit 2 HCS12 Architecture
© 2010 Kettering University, All rights reserved..
The M68HC11 Basic Instruction Set Basic Arithmetic Instructions
Basic Microcontroller System
Assembly Language Programming for the MC68HC11. Assembly language programming  Recall the 4 design levels for software development: – Application – High.
© 2010 Kettering University, All rights reserved..
Physics 413 Chapter 1: Introduction to the HCS 12 Microcontroller.
© 2010 Kettering University, All rights reserved..
ME4447/6405 The George W. Woodruff School of Mechanical Engineering ME4447/6405 Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics.
Microprocessors A microprocessor is essentially a computer on a single chip. It is also an example of a complex finite state machine or clocked sequential.
EECC250 - Shaaban #1 Lec # 20 Winter Microcontroller Basics A microcontroller is a small, low-cost computer-on-a-chip which usually includes:
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
Computer Architecture and the Fetch-Execute Cycle
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.
Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 7.
© 2010 Kettering University, All rights reserved..
© 2010 Kettering University, All rights reserved..
ECE 447: Lecture 12 Logic, Arithmetic, Data Test and Control Instructions of MC68HC11.
6-1 EE 319K Introduction to Microcontrollers Lecture 6: Indexed Addressing Mode and Variants, Functional Debugging, Arrays, Strings.
ME4447/6405 The George W. Woodruff School of Mechanical Engineering ME4447/6405 Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics.
ECE 265 – LECTURE 5 The M68HC11 Basic Instruction Set 12/8/ ECE265.
ECE 265 – LECTURE 11 Editing and the Assembler (updated 11/11/10) 12/15/ ECE265.
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.
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.
Advanced Assembly Language Programming
© 2010 Kettering University, All rights reserved..
ECE 447: Lecture 11 Introduction to Programming in Assembly Language.
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.
EE345 Chapter 2 Lecture 3 April Instruction and addressing modes 1.Extended Addressing 2.Direct Addressing 3.Inherent Addressing 4.Immediate Addressing.
Addressing Modes in Microprocessors
HC11 Programming.
ECE 3430 – Intro to Microcomputer Systems
ECE 3430 – Intro to Microcomputer Systems
ECE 3430 – Intro to Microcomputer Systems
ECE 3430 – Intro to Microcomputer Systems
Processor Instructions set. Learning Objectives
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME4447/6405 Microprocessor Control of Manufacturing Systems and
Branching and Loops.
Physics 413 Chapter 2.
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
Indexing Through Memory
ECE511: Digital System & Microprocessor
Presentation transcript:

© 2010 Kettering University, All rights reserved.

Microcomputers I – CE 320 Electrical and Computer Engineering Kettering University Jaerock Kwon, Ph.D.

Announcements Uploaded Ex. 3. to the course webpage.

Lecture 7: Comparison Branches

Today’s Goals Review addressing modes Use basic instructions Use the Unsigned and Signed Comparison Branches to control the flow of programs

Addressing Mode Summary How to Get an Effective Address INH Op Code IMM Op Code Data Op Code Data-high Data-low DIR Op Code Addr-low 00 Effective Address EXT Op Code Addr-high Addr-low Addr-high Effective Address Addr-low IDX Op Code Offset Effective Address Index Register REL Op Code Relative offset Effective Address Program Counter

Basic Instructions 8 Bit accumulator load  LDAA: load a value from the specified memory to accumulator A  LDAB: load a value from the specified memory to accumulator B 8 bit accumulator store  STAA: store a value in accumulator A into the specified memory  STAB: store a value in accumulator B into the specified memory 16 bit register load and store  LDD, LDX, LDY, LDS  STD, STX, STY, STS Examples:  Tell the difference between LDAA #$10 and LDAA $10 LDD $1000 and LDD #$1000 Load and store instruction

Basic Instructions Exchange instructions  EXG: exchange register contents EXG X Y EXG A B EXG X B EXG B X  XGDX: exchange register D and X  XGDY: exchange register D and Y Move  MOVB: move a byte from a memory to another MOVB #32 $0811 MOVB 1,X+ 1,Y+ ; (X)+1  (Y) +1 and X=X+1, Y=Y+1  MOVW: move a word (2 bytes) from a memory to another Clear  CLR: clear a byte in the specified memory CLR$0800 ; set the content at $0800 to 0  CLRA  CLRB Exchange, Move, and Clear Compare Move instructions with Store ones. Move: Memory to Memory Store: Register to Memory

Basic Instructions Copy a value from one register to another  TFR: Transfer a content of one register to another TFR A B  TAB: (A)  (B)  TBA: (B)  (A)  SEX: Sign EXtended transfer from 8 bit register to 16 bit register SEX A D  TPA: (CCR)  (A)  TAP: (A)  (CCR)  TSX: (SP)  (X)  TXS: (X)  (SP)  TSY: (SP)  (Y)  TYS: (Y)  (SP) Register to register transfer

Basic Instructions Increments  INC: (M) + 1  M  INCA: (A) + 1  A  INCB  INS  INX  INY Decrements  DEC  DECA  DECB  DES  DEX  DEY Negate  NEG: negate a memory byte  NEGA  NEGB Increments, Decrements, and Negate

Basic Instructions Comparison instructions  Actually, they are subtractions.  Discard the answer  No change in the registers and the memories  CCR bits are affected instead. CBA: Compare B to A:  Subtract the B accumulator from the A accumulator  (A) – (B) CMPA, CMPB: Compare accumulator to memory :  Subtract the content of a memory from the accumulator  (A) – (M), (B)- (M) Comparison Comparison is nothing but subtraction discarding the answer. The order is important! Need to know which one is minuend or which subtrahend to interpret CCR bits.

Comparison Instruction Let register A have 10h, register B have 20h  (A) = 10h, (B) = 20h CBA  (A) – (B) = E0h  Instead of saving the result, the result $E0 affects CCR bits.  N: 1, Z: 0, V: 0, C:1 CMPA, CMPB  Assume FFh at address $1000  CMPA $1000 (A) – ($1000) = 10h – FFh = 11h N: 0, Z: 0, V: 0, C: 1 Therefore,  CBA does not mean that I want to compare B and A.  Rather, CBA means that I want to know what happens in CCR bits after (A) – (B) operation. Example

Comparison Branches Comparison branches are based on comparing two numbers. Comparing is done by subtraction (see the previous slides). The subtraction instruction set CCR bits.  Three categories of subtraction Actual subtraction  Perform operation and keep the result. Comparison*  Perform subtraction and discard the answer. Test  Perform subtraction using 0. Comparison branch instructions examine the CCR bits. Logically, comparison instructions are needed before we are using comparison branches. But, actually comparison branch instructions only check CCR bits. Therefore, any instructions that can affect CCR bits can be placed before comparison branch instructions.

Comparison Branches Two sets of comparison branches: unsigned and signed Unsigned:  Higher, Higher or Same, Lower, Lower or Same Signed  Greater Than, Greater or Equal, Less Than, Less or Equal HCS12 instructions for comparison branches. Instructions ComparisonUnsignedSigned > ≥ < ≤ = ≠ BHIBGT BHSBGE BLOBLT BLSBLE BEQ BNE

Comparison Branches Trace the program below. Assume the memory locations $2000, $2001, and $2002 are already set to $40, $F0, and $55 respectively. Example Program 1: 1500 CE 2000 LDX #$2000 1: 1500 CE 2000 LDX #$2000 2: B FF 1000 MOVB #$FF,$1000 2: B FF 1000 MOVB #$FF,$1000 3: 1508 C6 02 LDAB #2 3: 1508 C6 02 LDAB #2 4: 150A 27 0E BEQ 14 4: 150A 27 0E BEQ 14 5: 150C A6 00 LDAA 0,X 5: 150C A6 00 LDAA 0,X 6: 150E B CMPA $1000 6: 150E B CMPA $1000 7: BHS 3 7: BHS 3 8: A 1000 STAA $1000 8: A 1000 STAA $1000 9: INX 9: INX 10: DECB 10: DECB 11: F0 BRA : F0 BRA : 151A 3F SWI 12: 151A 3F SWI … F …

TraceLinePCABXNZVC : 1500 CE 2000 LDX #$2000 1: 1500 CE 2000 LDX #$2000 2: B FF 1000 MOVB #$FF,$1000 2: B FF 1000 MOVB #$FF,$1000 3: 1508 C6 02 LDAB #2 3: 1508 C6 02 LDAB #2 4: 150A 27 0E BEQ 14 4: 150A 27 0E BEQ 14 5: 150C A6 00 LDAA 0,X 5: 150C A6 00 LDAA 0,X 6: 150E B CMPA $1000 6: 150E B CMPA $1000 7: BHS 3 7: BHS 3 8: A 1000 STAA $1000 8: A 1000 STAA $1000 9: INX 9: INX 10: DECB 10: DECB 11: F0 BRA : F0 BRA : 151A 3F SWI 12: 151A 3F SWI … 1000 … F … A C E

TraceLinePCABXNZVC : 1500 CE 2000 LDX #$2000 1: 1500 CE 2000 LDX #$2000 2: B FF 1000 MOVB #$FF,$1000 2: B FF 1000 MOVB #$FF,$1000 3: 1508 C6 02 LDAB #2 3: 1508 C6 02 LDAB #2 4: 150A 27 0E BEQ 14 4: 150A 27 0E BEQ 14 5: 150C A6 00 LDAA 0,X 5: 150C A6 00 LDAA 0,X 6: 150E B CMPA $1000 6: 150E B CMPA $1000 7: BHS 3 7: BHS 3 8: A 1000 STAA $1000 8: A 1000 STAA $1000 9: INX 9: INX 10: DECB 10: DECB 11: F0 BRA : F0 BRA : 151A 3F SWI 12: 151A 3F SWI Continued 11150A C EF F F F F AF AF … 1000 … F … FF  40

Questions What does this program do?  Get a minimum value from the values from $2000 to ($ the initial content in register B) What changes are needed to process 200 bytes?  Line 3: LDAB #2  LDAB #200 (or #$C8 or #C8h) What changes are needed to process signed numbers?  Line 7: BHS  BGT  Line 2: #$FF  #$7F (or #7Fh) What changes are needed if the list of data begins at $3000?  Line 1: #$2000  #$3000h (or #3000h) What changes are needed if the answer must be stored to location $3FFF?  Line 2, 6, and 8: $1000  $3FFF (or 3FFFh)

Questions?

Wrap-up Quick tour of basic instructions Comparison branches  Unsigned BHI, BGT, BHS, BGE  Signed BLO, BLT, BLS, BLE  Either signed or unsigned BEQ, BNE What we’ve learned

What to Come Assembly language Flowchart