EE 3170 Microcontroller Applications

Similar documents
EE 3170 Microcontroller Applications

EE 3170 Microcontroller Applications

EE 3170 Microcontroller Applications

EE 3170 Microcontroller Applications

Microcomputer Architecture and Programming

EE 3170 Microcontroller Applications

Instruction Set II. COMP 212 Computer Organization & Architecture. COMP 212 Fall Lecture 7. Instruction Set. Quiz. What is an Instruction Set?

William Stallings Computer Organization and Architecture 8 th Edition. Chapter 11 Instruction Sets: Addressing Modes and Formats

Assembly Language Programming of 8085

Chapter 2A Instructions: Language of the Computer

CPU Structure and Function

Mark II Aiken Relay Calculator

3.1 Description of Microprocessor. 3.2 History of Microprocessor

COMP3221: Microprocessors and. and Embedded Systems. Instruction Set Architecture (ISA) What makes an ISA? #1: Memory Models. What makes an ISA?

Chapter 1: Basics of Microprocessor [08 M]

Introduction to Programming

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

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

COMP2121: Microprocessors and Interfacing. Instruction Set Architecture (ISA)

Computer Systems. Binary Representation. Binary Representation. Logical Computation: Boolean Algebra

Instruction : A command to the microprocessor to perform a given task on specified data. Each instruction has two parts

CHAPTER 5 A Closer Look at Instruction Set Architectures

Introduction to the MIPS. Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University

Instruction Set Architecture

Chapter 4. MARIE: An Introduction to a Simple Computer


CHAPTER 5 A Closer Look at Instruction Set Architectures

CPU Structure and Function. Chapter 12, William Stallings Computer Organization and Architecture 7 th Edition

Topics/Assignments. Class 10: Big Picture. What s Coming Next? Perspectives. So Far Mostly Programmer Perspective. Where are We? Where are We Going?

Grading: 3 pts each part. If answer is correct but uses more instructions, 1 pt off. Wrong answer 3pts off.

Chapter 1. Microprocessor architecture ECE Dr. Mohamed Mahmoud.

COMPUTER ORGANIZATION & ARCHITECTURE

1 MALP ( ) Unit-1. (1) Draw and explain the internal architecture of 8085.

Processing Unit CS206T

Lecture 4: MIPS Instruction Set

Computer Organization CS 206 T Lec# 2: Instruction Sets

Processor design - MIPS

Lecture 4: Instruction Set Architecture

Instruction Set Principles and Examples. Appendix B

Microcontroller Systems

ECE232: Hardware Organization and Design

MARIE: An Introduction to a Simple Computer

Write A General Form Of The Assembly

Page 1. Structure of von Nuemann machine. Instruction Set - the type of Instructions

CSEE 3827: Fundamentals of Computer Systems

CHAPTER 5 A Closer Look at Instruction Set Architectures

EC 413 Computer Organization

MICROPROCESSOR MICROPROCESSOR. From the above description, we can draw the following block diagram to represent a microprocessor based system: Output

1. INTRODUCTION TO MICROPROCESSOR AND MICROCOMPUTER ARCHITECTURE:

Chapter 2 Instruction Set Architecture

Introduction to Computers - Chapter 4

Chapter 11. Instruction Sets: Addressing Modes and Formats. Yonsei University

William Stallings Computer Organization and Architecture. Chapter 11 CPU Structure and Function

CHAPTER 5 : Introduction to Intel 8085 Microprocessor Hardware BENG 2223 MICROPROCESSOR TECHNOLOGY

Chapter 5:: Target Machine Architecture (cont.)

Chapter 5. A Closer Look at Instruction Set Architectures

Delhi Noida Bhopal Hyderabad Jaipur Lucknow Indore Pune Bhubaneswar Kolkata Patna Web: Ph:

Real instruction set architectures. Part 2: a representative sample

Computer Architecture and Organization. Instruction Sets: Addressing Modes and Formats

QUESTION BANK. EE 6502 / Microprocessor and Microcontroller. Unit I Processor. PART-A (2-Marks)

Understand the factors involved in instruction set

INTRODUCTION OF MICROPROCESSOR& INTERFACING DEVICES Introduction to Microprocessor Evolutions of Microprocessor

MARIE: An Introduction to a Simple Computer

Overview. EE 4504 Computer Organization. Much of the computer s architecture / organization is hidden from a HLL programmer

Review Questions. 1 The DRAM problem [5 points] Suggest a solution. 2 Big versus Little Endian Addressing [5 points]

CENG3420 Lecture 03 Review

Basic Processing Unit: Some Fundamental Concepts, Execution of a. Complete Instruction, Multiple Bus Organization, Hard-wired Control,

Microprocessors/Microcontrollers

MICROPROCESSOR B.Tech. th ECE

COSC 243. Computer Architecture 1. COSC 243 (Computer Architecture) Lecture 6 - Computer Architecture 1 1

CPU Structure and Function

CMSC Computer Architecture Lecture 2: ISA. Prof. Yanjing Li Department of Computer Science University of Chicago

Instruction Sets: Characteristics and Functions

MICROPROCESSOR AND MICROCONTROLLER BASED SYSTEMS

1. Internal Architecture of 8085 Microprocessor

CPE300: Digital System Architecture and Design

ECE 154A Introduction to. Fall 2012

A First Look at Microprocessors

Addressing Modes. Immediate Direct Indirect Register Register Indirect Displacement (Indexed) Stack

8086 INTERNAL ARCHITECTURE

Math 230 Assembly Programming (AKA Computer Organization) Spring 2008

Chapter 4. Chapter 4 Objectives. MARIE: An Introduction to a Simple Computer

ASSEMBLY LANGUAGE MACHINE ORGANIZATION

Advanced Parallel Architecture Lesson 3. Annalisa Massini /2015

17. Instruction Sets: Characteristics and Functions

Typical Processor Execution Cycle

Assembly Language Programming of 8085

Lecture #2 January 30, 2004 The 6502 Architecture

CC312: Computer Organization

Practical Malware Analysis

EECS Computer Organization Fall Based on slides by the author and prof. Mary Jane Irwin of PSU.

Microprocessors. Microprocessors and rpeanut. Memory. Eric McCreath

2. ADDRESSING METHODS

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

Microprocessors and rpeanut. Eric McCreath

Hardware Design I Chap. 10 Design of microprocessor

Microcontrollers. Microcontroller

Advanced Parallel Architecture Lesson 3. Annalisa Massini /2015

Chapter 4. MARIE: An Introduction to a Simple Computer 4.8 MARIE 4.8 MARIE A Discussion on Decoding

Chapter 4. Chapter 4 Objectives

Transcription:

EE 317 Microcontroller Applications Lecture 5 : Instruction Subset & Machine Language: Introduction to the Motorola 68HC11 - Miller 2.1 & 2.2 Based on slides for ECE317 by Profs. Davis, Kieckhafer, Tan, and Cischke EE317/CC/Lecture#5 1 Lecture Overview Perspective on Programming Register Organization Issues 68HC11 Register Organization Memory Organization Issues 68HC11 Memory Model 68HC11 Instruction formats Instructions in memory 68HC11 fetch/execute cycle Detailed fetch/execute example 3-byte instruction cycle loading number from memory into accumulator EE317/CC/Lecture#5 2 Perspective on Programming Processor Programming Model High-Level languages (e.g. C, C++, Java) hide processor details from programmer provide a common abstract programming model allow code to be ported between processors To exploit a processor, you must first understand: The processor register organization The memory organization The instruction formats Most microcontroller applications require detailed operation of hardware components require intimate understanding of the hardware require detailed control of program and I/O timing can not be done entirely in an abstract high-level language Some assembly language drivers The basic microprocessor operation cycle Hardware & software are not separate topics for microcomputer Programming can not be done well w/o good understanding of registers in microprocessors & the memory EE317/CC/Lecture#5 3 EE317/CC/Lecture#5 4 1

How Do We Manipulate Data in Computers? We usually manipulate data in registers in the processing unit. Manipulate means adding numbers complementing a number shifting a number Registers are groups of flip-flops. In Clock D 1 2 3 4 D D D Some computers can manipulate data in memory. EE317/CC/Lecture#5 5 Register Organization Options Number of Registers: More registers Greater Capacity More On-Chip Real-Estate Larger Operand Fields in Instruction Fewer registers More spilling of program data to memory space Smaller Operand fields in instruction Observation: few routines employ more than 32 regs. Result: 32 regs became quasi-standard (by 199s) EE317/CC/Lecture#5 6 Register Organization Options Register Uniformity: degree to which registers can be used interchangeably One Extreme: All General Purpose Registers (GPR's) Registers can be used interchangeably Greater flexibility for programmer Longer Instructions (explicitly specify each register) 68HC11 Register Organization Small number of special purpose registers Saves on-chip real estate Shortens the instructions (saves memory) 7 A 7 B D X 8-bit accumulators 16-bit accumulator Index register Other Extreme: All Special Purpose Registers e.g.: accumulator, stack pointer, index register Reduces flexibility for programmer: Shorter Instruction (regs are implicit in the opcode) S Y SP PC X H I N Z V C Index register Stack pointer Program counter Condition code register Figure 2-1 Motorola 68HC11 Programming Model EE317/CC/Lecture#5 7 EE317/CC/Lecture#5 8 2

68HC11 Register Organization How Do We Store Stuff in a Computer? Accumulators -- data registers A and B 8 bits each D (A and B together) 16 bits Index Registers registers that hold all or part of an address X and Y 16 bits Stack Pointer register that holds an address for a stack (last-infirst-out memory organization) SP 16 bits Program Counter register that holds the address of the next instruction PC 16 bits Condition Code Register register that holds one-bit flags CC 8 bits 2-D arrays are easy to build in VLSI. Hence they are used for cheap, fast storage. the larger, the slower. later we will see a hierarchy of memory. Memory is a collection of register arranged sequentially and referred to by a four-digit hexadecimal address Now we will think of memory as a 1-D array. though actually 2-D grid. EE317/CC/Lecture#5 9 EE317/CC/Lecture#5 1 Byte-Addressable Memory Modern computers can address each byte of the memory. We think of memory as a sequence of bytes. Each memory location has an address like a post office box address starting from or hex and contents the stuff we store. Big and Little Endian How can we store a multiple-byte number in memory? Most significant byte first- big endian Motorola 68HC11, Sun, Macintosh, PowerPC, MIPS Least significant byte first- little endian PCs, Alpha, x86: Intel, AMD MIPs machines use both. Byte ordering can be a problem especially when connecting different processors EE317/CC/Lecture#5 11 EE317/CC/Lecture#5 12 3

Byte Ordering Illustration Memory Organization-Bit Ordering Example-Store 4-byte BCD number 12345678 starting in memory location $4. Big endian Least significant byte has highest address. Little endian Least significant byte has lowest address. Mem. Big Loc. Endian Little Endian 4 12 78 41 34 56 42 56 34 43 78 12 Which end of the word is labeled bit? Little endian--bit is the least significant bit (rightmost bit). Almost all modern processors, including the 6811 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 12 1,1 1,1 41 34 11,1 1,11 42 56 11,11 11,11 43 78 111,1 1,111 EE317/CC/Lecture#5 13 EE317/CC/Lecture#5 14 Memory Org. - Granularity 6811 Memory Model Granularity = the size of one memory word Almost all modern processors are "byte addressable one memory word = one byte simplifies access to character data 68HC11 is byte-addressable Proc. data word can be larger than one mem. word Most processors are byte addressable most procs can compute with 16, 32, or 64-bit data 68HC11 is an 8-bit processor with LIMITED 16 bit operations Accumulator D is implemented using A & B 8-bits (1 byte)/word= Byte-addressable 16-bit address 2 16 (64k) bytes maximum Big-endian byte-ordering Little-endian bit-ordering C239 C23A C23B FFFF B6 C1 33 Figure 2-2. Memory Model EE317/CC/Lecture#5 EE317/CC/Lecture#5 16 4

Instruction Formats Fixed Length Instruction Formats All instructions are the same length (32 bits) Microprocessor data bus must be same length Fast & easy fetch Variable Length Instruction Formats Instruction length is variable (1-9 bytes) Compact assembly language Multiple cycle fetch 68HC11 Instruction Format Variable length instructions (1-5 bytes) 8-bit data bus 1 byte fetched per cycle Instruction Format Machine Language (ML) = bit-patterns that the proc. interprets as instructions Each instruction contains Opcode Operand specifiers (e.g. value, address, reg. number) Example: Load byte @ address C2 into accumulator A B6C2 recall: 1 hex digit = 4 bits = 1/2 Byte This instruction = 6 hex digits = 3 bytes EE317/CC/Lecture#5 17 EE317/CC/Lecture#5 18 Instruction Format Instructions Stored in Memory Assembly Language (AL) = A more easily readable representation of ML Uses a Mnemonic name for the OPCODE Example: Load byte @ address C2 into Accum. A B6C2 = LDAA C2 Storage of: B6C2 68HC11 instructions range from one to five bytes This one happens to be three bytes Assembler = a program to translate AL to ML e.g. assembler translates LDAA into B6 a one-to-one mapping from AL to ML instructions Assembler = simpler version of a compiler EE317/CC/Lecture#5 19 EE317/CC/Lecture#5 2 5

Microprocessor Model 68HC11 Fetch/Execute Cycle - Details Lists those registers (in the microprocessor) involved in the instruction To begin with we will need: Accumulators: general purpose 8-bit data registers Program Counter: 16-bit register containing address of next data to be read from memory. Instruction Register: 24-bit register to hold instruction and operand address read from memory. This one is transparent: its operation is invisible to the programmer. Example: 3-Byte Instruction Fetch Phase Fetch Opcode, Decode Opcode (need 2 more bytes) & Increment PC Fetch 2nd byte & Increment PC Fetch 3rd byte & Increment PC Execute Phase Execute the instruction EE317/CC/Lecture#5 21 EE317/CC/Lecture#5 22 Beginning of Instruction: Contents of A, B, and IR are leftovers PC contains address of 1st byte of instruction Tick 1 of Fetch Phase: Send address of 1st byte and read signal to mem Put byte returned by mem into left-hand byte of IR Increment the PC Decode Opcode B6 -> need 2 more bytes Determine if fetching should continue by examining the left byte of IR Figure 2-7: First byte of instruction has been fetched EE317/CC/Lecture#5 23 EE317/CC/Lecture#5 24 6

Tick 2 of Fetch Phase: Send address of 2nd byte and read signal to mem Put byte returned by mem into middle byte of IR Increment the PC Tick 3 of Fetch Phase: Send address of 3rd byte and read signal to mem Put byte returned by mem into right-hand byte of IR Increment the PC 1 2 Figure 2-9: The second byte of the instruction has been fetched EE317/CC/Lecture#5 25 Figure 2-11: The third byte of the instruction has been fetched EE317/CC/Lecture#5 26 68HC11 Instruction Execution Tick 4 - Execute Phase Send right-2 bytes of IR and read signal to mem Put byte returned by mem into accumulator A Follows 2-step instruction sequencing Each step can take multiple ticks (clock cycles) Up to 41 ticks for a single instruction Up to 5 bytes for a single instruction Numbers for bytes & ticks in Appendix A of Miller Reading Assignment: 2.2, pp. 66-77, 2.3, Miller Topic: instructions and addressing modes EE317/CC/Lecture#5 27 EE317/CC/Lecture#5 28 7