George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.

Slides:



Advertisements
Similar presentations
Microprocessors.
Advertisements

CS25410 Memory Machine Code. Common types of non-rotating memory (1) RAMRandom Access Memory In reality, read/write memory This is usually volatile, meaning.
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:
H. Huang Transparency No.1-1 The 68HC11 Microcontroller Chapter 1: Introduction to 68HC11 The 68HC11 Microcontroller.
TK 2633 Microprocessor & Interfacing
S. Barua – CPSC 240 CHAPTER 5 THE LC-3 Topics Memory organization Registers Instruction set Opcodes.
Execution of an instruction
TK 2633 Microprocessor & Interfacing Lecture 3: Introduction to 8085 Assembly Language Programming (2) 1 Prepared By: Associate Prof. Dr Masri Ayob.
Room: E-3-31 Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language.
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.
Chapters 5 - The LC-3 LC-3 Computer Architecture Memory Map
EET 2261 Unit 2 HCS12 Architecture
Architecture of the MSP430 Processor. Central Processing Unit Program Counter (PC) - Contains the address of the next instruction to be executed. The.
Assembly & Machine Languages
Lecture 18 Last Lecture Today’s Topic Instruction formats
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.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
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.
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 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.
COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer Science York University Handout # 3: MIPS Instruction Set I Topics: 1.
Chapter 10 The Assembly Process. What Assemblers Do Translates assembly language into machine code. Assigns addresses to all symbolic labels (variables.
Execution of an instruction
ECE 447: Lecture 12 Logic, Arithmetic, Data Test and Control Instructions of MC68HC11.
IFT 201: Unit 1 Lecture 1.3: Processor Architecture-3
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.
9/20/6Lecture 2 - Prog Model Architecture, Data Types and Addressing Modes.
3-1 EE 319K Introduction to Microcontrollers Lecture 3: Addressing modes, Memory Operations, Subroutines, I/O, Logical/Shift Operations.
Lecture Set 4 Programming the 8051.
Addressing Modes MTT CPU08 Core Motorola CPU08 ADDRESSING MODES.
1 ECE 372 – Microcontroller Design Assembly Programming HCS12 Assembly Programming Addressing Modes Stack Operations Subroutines.
Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 8.
Ass Prof Dr Masri Ayob TK 2633: Microprocessor & Interfacing Lecture 6: Control Instructions.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
Topics covered: Instruction Set Architecture CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
Ch.2 Intro. To Assembly Language Programming From Introduction to Embedded Systems: Interfacing to the Freescale 9s12 by Valvano, published by CENGAGE.
1 Microcontroller Fundamentals & Programming Addressing Modes.
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.
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 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.
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.
Assembly Language Programming of 8085
ECE 3430 – Intro to Microcomputer Systems
ECE 3430 – Intro to Microcomputer Systems
Conditional Branches What distinguishes a computer from a simple calculator is its ability to make decisions Decisions are made using the if statement,
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME4447/6405 Microprocessor Control of Manufacturing Systems and
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
68000 Architecture, Data Types and Addressing Modes
Introduction to Micro Controllers & Embedded System Design
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
COMS 361 Computer Organization
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
MIPS e pipelining Tecniche di base.
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ECE511: Digital System & Microprocessor
Presentation transcript:

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics Instructor: Professor Charles Ume Lecture #10

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405

ME4447/6405 Relative addressing is used for branch instructions only. Three types of branch instructions: Short Branches – offset signed 8-bit number (-128 to 127) Long Branches – offset signed 16-bit number (-32,768 to 32,767) Bit Condition Branches – offset signed 8-bit number (-128 to 127) Short Branch instructions are 2 bytes in length. First byte contains opcode Second byte contains address offset BEQ Loop27 offset (I byte) Relative Addressing

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 Relative Addressing Long branch instructions are 4 bytes in length First two bytes contain opcode and postbyte Second byte contains 16-bit signed address offset LBEQ Loop MSB LSB  offset value Bit condition branch instructions are 4 to 6 bytes in length depending on addressing mode BRSET $0800 #$05 Loop 1E byte offset value BRSET $15, Y #$EA Label 0E 4F EA 1byte offset value Offset is calculated by subtracting contents of Program Counter from destination address. (Note: The Program Counter contains the memory location of the next instruction) If branch condition is true, then add offset to program counter

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ORG $1000 Address Opcode Postbyte Operand ABA $ : : BACK LDAA #$30 $106A 8630 NEGA $106C 40 ADDA $1A00 $106D BB 1A00 BEQ FRONT $ ADDA $31 $1072 9B 31 BNE BACK $ : : FRONT NOP $1080 A7 : : SWI 3F END Example Program for Relative Addressing Mode Offset ? Example: #1

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ORG $1000 Address Opcode Postbyte Operand ABA $ : : BACK LDAA #$30 $106A 8630 NEGA $106C 40 ADDA $1A00 $106D BB 1A00 BEQ FRONT $ ADDA $31 $1072 9B 31 BNE BACK $ : : FRONT NOP $1080 A7 : : SWI 3F END Example 1 Offset ? First calculate address offset for forward branch

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 Offset is positive if branching forward Example 1 Branching Forward

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ORG $1000 Address Opcode Postbyte Operand ABA $ : : BACK LDAA #$30 $106A 8630 NEGA $106C 40 ADDA $1A00 $106D BB 1A00 BEQ FRONT 27 ADDA $31 $1072 9B 31 BNE BACK $ : : FRONT NOP A7 : : SWI 3F END Example 1 Offset ? Address of BEQ instruction and Address of where to jump to (NOP) $1070 $1080

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 $ $ $ ’s COMP ’s COMP $ = $0E Example 1 Branching Forward Continued Step1: Add $02 to starting address $1070+$02 = $1072 to determine contents of Program Counter Step2: Subtract result from destination address $1080-$1072 = $0E In Hexadecimal Address Offset is:$0E

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ORG $1000 Address Opcode Postbyte Operand ABA $ : : BACK LDAA #$30 $106A 8630 NEGA $106C 40 ADDA $1A00 $106D BB 1A00 BEQ FRONT $ E ADDA $31 $1072 9B 31 BNE BACK $ : : FRONT NOP $1080 A7 : : SWI 3F END Example 1 Offset ? Calculate address offset for backward branch

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 Example 1 Branching Backward Offset negative if branching backward

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ORG $1000 Address Opcode Postbyte Operand ABA $ : : BACK LDAA #$ NEGA $106C 40 ADDA $1A00 $106D BB 1A00 BEQ FRONT $ ADDA $31 $1072 9B 31 BNE BACK 26 : : FRONT NOP $1080 A7 : : SWI 3F END Example 1 Offset ? Address of BNE instruction and Address of where to jump to (LDAA) $106A $1074

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 $106A-$1076 Note: In Binary $ $ $ ’s COMP ’s COMP $106A = $F4 Example 1 Branching Forward Continued

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 Example 1 Branching Backward Continued Step1: Add $02 to starting address$1074+$02 = $1076 to determine contents of Program Counter Step2: Subtract result from destination address$106A-$1076 But result will be negative so: In Hexadecimal Step 3: Switch order and subtract $1076-$106A = $0C Step 4: Take 1’s complement $0C -> $F3 Step5: Take 2’s complement $F3 + $01 = $F4 Address offset will be: $F4

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ORG $1000 Address Opcode Postbyte Operand ABA $ : : BACK LDAA #$30 $106A 8630 NEGA $106C 40 ADDA $1A00 $106D BB 1A00 BEQ FRONT $ E ADDA $31 $1072 9B 31 BNE BACK $ F4 : : FRONT NOP $1080 A7 : : SWI 3F END Example 1 Example Program assembled completely

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 Long branch instructions are equivalent to short branch instructions, except offset is signed 16-bit number [-32,767 to 32,768] Example: Assume distance from branch instruction to destination is greater than 127 memory locations. Must use long branch instructions: Short Branch: BNE FRONT$ A : : FRONT NOP$1080 A7 Long Branch: LBNE FRONT$ : : FRONT NOP$1480 A7 Long Branch Instructions Address Opcode Postbyte Operand

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 Branch if bit(s) clear (BRCLR) Example: Branch to DOG when bit 0 and bit 2 are clear in data contained at address $19 BRCLR $19 #$05 DOG Assume $19 contains #$63 #$63 = #$05 = (MASK) will not branch to DOG Assume $19 contains #$62 #$62 = #$05 = (MASK) will branch to DOG (Note: BRCLR may be used in extended addressing mode.) Example Branch Instructions Can also be written as: LDY #$0019 BRCLR $00,Y #$05 DOG

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 Branch if bit(s) set (BRSET) Example: Branch to DOG when bit 0 and bit 2 are set in data contained at address $20 BRSET $20 #$05 DOG Assume $20 contains #$63 #$63 = #$05 = (MASK) *will not branch to DOG Assume $20 contains #$65 #$65 = #$05 = (MASK) *will branch to DOG Example Branch Instructions Can also be written as: LDX #$0020 BRSET $00,X #$05 DOG

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 Branch Instructions from Programming Reference Guide

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 Branch Instructions from Programming Reference Guide (continued) (Note: BRCLR and BRSET boxed in Red)

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 Special Instructions Bit Clear Example: BCLR $34 #$04 Assume $34 contains #$44 #$44 = #$04 = Result: $34 will now contain Alternative: If index register X contains #$0034, we can use the following instruction to perform the same operation as above. BCLR $00,X #$04

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 Special Instructions Cont’d Bit Set Example: BSET $00,X #$01 Assume the content of index register X is #$0045 and assume that $45 contains #$60. #$60 = #$01 = Result: $45 now contains Alternative: We can use the following instruction to perform the same operation as above. BSET $45 #$01

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 Special Instructions Cont’d BITA This instruction is similar to ANDA except that the result of this operation is not stored in accumulator A. Example: BITA #$7C BNE LOOP Assume accumulator A contains #% #$7C = #% Accumulator A will still contain #% after above program is executed Result: The operation produces the result #% but this is not stored anywhere. The following instruction will branch to LOOP because the result of the preceding operation was not equal to zero.

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 Homework Set #3 Solution 1. Write a subroutine to save the first 5 odd (8-bit) numbers pointed to by the x-register (passed in) onto the stack. Note: For subroutine to execute in main program, a BSR or JSR command must be used in main program. 2. Write a program to output a square wave thru port S pin The output can be observed on the scope, and the period T of the wave should be measured. More than one period wave should be generated. The machine cycle time of the MC9S12C32 should be estimated. Draw the square wave.

George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 QUESTIONS???