ECE 3430 – Intro to Microcomputer Systems

Slides:



Advertisements
Similar presentations
Microprocessors.
Advertisements

Assembly Language Programming
EET 2261 Unit 3 Assembly Language; Load, Store, & Move Instructions  Read Almy, Chapters 5 and 6.  Homework #3 and Lab #3 due next week.  Quiz next.
The 8051 Microcontroller and Embedded Systems
Programming 68HC11.
2.3) Example of program execution 1. instruction  B25 8 Op-code B means to change the value of the program counter if the contents of the indicated register.
EE 362 Microprocessor Systems and Interfacing © 1-1 Lecture 1: Introduction to Microprocessor Based Systems Microprocessor Architecture Microprocessor.
© 2010 Kettering University, All rights reserved..
H. Huang Transparency No.1-1 The 68HC11 Microcontroller Chapter 1: Introduction to 68HC11 The 68HC11 Microcontroller.
EET 2261 Unit 2 HCS12 Architecture
ECE 265 – LECTURE 4 The M68HC11 Address Modes 8/14/ ECE265.
© 2010 Kettering University, All rights reserved..
9/20/6Lecture 21 -PIC Architecture1 PIC Architecture Programmers Model and Instruction Set.
Lecture 18 Last Lecture Today’s Topic Instruction formats
The M68HC11 Basic Instruction Set Basic Arithmetic Instructions
ME4447/6405 The George W. Woodruff School of Mechanical Engineering ME4447/6405 Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics.
1 Programming in Machine Language SCSC 311 Spring 2011.
Chapter 10 The Assembly Process. What Assemblers Do Translates assembly language into machine code. Assigns addresses to all symbolic labels (variables.
ME4447/6405 The George W. Woodruff School of Mechanical Engineering ME4447/6405 Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics.
ECE 265 – LECTURE 5 The M68HC11 Basic Instruction Set 12/8/ ECE265.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
Addressing Modes MTT CPU08 Core Motorola CPU08 ADDRESSING MODES.
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.
1 Microcontroller Fundamentals & Programming Addressing Modes.
ECE 447: Lecture 11 Introduction to Programming in Assembly Language.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
Lec. 10 Assembly Programming Dr. Tamer Samy Gaafar Microprocessors.
EE345 Chapter 2 Lecture 3 April 4. Quiz every Wednesday 1 quiz = 1% extra credit five quizzes before midterm  5% for midterm. five quizzes before final.
EE345 Chapter 2 Lecture 3 April Instruction and addressing modes 1.Extended Addressing 2.Direct Addressing 3.Inherent Addressing 4.Immediate Addressing.
EET 2261 Unit 6 The Stack; Subroutines
ECE 3430 – Intro to Microcomputer Systems
Displacement (Indexed) Stack
EET 2261 Unit 3 Assembly Language; Load, Store, & Move Instructions
ELEC 418 Advanced Digital Systems Dr. Ron Hayne
ECE 3430 – Intro to Microcomputer Systems
ECE 3430 – Intro to Microcomputer Systems
ECE 3430 – Intro to Microcomputer Systems
Addressing Modes in Microprocessors
ECE 3430 – Intro to Microcomputer Systems
ECE 3430 – Intro to Microcomputer Systems
Programming in Machine Language
ECE 3430 – Intro to Microcomputer Systems
ECE 3430 – Intro to Microcomputer Systems
ECE 3430 – Intro to Microcomputer Systems
ECE 3430 – Intro to Microcomputer Systems
ECE 3430 – Intro to Microcomputer Systems
A Closer Look at Instruction Set Architectures
ECE 3430 – Intro to Microcomputer Systems
Microcomputer Programming
A Closer Look at Instruction Set Architectures: Expanding Opcodes
William Stallings Computer Organization and Architecture 8th Edition
Computer Organization and Assembly Language (COAL)
EECE-276 Fall 2003 Microprocessors & Microcontrollers II
ME4447/6405 Microprocessor Control of Manufacturing Systems and
ECE 3430 – Intro to Microcomputer Systems
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
68000 Architecture, Data Types and Addressing Modes
Introduction to Micro Controllers & Embedded System Design
Computer Instructions
Lecture 06 Programming language.
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
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
CS 111 – Sept. 16 Machine language examples Instruction execution
Presentation transcript:

ECE 3430 – Intro to Microcomputer Systems ECE 3430 – Introduction to Microcomputer Systems University of Colorado at Colorado Springs Lecture #4 Agenda Today More on the LOAD Instructions Big Endian vs. Little Endian HC11 Addressing Modes Announcements Homework #1 due today. Hand it to me before you leave. Homework #2 available on the web page. Due in one week. Lecture #4 ECE 3430 – Intro to Microcomputer Systems Fall 2009

ECE 3430 – Intro to Microcomputer Systems The LOAD Instruction LOAD An HC11 instruction that moves information into the internal registers of the CPU (A,B,D,X,Y,SP). Where the “information” comes from depends on the addressing mode. The addressing mode is encoded in the instruction opcode. Recall operands provide additional information needed by an instruction. The HC11 has 6 addressing modes. We will use the LOAD instruction to illustrate the first four: 1) Immediate (operand provides the data) 2) Direct (operand provides memory location of data) 3) Extended (operand provides memory location of data) 4) Indexed (operand provides offset to memory location relative to value stored in the X or Y index register) 5) Inherent (no operands used) 6) Relative (operand provides address relative to current value stored in PC register) Lecture #4 ECE 3430 – Intro to Microcomputer Systems Fall 2009

Big Endian vs. Little Endian Suppose I wanted to do two 16-bit loads from memory locations $0000 and $0002… Big Endian (HC11 and Motorola/Freescale Architectures): After a 16-bit load from $0000, I would see in CPU registers: $1234 After a 16-bit load from $0002, I would see in CPU registers: $5678 Little Endian (Intel Architectures): After a 16-bit load from $0000, I would see in CPU registers: $3412 After a 16-bit load from $0002, I would see in CPU registers: $7856 Endian-ness applies to all memory accesses greater than 8-bits (i.e. 16-bit, 32-bit, 64-bit, 128-bit) Generally speaking, higher-level programmers are insulated from these architectural differences. M($0000)=$12 M($0001)=$34 M($0002)=$56 M($0003)=$78 Lecture #4 ECE 3430 – Intro to Microcomputer Systems Fall 2009

ECE 3430 – Intro to Microcomputer Systems Addressing Modes Immediate Addressing – The operand of the instruction is the “actual data” (IMM) to be loaded into a register. The “#” sign indicates to the cross-assembler that “immediate addressing” is intended. Ex) LDAA #%10101010 ; this instruction will put %10101010 into accumulator A LDD #%1010101001010101 ; this instruction will put %1010101001010101 into accumulator D ; overwriting what was stored in A and B Mnemonic Machine code (LDAA): $86 $AA Machine code (LDD): $CC $AA $55 Opcodes Operands Memory $0000 $86 $0001 $AA $0002 $CC $0003 $AA $0004 $55 Unique code to HC11, the control unit in the CPU decodes opcodes and knows what to do (i.e. put $AA into ACCA or put $AA55 into ACCD) How it looks in memory Lecture #4 ECE 3430 – Intro to Microcomputer Systems Fall 2009

Addressing Modes Direct Addressing – The operand of the instruction is the “address” of where (DIR) the data is located in memory. Direct uses only 1 byte in memory to indicate the address. This means that the data must reside between $00 - $FF (the upper byte of the address is assumed to be $00). Ex) LDAA $00 ; this instruction will put the contents of memory location $0000 into ACCA: ; ACCA = M($0000) LDX $00 ; this instruction will put the contents of memory locations $0000 and $0001 into ; the upper and lower parts of index register X: ; X(high) = M($0000), X(low) = M($0001) Mnemonics Machine code (LDAA): $96 $00 Machine code (LDX): $DE $00 Memory $0000 $12 $0001 $34 $e000 $96 $e001 $00 $e002 $DE $e003 $00 ACCA = $12 after this instruction is executed, Opcodes Operands X = $1234 after this instruction is executed The control unit knows that $96 and $DE mean direct addressing on ACCA and index register X respectively Lecture #4 ECE 3430 – Intro to Microcomputer Systems Fall 2009

Addressing Modes Extended Addressing – This is the same as direct except that 2 bytes are used (EXT) for the “address” of where the data is to be loaded from. With two bytes of memory, the data can be located from locations $0000 to $FFFF in memory. Ex) LDAA $FFFF ; this instruction will put the contents of memory location ; $FFFF into ACCA: ACCA = M($FFFF) LDY $FFFE ; this instruction will put the contents of ; memory location $FFFE and $FFFF into index ; register Y: ; Y(high) = M($FFFE), Y(low) = M($FFFF) Mnemonic Machine code (LDAA): $B6 $FF $FF Machine code (LDY): $18 $FE $FF $FE Memory $0000 $B6 $0001 $FF $0002 $FF $0003 $18 $0004 $FE $0005 $FF $0006 $FE $FFFE $12 $FFFF $34 ACCA = $34 and INDY = $1234 after these instructions are executed Opcodes Operands The control unit knows to use extended addressing mode. Lecture #4 ECE 3430 – Intro to Microcomputer Systems Fall 2009

Addressing Modes Indexed Addressing – The contents of index registers X and Y are added to the (INDX, INDY) operand of the instruction to form the effective address. The operand acts as an “offset” from where X and Y are pointing in memory. The X or Y registers need to be initialized. Ex) LDX #$0100 ; initializes the X register to $0100 using immediate addressing LDD 2,X ; loads accumulator D with the contents of memory location $0102 and ; $0103: ; ACCA = M($0102), ACCB = M($0103) Mnemonics Machine code (LDD): $EC $02 Memory $0000 $EC $0001 $02 $0101 - $0102 $56 $0103 $78 Opcode Operand ACCD = $5678 after this instruction is executed The control unit knows that $EC means to load ACCD using index register X Lecture #4 ECE 3430 – Intro to Microcomputer Systems Fall 2009

ECE 3430 – Intro to Microcomputer Systems Addressing Modes Inherent Addressing – The opcode contains all of the information needed by the (INH) instruction. Loading does not use this addressing mode. Instructions that use this addressing mode are usually doing atomic operations on CPU accumulators/registers. Ex) ABA ; adds contents of ACCA to contents of ACCB and puts the result ; in ACCA (A = A+B) CLI ; clears the I bit in the condition code register LSLB ; shifts the bits in ACCB one position to the left (shifts in a 0) NEGA ; take two’s complement of ACCA COMB ; take one’s complement of ACCB The machine code for each instruction will contain one or more opcodes—but no operands! Machine code (ABA): $1B Machine code (CLI): $0E etc. Lecture #4 ECE 3430 – Intro to Microcomputer Systems Fall 2009

Addressing Modes Relative Addressing – The operand gives an offset that is added to the memory (REL) location of the next instruction’s opcode. In the HC11, this addressing mode is used only with branch instructions. A branch is where the program counter is set to something besides PC+1 (covered later). The offset is an 8-bit signed number. This means the “effective address” can be from –128 to +127 memory locations from the current address. Ex) BRA $01 ; This will “branch” positive 1 memory location Machine code: $20 $01 Memory PC $0000 $20 $0001 $01 $0002 - $0003 - Opcode Operand PC = $0003 after the instruction is executed. The PC is set to $0002 after the opcode and operand are loaded out of memory. The offset ($01 = +1) is relative to $0002. Lecture #4 ECE 3430 – Intro to Microcomputer Systems Fall 2009

Addressing Modes Relative Addressing – Suppose the microcontroller was finished executing (REL) code and the program counter needed to be trapped (so that the HC11 will not continue plowing through uninitialized memory. One could call the STOP instruction or branch back to the last instruction: Ex) BRA $FE ; This will “branch” negative 2 memory locations Machine code: $20 $FE Opcode Operand Memory The PC is set to $E012 after the opcode and operand are loaded out of memory. The offset ($FE = -2) is relative to $E012. The code execution is effectively stopped now—but the uC is still using power. PC $E010 $20 $E011 $FE $E012 - $E013 - PC = $E010 after the instruction is executed. Lecture #4 ECE 3430 – Intro to Microcomputer Systems Fall 2009

ECE 3430 – Intro to Microcomputer Systems Addressing Modes Relative Addressing – These offsets are really confusing! Fortunately (REL) assemblers make use of labels and these labels allow the assembler to automatically calculate the correct offsets for you! This will be discussed later. Ex) DONE: BRA DONE DONE is a label which labels the BRA instruction. The label can be called just about anything. The above is valid assembly syntax and will be converted the correct machine code by the assembler. Lecture #4 ECE 3430 – Intro to Microcomputer Systems Fall 2009

The LOAD Instructions (Review) LOAD Instructions – The HC11 has LOAD instructions to put information within its internal registers and accumulators. There are instructions for all of the internal registers. Each accumulator can be loaded using the addressing modes described earlier. See the HC11 Programmer’s Reference Guide (the pink book) for specifics. LDAA ; load accumulator A (8-bit) LDAB ; load accumulator B (8-bit) LDD ; load accumulator D (16-bit, LDD #$1234, ACCA=$12, ACCB=$34) LDS ; load stack pointer (16-bit) LDX ; load index register X (16-bit) LDY ; load index register Y (16-bit) NOTE: The condition code register (CCR) and program counter (PC) are not loaded with load instructions. The PC is initialized via reset interrupt vectors (discussed later) and the CCR can be altered by transferring contents to and from ACCA using special TPA/TAP instructions—but generally other instructions indirectly change the CCR. Lecture #4 ECE 3430 – Intro to Microcomputer Systems Fall 2009

To Find Out More About HC11 Instructions See the pink book. A large table runs length-wise and consumes many pages. Here you will find the entire HC11 instruction set (alphabetized) along with the opcodes for each instruction (for all supported addressing modes). You will need to reference this when doing homework #2. Lecture #4 ECE 3430 – Intro to Microcomputer Systems Fall 2009