HC11 Instruction Set

Similar documents
Accumulator and memory instructions 1. Loads, stores, and transfers 2. Arithmetic operations 3. Multiply and divide 4. Logical operations 5. Data test

HC 11 Instructions! From Alex Hollowayʼs notes with! many thanks!

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

Programming the Motorola MC68HC11 Microcontroller

HC11 Instruction Set Architecture

HC11 Instruction Set Architecture

The Motorola 68HC11 Instruc5on Set

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

Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers

Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers

EE4390 Microprocessors

SECTION 6 CENTRAL PROCESSING UNIT

Motorola HC11. Fun with Microcontrollers and Embedded Systems

Microcontrollers and the Freescale/Motorola HC11

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

MC9S12 Address Space

68HC11 PROGRAMMER'S MODEL

instruction 1 Fri Oct 13 13:05:

Exam I Review February 2017

Chapter 7 Central Processor Unit (S08CPUV2)

Microcontrollers and Embedded Systems. Fun with Motorola/Freescale HC11

Using the stack and the stack pointer

ECE 3120 Computer Systems Arithmetic Programming

COSC345 Software Engineering. Basic Computer Architecture and The Stack

Addressing Mode Description Addressing Mode Source Format Abbrev. Description

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

Introduction to Microcontrollers

Microcontrollers. Microcontroller

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

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

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

ME 4447/6405. Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics. Instructor: Professor Charles Ume LECTURE 6

S12CPUV2. Reference Manual HCS12. Microcontrollers. S12CPUV2/D Rev. 0 7/2003 MOTOROLA.COM/SEMICONDUCTORS

Mark II Aiken Relay Calculator

538 Lecture Notes Week 5

538 Lecture Notes Week 5

ECE331 Handout 3- ASM Instructions, Address Modes and Directives

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

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

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

Sample Problem Set #1

EEL 4744C: Microprocessor Applications. Lecture 7. Part 2. M68HC12 Interrupt. Dr. Tao Li 1

EE 3170 Microcontroller Applications

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

Introduction to Microcontroller. Systems. Embedded system. Assembler or C? Datatypes 2. Datatypes 1

Coe538 Final Study Guide 2016 (Questions & Answers)

Chapter 2 HCS12 Assembly Language

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

Outline. 2.8 Stack. 2.9 Subroutines

CPU08RM/AD REV 3 8M68HC08M. CPU08 Central Processor Unit. Reference Manual

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

Lecture 11: Advanced Arithmetic Instructions

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.

538 Lecture Notes Week 3

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

8051 Overview and Instruction Set

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

Introduction to Mechatronics. Fall Instructor: Professor Charles Ume. Interrupts and Resets

Cross Assembly and Program Development

real-time kernel documentation

Introduction to the 9S12 Microcontroller

ECE 4510/5530 Microcontroller Applications Chapter 1

Introduction to Programming the 9S12 in C Huang Sections 5.2 and 5.3. You will be able to use all of the Motorola data manuals on the exam.

Introduction to Embedded Systems. Some Nagging

AN Kbyte Addressing with the M68HC11. Overview

CS/ECE 5780/6780: Embedded System Design

CHAPTER 8. Solutions for Exercises

CMPEN 472 Sample EXAM II

Design of Embedded Systems Using 68HC12/11 Microcontrollers

Wed. Aug 23 Announcements


1. Introduction to Assembly Language

MOXSYN. General Description. Features. Symbol

History of the Microprocessor. ECE/CS 5780/6780: Embedded System Design. Microcontrollers. First Microprocessors. MC9S12C32 Block Diagram

LEGO RCX Hitachi H8/3292

Microcontroller. Instruction set of 8051

Computers and Microprocessors

Fredrick M. Cady. Assembly and С Programming forthefreescalehcs12 Microcontroller. шт.

MIGRATING TO THE 68HC12 IN C

AN1064. Motorola Semiconductor Application Note. Use of Stack Simplifies M68HC11 Programming By Gordon Doughman. Introduction

Lecture 6 Assembly Programming: Branch & Iteration

EE 3170 Microcontroller Applications

Lecture 9 Subroutines

Cmpt 150 The Freescale CPU12 March, The Freescale HC12

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

Exam 1 Feb. 23, 25, 27?

Introduction to the MC9S12 Hardware Subsystems

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

ECE 372 Microcontroller Design Parallel IO Ports - Interrupts. ECE 372 Microcontroller Design Parallel IO Ports - Interrupts

MOS 6502 Architecture

Mechatronics and Microcomputers. Stipendium Hungaricum 2018/2019 Autumn Semester Szilárd Aradi, PhD

3.1 DATA MOVEMENT INSTRUCTIONS 45

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

Addition and Subtraction of Hexadecimal Numbers Simple assembly language programming

EXPERIMENT NO.1. A Microcontroller is a complete computer system built on a single chip.

CHAPTER ASSEMBLY LANGUAGE PROGRAMMING

EEM336 Microprocessors I. Arithmetic and Logic Instructions

UNIVERSITY OF MANITOBA DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING. Term Test #2 Solution ECE 3610 MICROPROCESSING SYSTEMS

Addition and Subtraction of Hexadecimal Numbers Simple assembly language programming

Transcription:

HC11 Instruction Set Instruction classes 1. Accumulator and Memory 2. Stack and Index Register 3. Condition Code Register 4. Program control instructions CMPE12 Summer 2009 19-2 1

Accumulator and memory instructions Loads, stores, and transfers (LST) Arithmetic operations Multiply l and divideid Logical operations Data testing and bit manipulation Shifts and rotates CMPE12 Summer 2009 19-3 LST Almost all MCU activities involve transferring data from memories or peripherals into the CPU or transferring results from the CPU into memory or I/O devices. CMPE12 Summer 2009 19-4 2

LST Example AAA:.asciz "I love assembly language! #AAA xgdx addd #5 xgdx ldaa 0, X OUTCHAR dex dex ldab 0, X tba staa 2, X ldaa #0 staa 3, X #AAA What does this program do? CMPE12 Summer 2009 19-5 Endian-ness Storing a 16-bit word in memory at address [ADDR, ADDR+1] Two choices: Little-endian: at address ADDR store the LSB (the little end ) Big-endian: at address ADDR store the MSB (the big end ) Example: storing 0xAABB Little-endian Big-endian ADDR+ 1 ADDR 0xAA 0xBB memory ADDR+ 1 ADDR 0xBB 0xAA memory CMPE12 Summer 2009 19-6 3

Arithmetic Operations This group of instructions supports arithmetic operations on a variety of operands; 8- and 16-bit operations are supported directly and can easily be extended to support multiple-word operands. Twoscomplement (signed) and binary (unsigned) operations are supported directly. CMPE12 Summer 2009 19-7 Multi-Precision Addition J3 J2 J1 J0 K3 K2 K1 K0 S3 S2 S1 S0 + = ldaa ldab aba staa ldaa adca staa ldaa adca staa ldaa adca staa J0 K0 S0 J1 K1 S1 J2 K2 S2 J3 K3 S3.sect.data J0:.byte 210 // 1234567890 = J1:.byte 2 // 73 150 2 210 J2:.byte 150 // 01001001 10010110 00000010 11010010 J3:.byte 73 // K0:.byte 177 // 887654321 = K1:.byte 135 // 52 232 135 177 K2:.byte 232 // 00110100 11101000 10000111 10110001 K3:.byte 52 // S0:.byte 0xFF // 1234567890 + 887654321 = 2122222211 = S1:.byte 0xFF // 126 126 138 131 S2:.byte 0xFF // 01111110 01111110 10001010 10000011 S3:.byte 0xFF // print: ldab ldab ldab ldab clra rts S0 print S1 print S2 print S3 print CMPE12 Summer 2009 19-8 4

Comparison Instructions // example 1 AAA:.byte 0x11 BBB:.byte 0x22 ldaa AAA ldab BBB cba // or ldaa AAA cmpa BBB // example 2: what does this code do? AAA:.ascii "I love assembly!" BBB:.byte 0x00 #AAA loop: ldaa 0, X OUTCHAR inx cpx #BBB bne loop CMPE12 Summer 2009 19-9 More Arithmetic Operations Compare instructions perform a subtract within the CPU to update the condition code bits without altering either operand. Although test instructions are provided, they are seldom needed since almost all other operations automatically update the condition code bits. CMPE12 Summer 2009 19-10 5

Test Instructions Set the CCR based on one single value, without changing the value tested Example: AAA:.ascii "I love assembly!" BBB:.byte 0x00 END:.asciz "Done" #AAA loop: ldaa 0, X OUTCHAR inx tst 0, X bne loop #END What does this program do? CMPE12 Summer 2009 19-11 Multiply and Divide 8 bits 8 bits = 16-bit result Integer divide (IDIV): 16 bits 16 bits = 16-bit result and 16-bit remainder Fractional divide (FDIV): 16 bits 16 bits =16- bit result (a binary-weighted fraction between 0.000015 and 0.99998) and 16-bit remainder CMPE12 Summer 2009 19-12 6

Multiplication J0 K0 x = P1 P0 AAA:.byte 0x03 // 3 BBB:.byte 0x6F // 111 ldaa ldab mul AAA BBB CMPE12 Summer 2009 19-13 Integer Division NNN:.word 100 DDD:.word 7 num:.asciz "Numerator: " den:.asciz "Denominator: " quo:.asciz "Quotient: " rem:.asciz "Reminder: " Output: ldd ldd ldd IDIV xgdy xgdx xgdy #num NNN #den DDD NNN DDD // X = D / X, D = D % X // Y = reminder // D = quotient #quo // D = reminder #rem CMPE12 Summer 2009 19-14 7

Fractional Division NNN:.word 2 DDD:.word 40 num:.asciz "Numerator: " den:.asciz "Denominator: " quo:.asciz "Quotient: " rem:.asciz "Reminder: " ldd ldd ldd FDIV xgdy xgdx xgdy #num NNN #den DDD NNN DDD // X = D / X, D = D % X // Y = reminder // D = quotient #quo // D = reminder #rem CMPE12 Summer 2009 19-15 Logical Operations This group of instructions is used to perform the Boolean logical operations AND, inclusive OR, exclusive OR, and one s complement. CMPE12 Summer 2009 19-16 8

Data Testing and Bit Manipulation This group of instructions is used to operate on operands as small as a single bit, but these instructions can also operate on any combination of bits within any 8-bit location in the 64-Kbyte memory space. CMPE12 Summer 2009 19-17 Setting Bits in Memory AAA:.word 0x0002 bef:.asciz "Before: " aft:.asciz "After: " ldd #bef AAA #AAA bset 1, X, #0x09 ldd #aft AAA CMPE12 Summer 2009 19-18 9

Setting Bits In Memory: Endianness AAA:.word 0x0002 bef:.asciz "Before: " aft:.asciz "After: " ldd #bef AAA #AAA bset 0, X, #0x09 2306 = 00001001 00000010 ldd #aft AAA CMPE12 Summer 2009 19-19 Shift and Rotate All the shift and rotate functions in the M68HC11 CPU involve the carry bit in the CCR in addition to the 8- or 16-bit operand in the instruction, which permits easy extension to multipleword operands. CMPE12 Summer 2009 19-20 10

Shift and Rotate AAA:.byte 0x0F BBB:.byte 0x8F bef:.asciz "Before: " aft:.asciz "After: " #bef clra ldab AAA ldaa AAA ASRA #aft tab clra ldaa BBB ASRA // print A CMPE12 Summer 2009 19-21 Stack and index register instructions Remember that HC11 is big endian Stack instructions do not affect the condition codes CMPE12 Summer 2009 19-22 11

Stack and Index Register Instructions This table summarizes the instructions available for the 16-bit index registers (X and Y) and the 16-bit stack pointer. CMPE12 Summer 2009 19-23 XGDX and EGDY Bidirectional exchanges: the original content of D is not changed while using the double accumulator to process X or Y D X D Y CMPE12 Summer 2009 19-24 12

TSX, TSY, TXS, TYS The stack pointer SP always points to the next free location on the stack. Automatically incremented on TSX and TSY Automatically ti decremented d on TXS and TSY. Example: TSX INX INX 0x6FF5 0x6FF6 0x6FF7 SP 0x6FF8 0x6FF9 X = 0x6FFA 0x6FFB TXS 0x6FFC 0x6FFD SP = 0x6FFE 0x6FFF 0x7000 CMPE12 Summer 2009 19-25 Condition Code Register Instructions These instructions allow a programmer to manipulate bits of the condition code register (CCR) CMPE12 Summer 2009 19-26 13

Program Control Instructions Branches Jumps Subroutine calls and returns Interrupt handling Miscellaneous CMPE12 Summer 2009 19-27 Branches These instructions allow the CPU to make decisions based on the contents of the condition code bits. All decision blocks in a flow chart would correspond to one of the conditional branch instructions summarized here. CMPE12 Summer 2009 19-28 14

Far branches If the branch destination is farther than 128 or +127 bytes, then must use a branch + jump combo Example: BHI TINBUK2 // Out of range Becomes BLS AROUND JMP TIMBUK2 AROUND: CMPE12 Summer 2009 19-29 Jump The jump instruction allows control to be passed to any address in the 64-Kbyte memory map. CMPE12 Summer 2009 19-30 15

Subroutine Calls and Returns The CPU automates the process of remembering the address in the main program where processing should resume after the subroutine is finished. This address is automatically pushed onto the stack when the subroutine is called and is pulled off the stack during the RTS instruction that ends the subroutine CMPE12 Summer 2009 19-31 Interrupt Handling SWI is like JSR but pushes all registers onto the stack RTI pops them off the stack WAI pushes all registers and waits in low-power mode CMPE12 Summer 2009 19-32 16

Interrupt ex: ledclockint (1/3) /********************************************************* * binary clock on the LED of the HC11 kit * reset the clock with a flash when the interrupt is pressed * andrea di blas *********************************************************/ #include <v2_18g3.asm>.sect.data tick:.byte 0x00 // current second /**********************************************************/.sect.text main: /*--- load ISR ---*/ ldd #CLOCKRESET #ISR_JUMP15 std 0, x CMPE12 Summer 2009 19-33 Interrupt vectors // Ram isr image table jump addresses. Note the table is ordinal and that some // vectors are not available to the user. These are used or reserved for the // system and have not been mapped from the corresponding ROM table. // See Motorola documentation for discussion of these vectors. // 1 unavailable to user SCI #define ISR_JUMP2 0x7bc5 // SPI #define ISR_JUMP3 0x7bc8 // Pulse Accumulator Input #define ISR_JUMP4 0x7bcb // Pulse Accumulator Overflow // 5 unavailable to user Timer Overflow // 6 unavailable to user Output Compare 5 #define ISR_JUMP7 0x7bd4 // Output Compare 4 #define ISR_JUMP8 0x7bd7 // Output Compare 3 #define ISR_JUMP9 0x7bda // Output Compare 2 #define ISR_JUMP10 0x7bde // Output Compare 1 #define ISR_JUMP11 0x7be3 // Input Capture 3 #define ISR_JUMP12 0x7be6 // Input Capture 2 #define ISR_JUMP13 0x7be9 // Input Capture 1 // 14 unavailable to user Real Time Interrupt #define ISR_JUMP15 0x7bec // IRQ // 16 unavailable to user XIRQ // 17 unavailable to user SWI // 18 unavailable to user Illegal Opcode #define ISR_JUMP19 0x7bf8 // Cop fail #define ISR_JUMP20 0x7bfb // Cop clock fail // 21 unavailable to user Reset (found at 0x8040) (from v2_18g3.asm) CMPE12 Summer 2009 19-34 17

Main timer and RTI diagram CMPE12 Summer 2009 19-35 Kit Memory map HC11 0x0000 0x00FF 0x0100 0x0FFF 0x1000 0x7BC0 0x7BC1 0x7BFF 0x7C00 0x7FFF 0x8000 0x803F 0x8040 0xFFFF Internal SRAM 4k System Memory User Area User Interrupt vector jump table I/O ports Internal 64-byte register block External ROM (system code) #define ISR_JUMP15 0x7bec // IRQ CMPE12 Summer 2009 19-36 18

ledclockint.asm (2/3) /*--- start program ---*/ clra #LEDS loop: ldaa tick coma staa 0, X coma inca staa tick ldd #250 WAIT jmp loop /**************************************************/ CMPE12 Summer 2009 19-37 ledclockint.asm (3/3) /* my ISR to reset the clock with a flash! */ CLOCKRESET: pshx #LEDS clra staa 0, X // flash the LEDs cli // re-enable interrupts (int disables) ldd #200 // keep LEDS on for a bit WAIT clra staa tick // clear seconds counter rti /********************************************************* / CMPE12 Summer 2009 19-38 19

Miscellaneous Instructions NOP is a do nothing instruction, just wastes an instruction cycle. STOP is used to turn off the oscillator and put the CPU into a low power mode. Only reset or interrupts can wake it up again. TEST is a reserved instruction only used at the factory when making the chips (illegal opcode) CMPE12 Summer 2009 19-39 20