3-1 EE 319K Introduction to Microcontrollers Lecture 3: Addressing modes, Memory Operations, Subroutines, I/O, Logical/Shift Operations.

Slides:



Advertisements
Similar presentations
Chapter 5 Tutorial 5a. Editing and Assembling From Valvano.
Advertisements

H. Huang Transparency No.1-1 The HCS12/MC9S12 Microcontroller Copyright © 2010 Delmar Cengage Learning HCS12 Instruction Examples The LOAD and STORE Instructions.
Microprocessors.
10-1 EE 319K Introduction to Microcontrollers Lecture 10: Interrupts, Output Compare Periodic Interrupts Read Book Sections 9.1, 9.2, 9.4, 9.6.1, 9.6.2,
ELEC 330 Digital Systems Engineering Dr. Ron Hayne
EET 2261 Unit 5 Tables; Decision Trees & Logic Instructions
Addressing Modes & Instruction Set By: Prof. Mahendra B. Salunke Asst. Prof., Department of Computer Engg., SITS, Pune-41 URL:
68HC11 Polling and Interrupts
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.
1 ECE 372 – Microcontroller Design Basic Assembly Programming for(j=0; j
Recap – Our First Computer WR System Bus 8 ALU Carry output A B S C OUT F 8 8 To registers’ input/output and clock inputs Sequence of control signal combinations.
State Machines Used to Design Sequential Circuits.
1-1 Ramesh Yerraballi EE 319K Introduction to Microcontrollers Lecture 1: Introduction, Embedded Sys, Product Life- Cycle, 9S12 Programming.
Chapters 4 & 5: LC-3 Computer Architecture Machine Instructions Assembly language Programming in Machine and Assembly Language.
Overview von Neumann Model Components of a Computer Some Computer Organization Models The Computer Bus An Example Organization: The LC-3.
2-1 EE 319K Introduction to Embedded Systems Lecture 2: I/O, Logic/Shift Operations, Addressing modes, Memory Operations, Subroutines, Introduction to.
Microcontroller Fundamentals & Programming
Lab 1 – Assembly Language and Interfacing Start date: Week 3 Due date: Week 4 1.
A Simple Tour of the MSP430. Light LEDs in C LEDs can be connected in two standard ways. Active high circuit, the LED illuminates if the pin is driven.
ME4447/6405 The George W. Woodruff School of Mechanical Engineering ME4447/6405 Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics.
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.
© 2010 Kettering University, All rights reserved..
9-1 EE 319K Introduction to Microcontrollers Lecture 9:I/O Synchronization; LCD Interfacing; Implementing Local Variables using a Stack Frame; Parameter.
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.
EE 319K Introduction to Microcontrollers
Ch. 6 Pointers and Data Structures From the text by Valvano: Introduction to Embedded Systems: Interfacing to the Freescale 9S12.
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.
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.
The von Neumann Model – Chapter 4 COMP 2620 Dr. James Money COMP
8-1 EE 319K Introduction to Microcontrollers Lecture 8:Fixed Point Numbers, Local Variables, Binding, Allocation, Access, Deallocation.
Ch.2 Intro. To Assembly Language Programming
ECE Lecture 21 Typical Assembly Language Program Bugs.
EE 319K Introduction to Embedded Systems
Ch.2 Intro. To Assembly Language Programming From Introduction to Embedded Systems: Interfacing to the Freescale 9s12 by Valvano, published by CENGAGE.
ECE 447: Lecture 16 Common Errors & Good Programming Style.
Advanced Assembly Language Programming
ECE 447 Fall 2009 Lecture 4: TI MSP430 Architecture and Instruction Set.
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.
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.
CPU12 Instruction Set Overview
Instruction sets : Addressing modes and Formats
ELEC 418 Advanced Digital Systems Dr. Ron Hayne
ELEC 418 Advanced Digital Systems Dr. Ron Hayne
ECE 3430 – Intro to Microcomputer Systems
Addressing Modes in Microprocessors
Gunjeet Kaur Dronacharya Group of institutions
S04: MSP430 Microarchitecture
EE 319K Introduction to Embedded Systems
ECE 3430 – Intro to Microcomputer Systems
Microcomputer Programming
A Closer Look at Instruction Set Architectures: Expanding Opcodes
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME4447/6405 Microprocessor Control of Manufacturing Systems and
ECE 3430 – Intro to Microcomputer Systems
Instruction encoding We’ve already seen some important aspects of processor design. A datapath contains an ALU, registers and memory. Programmers and compilers.
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
Shift & Rotate Instructions)
Instruction encoding We’ve already seen some important aspects of processor design. A datapath contains an ALU, registers and memory. Programmers and compilers.
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
Presentation transcript:

3-1 EE 319K Introduction to Microcontrollers Lecture 3: Addressing modes, Memory Operations, Subroutines, I/O, Logical/Shift Operations

3-2 Ramesh Yerraballi ldaa

3-3 Ramesh Yerraballi Simple Addressing Modes  Clarifications:  Immediate mode can use more than 8-bit values: ldd #W;RegD=W load a 16-bit constant into RegD lds #W ;SP=W load a 16-bit constant into SP  Branch uses a 8-bit offset however there is a long Branch instruction that can increase this to 16-bits obra, bmi, bne, bpl use 8-bit offset: bra rel820 rr olbra, lbmi, lbne, lbpl, and 16 other long branch instructions use 16-bit offset: lbra rel qq rr oJmp uses 16-bit destination address in extended addr mode: jmp opr1606 hh ll

3-4 Ramesh Yerraballi Memory to memory move  Note that the “addressing mode” applies to the operands. If an instruction has two operands each has its own addressing mode:  movb#w,addr ; [addr]=w Move an 8-bit constant into memory  movbaddr1,addr2 ; [addr2]=[addr1] Move an 8-bit value memory to memory  movw#W,addr ;{addr}=W Move a 16-bit constant into memory  movwaddr1,addr2 ;{addr2}={addr1} Move a 16-bit value memory to memory EXT-IMM EXT-EXT EXT-IMM EXT-EXT

3-5 Ramesh Yerraballi Subroutines $0800 org $0800 $0800 Flag rmb 1 $0801 Data rmb 2 $4000 org $4000 ;*****Set************** ; Set Data=1000, and Flag=1 ; Input: None ; Output: None $ E80801 Set movw #1000,Data ;3 $ B movb #1,Flag ;4 $400B 3D rts ;5 $400C CF4000 main lds #$4000 ;1 $400F 07EF bsr Set ;2 $ FE loop bra loop ;6 $FFFE org $fffe $FFFE 400C fdb main

3-6 Ramesh Yerraballi Stack Use in Subroutines: bsr bsr Execution: Opcode fetch R 0x400F 0x07 from ROM Phase 1 Operand fetch R 0x4010 0xEF from ROM Phase 1 Stack store lsbW 0x3FFF 0x11 to RAM Phase 6 Stack store msbW 0x3FFE 0x40 to RAM Phase 6

3-7 Ramesh Yerraballi Stack Use in Subroutines: rts rts Execution: Opcode fetch R 0x4009 0x3D from ROM Phase 1 Stack read msb R 0x3FFE 0x40 from RAM Phase 4 Stack read lsb R 0x3FFF 0x11 from RAM Phase 4

3-8 Ramesh Yerraballi Input/Output: 9S12DP512

3-9 Ramesh Yerraballi I/O Ports and Direction Registers  The input/output direction of a bidirectional port is specified by its direction register.  DDRH, DDRP, DDRJ, DDRT, specify if corresponding pin is input or output:  0 means input  1 means output AddressBit Bit0Name $0240 PT7PT6PT5PT4PT3PT2PT1PT0 PTT $0242 DDRT7DDRT6DDRT5DDRT4DDRT3DDRT2DDRT1DDRT0 DDRT

3-10 Ramesh Yerraballi Logical Operations anda#w ;RegA=RegA&w andau ;RegA=RegA&[u] andaU ;RegA=RegA&[U] oraa#w ;RegA=RegA|w oraau ;RegA=RegA|[u] oraaU ;RegA=RegA|[U] eora#w ;RegA=RegA^w eorau ;RegA=RegA^[u] eoraU ;RegA=RegA^[U] coma ;RegA=~RegA

3-11 Ramesh Yerraballi Switch Interfacing The and operation to extract, or mask, individual bits: Pressed = PTT&0x40;//true if the switch pressed Assembly : ldaa PTT ;read input Port T anda #$40 ;clear all bits except bit 6 staa Pressed ;true iff the switch is pressed a 7 a 6 a 5 a 4 a 3 a 2 a 1 a 0 value of PTT $40 constant 0 a result of the anda

3-12 Ramesh Yerraballi To set The or operation to set bits 1 and 0 of the register DDRT. The other six bits of DDRT remain constant. Friendly software modifies just the bits that need to be. DDRT |= 0x03; // PT1,PT0 outputs Assembly: ldaa DDRT ;read previous value oraa #$03 ;set bits 0 and 1 staa DDRT ;update c 7 c 6 c 5 c 4 c 3 c 2 c 1 c 0 value of DDRT $03 constant c 7 c 6 c 5 c 4 c 3 c result of the oraa

3-13 Ramesh Yerraballi To toggle The exclusive or operation can also be used to toggle bits. PTT ^= 0x80; /* toggle PT7 */ Assembly: ldaa PTT ;read output Port T eora #$80 ;toggle bit 7 staa PTT ;update b 7 b 6 b 5 b 4 b 3 b 2 b 1 b 0 value of PTT $80 constant ~b 7 b 6 b 5 b 4 b 3 b 2 b 1 b 0 result of the eora

3-14 Ramesh Yerraballi Shift Operation asla;RegA=RegA*2 lsla;RegA=RegA*2 asra;RegA=RegA/2 lsra;RegA=RegA/2 Use the asla instruction when manipulating signed numbers, and use the lsla instruction when shifting unsigned numbers

3-15 Ramesh Yerraballi Shift Example High and Low are unsigned 4-bit components, which will be combined into a single unsigned 8-bit Result. Result = (High<<4)|Low; Assembly: ldaa High ;read value of High lsla ;shift into position lsla oraa Low ;combine the two parts staa Result ;save answer h 3 h 2 h 1 h 0 value of High h 3 h 2 h 1 h 0 0 after first lsla 0 0 h 3 h 2 h 1 h after second lsla 0 h 3 h 2 h 1 h after third lsla h 3 h 2 h 1 h after last lsla l 3 l 2 l 1 l 0 value of Low h 3 h 2 h 1 h 0 l 3 l 2 l 1 l 0 result of the oraa instruction