EE 3170 Microcontroller Applications

Similar documents
EE 3170 Microcontroller Applications

Table 1: Mnemonics Operations Dictionary. Add Accumulators Add B to Y. Add with carry to B. Add Memory to B. Add 16-bit to D And B with Memory

2) [ 2 marks] Both of the following statements cause the value $0300 to be stored in location $1000, but at different times. Explain the difference.

Programming the Motorola MC68HC11 Microcontroller

Lecture 6 Assembly Programming: Branch & Iteration

The Motorola 68HC11 Instruc5on Set

EE 3170 Microcontroller Applications

EE 3170 Microcontroller Applications

ECE331 Handout 3- ASM Instructions, Address Modes and Directives

ME4447/6405. Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics. Instructor: Professor Charles Ume LECTURE 7

Chapter 2: HCS12 Assembly Programming. EE383: Introduction to Embedded Systems University of Kentucky. Samir Rawashdeh

Addressing Mode Description Addressing Mode Source Format Abbrev. Description

EE4390 Microprocessors

SECTION 6 CENTRAL PROCESSING UNIT

Disassembly of an HC12 Program It is sometimes useful to be able to convert HC12 op codes into mnemonics. For example, consider the hex code:

Introduction to Embedded Microcomputer Systems Lecture 8.1. Computers in the future may weigh no more than 1.5 tons Popular Science, 1949

COE538 Lecture Notes Week 3 (Week of Sept 17, 2012)

Lecture 7 Assembly Programming: Shift & Logical

538 Lecture Notes Week 2

Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers

Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers

Chapter 2 HCS12 Assembly Language

Mark II Aiken Relay Calculator

ECET Chapter 2, Part 3 of 3

Department of Computer Science and Engineering

MC9S12 Assembler Directives A Summary of MC9S12 Instructions Disassembly of MC9S12 op codes. Summary of HCS12 addressing modes ADDRESSING MODES

Exam I Review February 2017

EE 5340/7340 Motorola 68HC11 Microcontroler Lecture 1. Carlos E. Davila, Electrical Engineering Dept. Southern Methodist University

Condition Code Register. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff

Menu Computer Organization Programming Model for the an example microprocessors (the G-CPU & Motorola 68HC11) Assembly Programming Look into my...

Introduction to Microcontrollers

LECTURE #21: G-CPU & Assembly Code EEL 3701: Digital Logic and Computer Systems Based on lecture notes by Dr. Eric M. Schwartz

C SC 230 Computer Architecture and Assembly Language April 2000 Exam Sample Solutions

COSC 243. Instruction Sets And Addressing Modes. Lecture 7&8 Instruction Sets and Addressing Modes. COSC 243 (Computer Architecture)

Timing Generation and Measurements

Introduction to Programming

538 Lecture Notes Week 3

instruction 1 Fri Oct 13 13:05:

Introduction to Computers - Chapter 4

Most of the HC12 s instructions access data in memory There are several ways for the HC12 to determine which address to access

2. Arithmetic Instructions addition, subtraction, multiplication, divison (HCS12 Core Users Guide, Sections 4.3.4, and ).

HC11 Instruction Set Architecture

Microcontrollers. 2IN60: Real-time Architectures (for automotive systems) Mike Holenderski,

538 Lecture Notes Week 3

Introduction to Embedded Microcomputer Systems Lecture 6.1

Reading Assignment. 68HC12 Instruction Set. M68HC12 Instruction Set Categories. Some Tips. Endianness (Byte Order) Load and Store Instructions

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-470/570: Microprocessor-Based System Design Fall 2014.

Introduction to the 9S12 Microcontroller

HC11 Instruction Set Architecture

EE319K Fall 2007 Quiz 1A Page 1. (5) Question 2. What will be the value of the carry (C) bit after executing the following? ldab #210 subb #60

Chapter 1. Microprocessor architecture ECE Dr. Mohamed Mahmoud.

ECE 3120 Computer Systems Arithmetic Programming

N bit is set if result of operation in negative (MSB = 1) Z bit is set if result of operation is zero (All bits = 0)

0b) [2] Can you name 2 people form technical support services (stockroom)?

Lecture #3 Microcontroller Instruction Set Embedded System Engineering Philip Koopman Wednesday, 20-Jan-2015

COSC345 Software Engineering. Basic Computer Architecture and The Stack

ECE3120: Computer Systems Hardware & Software Development Tools

EE319 K Lecture 3. Introduction to the 9S12 Lab 1 Discussion Using the TExaS simulator. University of Texas ECE

Administrivia. ECE/CS 5780/6780: Embedded System Design. Assembly Language Syntax. Assembly Language Development Process

Lecture 5 Assembly Programming: Arithmetic

EE319K Fall 2003 Quiz 1 Page 1

ECE 372 Microcontroller Design Assembly Programming Arrays. ECE 372 Microcontroller Design Assembly Programming Arrays

Assembly Language Development Process. ECE/CS 5780/6780: Embedded System Design. Assembly Language Listing. Assembly Language Syntax

EE319K Fall 2006 Quiz 1 Page 1

ECET Chapter 2, Part 2 of 3

What is an Addressing Mode?

ECE/CS 5780/6780: Embedded System Design

Decimal, Hexadecimal and Binary Numbers Writing an assembly language program

EE319K Final Fall 2005 Solution C. (3) Question 1. (3) Question 2. short function(const short in){ return in+5; } const

Addition and Subtraction of Hexadecimal Numbers Simple assembly language programming

Lecture 9 Subroutines

1. Memory Mapped Systems 2. Adding Unsigned Numbers

EE 308 Spring The HCS12 has 6 addressing modes

EE319K Fall 2005 Quiz 1A Page 1

Ryerson University Department of Electrical and Computer Engineering ELE 538 Microprocessor Systems Final Examination December 8, 2003

The 6502 Instruction Set

Lecture 11: Advanced Arithmetic Instructions

538 Lecture Notes Week 5

Introduction to Embedded Systems and Chapter 1: Introduction to HCS12/MC9S12. EE383: Introduction to Embedded Systems University of Kentucky

Addition and Subtraction of Hexadecimal Numbers Simple assembly language programming

It translates (converts) assembly language to machine code.

BRANCH IF REGISTER IS HIGHER/GREATHER/ THAN OPERAND e.g. CMPA #$D0

CS 273 Machine Programming and Organization Lecture Notes

Menu. Programming Models for the Atmel XMEGA Architecture (and others devices) Assembly Programming Addressing Modes for the XMEGA Instruction Set

OSIAC Read OSIAC 5362 posted on the course website

Cross Assembly and Program Development

538 Lecture Notes Week 5

HC11 Instruction Set

CHAPTER 8. Solutions for Exercises

ECE/CE 3720: Embedded System Design

ECE 372 Microcontroller Design Basic Assembly Programming. ECE 372 Microcontroller Design Basic Assembly Programming

ARM Assembly Language. Programming

Motorola HC11. Fun with Microcontrollers and Embedded Systems

EE 3170 Microcontroller Applications

Coe538 Final Study Guide 2016 (Questions & Answers)

EE319K Fall 2010 Exam 1B Page 1

EE319 K Lecture 7. Address mode review Assembler, Debugging Psuedo ops 16 bit timer finite state machines. University of Texas ECE

Module 1-G. Marcos and Structured Programming

A Simple MC9S12 Program

Homework 12 Solutions

Transcription:

Q. 3.9 of HW3 EE 37 Microcontroller Applications (a) (c) (b) (d) Midterm Review: Miller Chapter -3 -The Stuff That Might Be On the Exam D67 (e) (g) (h) CEC23 (i) (f) (j) (k) (l) (m) EE37/CC/Lecture-Review EE37/CC/Lecture#9 2 Q. 3.9 of HW3 Q. 3.2 of HW3 (o) (n) (r) (p) (q) 7 (s) References 22 5 7 9 6 (q) 23 3 START CMPB #-6 BLT NEXT CMPB #4 BGT NEXT CLRB NEXT SWI/STOP END EE37/CC/Lecture#9 3 EE37/CC/Lecture#9 4

Q. 3.22 of HW3 One version might look like this:. TAB LDAA #$FF TSTB BMI NEXT CLRA NEXT. Chapters -3 Coverage & Format Some multiple choice Some short answer Some quantitative questions EE37/CC/Lecture#9 5 EE37/CC/Lecture#9 6 Various and Sundry Close book/notes The relevant pages (instruction table) of HC Reference Manual can be printed and brought to the exam You can bring your calculators Not really needed Chapter / Lectures 2-4 Number representation (lecture 3) Conversion among: decimal, binary, octal, hexadecimal Signed binary numbers, two s complement Binary Coded Decimal (BCD) Ranges of signed and unsigned numbers Number storage Endian-ness: Little endian vs. Big endian (lecture 5) Memory Systems (lecture 4) What is the address vs. the data? What are the other signals? Read/Write, Timing Fetch/Decode/Execute Cycle (lecture 4) Computer vs. Microprocessor vs. microcontroller (lecture 4) Building blocks of a computer: The four major components of a microprocessor EE37/CC/Lecture#9 7 EE37/CC/Lecture#9 8

Number representation: example Convert 95 into 8-bit binary Convert into a decimal number if it is Unsigned binary 2 2 s complement -45 The range of 8 bits signed number (-28, 27) Extend 2 into a 8-bit signed number 2 The value of in 2 s complement, S&M -3, -5 Memory Organization Memory Organization Questions 68HC 8-bits ( byte)/word Byte-addressable 6-bit address 2 6 (64k) bytes maximum (hexadecimal expression) Big-endian byte-ordering Little-endian bit-ordering EE37/CC/Lecture#9 9 EE37/CC/Lecture#9 Memory Interfacing Number storage: Byte Ordering Illustration N = num. of bits in address = log 2 (num. of words) w = word width = num. of bits in one word Example-Store 4-byte BCD number 2345678 starting in memory location $4. Mem. Big Little Loc. Endian Endian Big endian Least significant byte has highest address. Little endian Least significant byte has lowest address. 4 2 78 4 34 56 42 56 34 43 78 2 EE37/CC/Lecture#9 EE37/CC/Lecture#9 2

Memory Organization-Bit Ordering Four basic components of a computer Which end of the word is labeled bit? Little endian--bit is the least significant bit (rightmost bit). Almost all modern processors, including the 68 use little endian. Big endian--bit is the most significant bit (leftmost bit). Mem. Big Little Big Loc Endian Endian Endian (Byte) (Bit) (Bit) 4 2,, 4 34,, 42 56,, 43 78,, ALU + registers IR EE37/CC/Lecture#9 3 EE37/CC/Lecture#9 4 Chapter 2 / Lectures 5 & 6s & 7 & 8 Register The HC programming model Registers, memory, CCR, PC, etc. Register organization issues number of registers Instructions Logical (AND, OR, EOR, NOT) Shift (Logical, Arithmetic, Roll) Arithmetic Branch Comparison register uniformity 7 5 5 5 A 7 B D X Y 8-bit accumulators 6-bit accumulator Index register Index register Addressing Modes 5 5 SP PC Stack pointer Program counter S X H I N Z V C Condition code register EE37/CC/Lecture#9 5 EE37/CC/Lecture#9 6

Condition code questions Example : + + C= V= N= Z= valid for unsigned? valid for singed? C= V= N= Z= valid for unsigned? valid for singed? EE37/CC/Lecture#9 7 Condition code questions Example 2: A=5, B=-5 R=A+B=? C= V= N= Z= Example 3: A=4, B=-5 R=A+B=? C= V= N= Z= Example 3: A=2, B=36 R=A+B=? C= V= N= Z= EE37/CC/Lecture#9 8 Instructions and Addressing Exercise Load and store instructions direct addressing (8-bit address) extended addressing (6-bit address) immediate data 7A 49 2 27... 3C 54 2 7 3 88 Originally A holds 7D and B holds 6E. Find the contents of A, B and memory after the sequence ldaa #6 A=$ ldab $2 B=$7 staa $ ()=$ ldd $ D=$54 EE37/CC/Lecture#9 9 EE37/CC/Lecture#9 2

Logical operations Logic operations: example and, or, eor rega regb Write assembly software that toggles PORTA bits 3,4 and may be used to isolate a bit, usually for testing Example: anda #$4 isolates bit 2 bits are numbered from at the right and may be used to clear a bit Example: anda #$F7 clears bit 3 the other bits are not affected or may be used to set a bit Example: oraa #$4 sets bit 6 the other bits are not affected EE37/CC/Lecture#9 2 ldaa PORTA eora #$C *#% staa PORTA EE37/CC/Lecture#9 22 68 Shift Instructions For register A asla arithmetic shift left asra arithmetic shift right lsla logical shift left lsra logical shift right rola rotate left rora rotate right Registers B and D and memory have similar instructions. Shifting into carry allows us to check carry bit. 7 6 5 4 3 2 C EE37/CC/Lecture#9 23 Arithmetic operations Arithmetic Operations instructions and results including validity of results Example: Add $8 and $ + = Sum is $8. C = N = V = Z = Unsigned interpretation: 28 + = 29 valid Signed interpretation: -28 ++ = -27 valid EE37/CC/Lecture#9 24

Architecture Example Excise: Loaded Object Program and Data Explain the execution of a 3-Byte Instruction (4 Ticks) using the processor model as shown (slides 22-27 of lecture 5): LDAA C2 Fetch Phase Fetch Opcode, Decode Opcode (need 2 more bytes) and Increment PC-- Tick Fetch 2 nd byte and Increment PC-- Tick 2 Fetch 3 rd byte and Increment PC-- Tick 3 Execute Phase Execute the instruction-- Tick 4 A PC IR B ldaa adda staa stop C2B C2C C2D LDAA ADDA STAA STOP N N2 SUM C2 C2 C22 C23 C24 C25 C26 C27 C28 C29 C2A C2B C2C C2D B6 C2 B BB C2 C B7 C2 D 3F FF 2 29 FF EE37/CC/Lecture#9 25 EE37/CC/Lecture#9 26 Addressing Mode Summary 68HC Operand Formats: Inherent = obvious from the opcode (there is no operand) Immediate = precede value with a # (e.g. #35 #$23) Extended = just write the address (e.g. 266 $A) Direct = just write the address (like extended), but: If the address is <256 Then the assembler chooses direct instead of extended Indexed = write offset, Index-Register (e.g. $AF, X;) Relative = just write the symbolic address instructions using relative addressing have no options obvious from the opcode Addressing example X=$2 Y=$28 A=$45 B=$67 For each of the instruction, specify EA, result, memory location and value: staa 4, x (24)=$45 std $66, y (2E6)=$45, (2E7)=$67 EE37/CC/Lecture#9 27 EE37/CC/Lecture#9 28

Review of instructions Load/store ldaa, ldab, ldd, lds, ldx, ldy staa, stab, std, sts, stx, sty Arithmetic adda, addb, addd suba, subb, subd Logical anda, andb, oraa, orab, eora, eorb Shifts of three types asla, asra, lsla, lsra, rola, rora Comparison and test instructions cmpa cmpb, cpd, cpx, cpy tst (memory), tsta, tstb Branch instructions Bit instructions Increment/decrement EE37/CC/Lecture#9 29 Condition Code and Branch C = Carry-out bit Meaning: C=: Previous instruction had a carry-out C=: Previous instruction didn t have a carry-out Usage: C= Overflow for unsigned arithmetic only Ignore C bit for signed arithmetic Relevant Branch opcodes: BCC: Branch if Carry Clear (C=) BCS: Branch if Carry Set (C=) EE37/CC/Lecture#9 3 Condition Code and Branch V = Overflow bit (2 s complement) Meaning: V=: Previous instruction had an overflow V=: Previous instruction didn t have an overflow Usage: V= Overflow for signed arithmetic only Ignore V bit for unsigned arithmetic Relevant Branch opcodes: BVC: Branch if Overflow Clear (V=) BVS: Branch if Overflow Set (V=) EE37/CC/Lecture#9 3 Condition Code and Branch Z = Zero bit Meaning: Z=: Previous instruction result = Z=: Previous instruction result watch these; they are counter-intuitive Usage: Z= the zero condition is true all bits of the result are zeros Relevant Branch opcodes: BNE: Branch if result not equal to zero (Z=) BEQ: Branch if result is equal to zero (Z=) EE37/CC/Lecture#9 32

Condition Code and Branch N = Negative bit Meaning: N=: Previous instruction result < N=: Previous instruction result Usage: N= Left-hand bit = (sign-bit) Evaluates 2 s complement negative Relevant Branch opcodes: BPL: Branch if result sign is plus (N=) actually branches if result is not-negative BMI: Branch if result sign is minus (N=) Chapter 3 / Lectures 9 & Process of Assembly Language Program Development Labels Rules, what are they used for Assembler Directives (Psuedo-ops) What do they do? How are they different? The Assembler How many passes? Location Counter Symbol Table Be able to hand-assemble individual instructions (probably not whole programs). EE37/CC/Lecture#9 33 EE37/CC/Lecture#9 34