15-348 Embedded Systems Lecture 5 January 25 th, 2016.

Slides:



Advertisements
Similar presentations
Ch.3 Representation and Manipulation of Information From Introduction to Embedded Systems: Interfacing to the Freescale 9s12 by Valvano, published by CENGAGE.
Advertisements

Microprocessors.
The 8051 Microcontroller and Embedded Systems
INSTRUCTION SET ARCHITECTURES
Programming 68HC11.
EE 362 Microprocessor Systems and Interfacing © 1-1 Lecture 1: Introduction to Microprocessor Based Systems Microprocessor Architecture Microprocessor.
Revised: Aug 1, EE4390 Microprocessors Lesson 6,7 Instruction Set, Branch Instructions, Assembler Directives.
68HC11 Polling and Interrupts
The 68HC11 Microcontroller Minnesota State University, Mankato
H. Huang Transparency No.1-1 The 68HC11 Microcontroller Chapter 1: Introduction to 68HC11 The 68HC11 Microcontroller.
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.
Pyxis Aaron Martin April Lewis Steve Sherk. September 5, 2005 Pyxis16002 General-purpose 16-bit RISC microprocessor bit registers 24-bit address.
EET 2261 Unit 2 HCS12 Architecture
Chapters 4 & 5: LC-3 Computer Architecture Machine Instructions Assembly language Programming in Machine and Assembly Language.
© 2010 Kettering University, All rights reserved..
Lecture 18 Last Lecture Today’s Topic Instruction formats
Lab 1 – Assembly Language and Interfacing Start date: Week 3 Due date: Week 4 1.
Module 10 Adapted By and Prepared James Tan © 2001.
Machine Instruction Characteristics
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:
Objectives Implement pointers using indexed addressing modes Use pointers to access arrays, strings, structures, tables, and matrices Present finite-state.
ECE 265 – LECTURE 8 The M68HC11 Basic Instruction Set The remaining instructions 10/20/ ECE265.
Revised: Aug 1, ECE263 Embedded System Design Lesson 4 Programming Model, Assembly Language, Instruction Execution Cycle.
Execution of an instruction
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.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
1 Segments and Pseudo Operations Program Development.
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 ECE 372 – Microcontroller Design Assembly Programming HCS12 Assembly Programming Addressing Modes Stack Operations Subroutines.
EE 345 Class Notes EE345 Midterm Review Dr. Jane Dong.
1 Introduction to Microcontroller Microcontroller Fundamentals & Programming.
Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 8.
Ch.2 Intro. To Assembly Language Programming
Ch.2 Intro. To Assembly Language Programming From Introduction to Embedded Systems: Interfacing to the Freescale 9s12 by Valvano, published by CENGAGE.
COMPUTER ORGANIZATION AND ASSEMBLY LANGUAGE Lecture 21 & 22 Processor Organization Register Organization Course Instructor: Engr. Aisha Danish.
Microcontroller Fundamentals & Programming Arithmetic Instructions.
CS61C L20 Datapath © UC Regents 1 Microprocessor James Tan Adapted from D. Patterson’s CS61C Copyright 2000.
ECE 447: Lecture 11 Introduction to Programming in Assembly Language.
1 Basic Processor Architecture. 2 Building Blocks of Processor Systems CPU.
Instruction Sets: Characteristics and Functions  Software and Hardware interface Machine Instruction Characteristics Types of Operands Types of Operations.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
Embedded Systems Lecture 4 January 20, 2016.
EE345 Chapter 2 Lecture 3 April Instruction and addressing modes 1.Extended Addressing 2.Direct Addressing 3.Inherent Addressing 4.Immediate Addressing.
“ INSTRUCTIONS SET OF AVR MICROCONTROLLER ” SIGMA INSTITUTE OF ENGINEERING Prepared By: SR.NO NAME OF STUDENT ENROLLMENT 1 Abhishek Lakhara
Programmable System on Chip
Addressing Modes in Microprocessors
ECE 3430 – Intro to Microcomputer Systems
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
Microcomputer Programming
A Closer Look at Instruction Set Architectures: Expanding Opcodes
ME4447/6405 Microprocessor Control of Manufacturing Systems and
ECE232: Hardware Organization and Design
ECE 3430 – Intro to Microcomputer Systems
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
CS501 Advanced Computer Architecture
COMPUTER ORGANIZATION AND ARCHITECTURE
Computer Architecture Assembly Language
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
Presentation transcript:

Embedded Systems Lecture 5 January 25 th, 2016

Road Map  What have we done  Gotten familiar with embedded hardware  Bit manipulation in C  Input and Output using I/O ports  What we plan on doing  Programming in Assembly Language  What you should do  Read pages from the textbook

Registers in 9S12  CCR – Condition Code Register  S – Stop Bit: Used to enable stop mode for power saving  X – Interrupt Mask:  I – Interrupt Mask:  C – Carry Flag: Set when carry out from D7  V – Overflow Flag: Set for signed overflow  Z – Zero Flag: Set when result is zero  N – Negative Flag: Set when result is negative  H – Half-byte carry Flag: Set when carry from D3 to D4 SXHIN Z V C 8-bit condition code

Registers in 9S12  Two 8-bit accumulators  Two 16-bit index registers (X and Y)  16-bit stack pointer SP  16-bit program counter PC Register ARegister B Register D

Memory Structure of MC9S12C128 0x0000 0x0400 0x1000 0x4000 0xFF00 0xFFFF 0x0000 – 0x03FF 1K Register Space 0x0400 – 0x1000 ~4K RAM 0x4000 – 0xFF00 ~128K ROM (EEPROM) 0xFF00 – 0xFFFF Vector Space

Using the RAM Global Variables RAM 4K Bytes Available Memory Stack grows down Stack Stack Pointer

Using ROM  Fixed Constants  Strings  Calibration values  ID numbers  Finite State Machines  Device Address Fixed Constants Machine Code Vector Table PC

What is assembly language  Machine code in human readable format  Human readable is of course relatively speaking  E.g. DDRT equ $0x0240 ldaa #$0F860F staa DDRT7A F7A0240 Assembly Language Equivalent Machine code Real Machine code

Assembly Format  Each field separated by whitespace [Label] Instruction [Operands] [Comments] PORTAequ $0000 Inpldaa PORTA ; read input Labelclra deca ; decrement a bne Label  The operand field depends on the operation

Assembly Instructions  Two main kinds of instructions  Operations  Assembler Directives DDRT equ $0x0240  Assembler Directive ldaa #$0F  Load Operation staa DDRT  Store Operation

Load instructions  ldaaload accumulator a  ldabload accumulator b  lddload register d  ldxload index register x  ldyload index register y  ldsload Stack Pointer 16 bit move

Addressing modes (load what?)  ldaa#wLoad the value w in a  ldaaULoad the value at address U  All load instructions set the N and the Z bit in CCR

Store instructions  staaU  stab  std  stx  sty  sts  All store instructions set the N and the Z bit in CCR

Example C code: DDRB = 0x45; PORTB = 0x23 Assembly Code: LDAA #$45 STAA $03 ; DDRB is address 3 LDAB #$23 STAB $01 ; PORTB is address 1

More addressing modes  Indexed staa -4,YReg a  Address Y- 4 staa$40,YReg a  [Y+$40]  Auto inc/dec Indexed staa 1, Y+ Reg a  [Y] and Y = Y+1 staa 4, Y+ Reg a  [Y] and Y = Y+4 staa 4, +Y Reg a  [Y + 4] and Y = Y+4 [Y-4]

More addressing modes  Accumulator Offset Indexed ldab #4 ldy #2345 staa B,Y ;store contents of a at 2349

Arithmetic Operations  8-bit Add adda#w ; RegA=RegA + w addaU ; RegA = RegA +[U] addb#w ; RegB=RegB + w addbU ; RegB = RegB +[U]  Add instructions sets the N, Z, V, and C bits in CCR

16-bit add addd#W; RegD = RegD + W addd#U; RegD = RegD + [U] Example: ldd$1234 addd#1000 std$1238

Example C code: byte a = 23; byte b = 12; PORTA = a + b Assembly Code: LDAA #23 ADDA #12 STAA $00; PORTA is address 0

Subtract suba#w;RegA = RegA – w cmpa#w; RegA – w tsta; RegA – 0 cpd#W; RegD – W subdU; RegD – [U] deca; RegA = RegA -1 incb; RegB = RegB +1 Only Used to set CCR

Multiply mul; RegD = RegA * RegB ldaa#3; RegA = 3 ldab#100; RegB = 100 mul; RegD = 300

Divide idiv; RegX = RegD/RegX ; RegD = RegD%RegX ldd#53 ldx#12 idiv; RegX = 4, RegD = 5

Shift Operations  asla  asld  asrb  lsra  lsrb  rolaRoll left using C bit from CCR  roraRoll right using C bit from CCR

Example C code: int i = 23; PORTA = i >> 2; Assembly Code: LDAD #23 ASRD STAB $00; PORTA is address 0

Branch operations bcctarget;Branch to target if C=0 bcstarget;Branch to target if C=1 beqtarget;Branch to target if Z=1 bnetarget;Branch to target if Z=0 bmitarget;Branch to target if N=1 bpltarget;Branch to target if N=0 bratarget;Branch to target always jmptarget;Branch to target always 8-bit signed 16-bit signed

More branch instructions  Following instructions must follow a subtract instruction bge,bgt,ble,blt

Example if(G2 == G1) isEqual(); Given two variable G1 and G2, write assembly code for the above code: ldaaG1 subaG2 bneskip bsrisEqual skip:

Example  Implement the following C code in assembly int main() { int i; byte sum = 12; for(i = 0; i <10; i++) sum = sum + 1; }