The M68HC11 Basic Instruction Set Basic Arithmetic Instructions

Slides:



Advertisements
Similar presentations
Ch.3 Representation and Manipulation of Information From Introduction to Embedded Systems: Interfacing to the Freescale 9s12 by Valvano, published by CENGAGE.
Advertisements

Week 3. Assembly Language Programming  Difficult when starting assembly programming  Have to work at low level  Use processor instructions >Requires.
MOV Instruction MOV destination, source ; copy source to dest. MOV A,#55H ;load value 55H into reg. A MOV R0,A ;copy contents of A into R0 ;(now A=R0=55H)
9/20/6Lecture 3 - Instruction Set - Al Instruction Set.
ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS
Revised: Aug 1, EE4390 Microprocessors Lesson 6,7 Instruction Set, Branch Instructions, Assembler Directives.
H. Huang Transparency No.1-1 The 68HC11 Microcontroller Chapter 1: Introduction to 68HC11 The 68HC11 Microcontroller.
TK 2633 Microprocessor & Interfacing Lecture 3: Introduction to 8085 Assembly Language Programming (2) 1 Prepared By: Associate Prof. Dr Masri Ayob.
Assembly Language and Computer Architecture Using C++ and Java
M68K Assembly Language Programming Bob Britton Chapter 4 Number Systems.
1  2004 Morgan Kaufmann Publishers Chapter Three.
© 2006 Pearson Education, Upper Saddle River, NJ All Rights Reserved.Brey: The Intel Microprocessors, 7e Chapter 5 Arithmetic and Logic Instructions.
1 Binary Arithmetic, Subtraction The rules for binary arithmetic are: = 0, carry = = 1, carry = = 1, carry = = 0, carry =
EET 2261 Unit 2 HCS12 Architecture
Chapter 4 Basic Instructions. 4.1 Copying Data mov Instructions mov (“move”) instructions are really copy instructions, like simple assignment statements.
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
1 Binary Numbers Again Recall that N binary digits (N bits) can represent unsigned integers from 0 to 2 N bits = 0 to 15 8 bits = 0 to bits.
FIGURES FOR CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
ECE 265 – LECTURE 4 The M68HC11 Address Modes 8/14/ ECE265.
Computer Arithmetic Nizamettin AYDIN
The 8051 Microcontroller and Embedded Systems
Computer Arithmetic. Instruction Formats Layout of bits in an instruction Includes opcode Includes (implicit or explicit) operand(s) Usually more than.
Khaled A. Al-Utaibi  Introduction  Arithmetic Instructions  Basic Logical Instructions  Shift Instructions  Rotate Instructions.
#1 Lec # 2 Winter EECC341 - Shaaban Positional Number Systems A number system consists of an order set of symbols (digits) with relations.
Machine Instruction Characteristics
IT253: Computer Organization
ECEN2102 Digital Logic Design Lecture 1 Numbers Systems Abdullah Said Alkalbani University of Buraimi.
Digital Logic Design Lecture 3 Complements, Number Codes and Registers.
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION.
9/20/6Lecture 3 - Instruction Set - Al Instruction Set (2)
Chapter four – The 80x86 Instruction Set Principles of Microcomputers 2015年10月19日 2015年10月19日 2015年10月19日 2015年10月19日 2015年10月19日 2015年10月19日 1 Chapter.
ECE 301 – Digital Electronics Unsigned and Signed Numbers, Binary Arithmetic of Signed Numbers, and Binary Codes (Lecture #2)
ECE 265 – LECTURE 8 The M68HC11 Basic Instruction Set The remaining instructions 10/20/ ECE265.
BR 8/99 Binary Numbers Again Recall than N binary digits (N bits) can represent unsigned integers from 0 to 2 N bits = 0 to 15 8 bits = 0 to 255.
Charles Kime & Thomas Kaminski © 2004 Pearson Education, Inc. Terms of Use (Hyperlinks are active in View Show mode) Terms of Use Logic and Computer Design.
ECE 2110: Introduction to Digital Systems Signed Addition/Subtraction.
ECE 447: Lecture 12 Logic, Arithmetic, Data Test and Control Instructions of MC68HC11.
ECE 265 – LECTURE 3 68HC11 Address Space, Memory, Registers, and data transfers 3/29/ ECE265.
 Lecture 2 Processor Organization  Control needs to have the  Ability to fetch instructions from memory  Logic and means to control instruction sequencing.
ECE 265 – LECTURE 5 The M68HC11 Basic Instruction Set 12/8/ ECE265.
CEC 220 Digital Circuit Design Binary Arithmetic & Negative Numbers Monday, January 13 CEC 220 Digital Circuit Design Slide 1 of 14.
CEC 220 Digital Circuit Design Binary Arithmetic & Negative Numbers Fri, Aug 28 CEC 220 Digital Circuit Design Slide 1 of 14.
Microcontroller Fundamentals & Programming Arithmetic Instructions.
Arithmetic and Logic Instructions
순천향대학교 정보기술공학부 이 상 정 1 3. Arithmetic for Computers.
ECE 447: Lecture 11 Introduction to Programming in Assembly Language.
©2010 Cengage Learning SLIDES FOR CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION Click the mouse to move to the next page. Use the ESC key to exit.
Microprocessor & Assembly Language Arithmetic and logical Instructions.
Number Systems. The position of each digit in a weighted number system is assigned a weight based on the base or radix of the system. The radix of decimal.
CS2100 Computer Organisation
Status Register Status = system byte (supervisor only) + user byte = system status + condition code register usually, it is not important to know.
ECE 3430 – Intro to Microcomputer Systems
HC11 Programming.
Classification of Instruction Set of 8051
ECE 3430 – Intro to Microcomputer Systems
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
ECE 3430 – Intro to Microcomputer Systems
Instruction Groups The 8051 has 255 instructions.
Arithmetic operations Programming
The 8051 Assembly Language Arithmetic & Logic Instructions
Chapter 11 © 2011, The McGraw-Hill Companies, Inc.
Data Representation in Computer Systems
ECE 3430 – Intro to Microcomputer Systems
Chapter 5 Arithmetic and Logic Instructions
ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS
COMS 361 Computer Organization
Presentation transcript:

The M68HC11 Basic Instruction Set Basic Arithmetic Instructions ECE265 ECE 265 – Lecture 6 The M68HC11 Basic Instruction Set Basic Arithmetic Instructions 4/20/2017

Lecture Overview The M68HC11 Basic Instruction Set The basic mathematical instructions REF: Chapter 3 and the appendix that details the instructions. ECE265 4/20/2017

Arithmetic Instructions These instructions are used to add, subtract, compare, increment, decrement, 2’s complement, test, and decimal adjust data. Both 8-bit and 16-bit operations are possible. It is possible to write code that allows data of higher precision to be operated upon. This extended precision requires the user to write code to support the higher precision. Architecture also supports Binary Coded Decimal (BCD) operations. ECE265 4/20/2017

Add instructions Add instructions – note the addressing mode ECE265 4/20/2017

Add operations Operation: Description: 2’s complement binary addition ABA – add the A and B accumulators – Result in A ABX, ABY – add B to the specified index register ADCA,ADCB – add with carry to A/B ADDA,ADDB – add the contents of memory to A/B ADC and these set the H CC bit to accommodate BCD arithmetic ADDD – a 16-bit addition using memory Description: 2’s complement binary addition CC effects: N X V C and H as noted ECE265 4/20/2017

The overflow flag What exactly is overflow? Does that mean you exceeded the binary range represent-able? ECE265 4/20/2017

More arithemetic instructions Decimal adjust, increment and decrement, and Two’s complement. ECE265 4/20/2017

Decimal Adjust DAA Description: Adjusts the result in A to a valid BCD number. Consider adding the BCD for $99 + $22 in Accum A Both $99 and $22 are valid BCD numbers. Adding these in binary gives a result of $BB with no half carry or carry. Also, $B is not a valid BCD digit. Executing DAA will have the following effect. For the lsd: BCD of $9 + $2= $B will give a $1 and a half carry. For the most significant digit you have $9 + $2=$B adjusted $B is $1 + hc = $2 and a final carry out. So here, accumulator A is adjusted to $21 and both C & H are set CC effects: N Z and C H are corrected Forms: DAA and only inherent mode ECE265 4/20/2017

Increment and Decrement Description: Instructions that increment or decrement a memory location or either the A or B accumulator (Inherent mode). Note that there is no instruction to increment or decrement the D accumulator. (and C is not affected) CC effects: N Z V Forms: INCA INCB INC (opr) DECA DECB DEC(opt) Just add 1 or subtract 1 (2’s complement) ECE265 4/20/2017

Two complement operations Description: Replace the contents of the location with its two’s complement value CC effects: N Z V and C The C bit will be set in all cases except when the contents are $00 Forms: NEGA NEGB NEG (opr) ECE265 4/20/2017

Two’s Complement How do you get the two’s complement? Two simple algorithms – consider 00001001(dec 9) ECE265 4/20/2017

Two’s Complement How do you get the two’s complement? Two simple algorithms – consider 00001001(dec 9) 1. Take the 1’s complement and add 1 Ones complement is 11110110 + 00000001 = 11110111 Which represents -9 ECE265 4/20/2017

Two’s Complement How do you get the two’s complement? Two simple algorithms – consider 00001001(dec 9) 1. Take the 1’s complement and add 1 Ones complement is 11110110 + 00000001 = 11110111 Which represents -9 2. Starting with the lsb keep all binary digits until you come to the 1st 1. Keep that 1. Invert all the more significant binary digits. Easy to see on the above example. Now consider 0000 1110  11110010 (14 and -14) ECE265 4/20/2017

Two’s complement numbers 0111 7 0110 6 0101 5 0100 4 0011 3 0010 2 0001 1 0000 0 1111 -1 1110 -2 1101 -3 1100 -4 1011 -5 1010 -6 1001 -7 1000 -8 For 4-bits ECE265 4/20/2017

Additional Arithmetic Instr. A few more instructions, this time for binary subtraction ECE265 4/20/2017

Binary subtraction Consider the following example of 7 – 5 = 2 0111 -0101 0010 Direct and very easy to see Now throw in a borrow - 6 – 5 = 1 0110 -0101 but right off see that we need to subtract 1 from 0 so borrow from the next binary position and get 0102 (and yes 2 is not a binary digit – but this is for illustration) -0101 (and it is the weight when a digit is moved right) 0001 ECE265 4/20/2017

More binary subtraction Consider 12 – 3 = 9 1100 -0011 and we again have borrows ECE265 4/20/2017

More binary subtraction Consider 12 – 3 = 9 1100 -0011 and we again have borrows 1020 after 1st step of borrow -0011 but we still need a borrow ECE265 4/20/2017

More binary subtraction Consider 12 – 3 = 9 1100 -0011 and we again have borrows 1020 after 1st step of borrow -0011 but we still need a borrow 1012 after 2nd step of borrow -0011 1001 which is the binary for 9 ECE265 4/20/2017

How about a 2’s complement result An example to get a 2’s complement result, i.e., a negative number result. Consider 3 – 5 0011 - 0101 Borrow in =1 2011  1211 giving 1110 which is the 2’s complement for -2 And here would also have a CC carry bit of 1 to indicate a borrow. ECE265 4/20/2017

The subtract instruction Description: Subtract the contents of two locations CC effects: N Z V and C C is set if contents of 2nd operand is larger Forms: SBA – subtract accumulator B from A  A SUBA (opr) – subtract memory location SUBB (opr) contents from accumulator SUBD (opr) - 16 bit operation SBCA (opr), SBCB (opr) – subtract with carry ECE265 4/20/2017

Compare Instructions Instruction to compare two values and set condition codes. ECE265 4/20/2017

Compare Instructions Description: compare the data at two locations and set the CC bits. The data is not altered. (Compare instructions perform a subtraction to update the bits of the CC register.) CC effects: N V C Z Forms: CBA CPD (opr) CMPA (opr) and CMPB (opr) Addressing modes: Note the difference in the mnemonic for register compare of D, A, or B to memory. ECE265 4/20/2017

Compare instruction example Comparison of a subtract versus a compare. A subtract instruction does alter one of the operands which is the destination. Note that only the affected bit of the CCR is shown. ECE265 4/20/2017

Compare example problem PROBLEM: What programming steps are needed to compare the data at address $1031 with a set point value of $50 using accumulator A. Note that this address is one of the A/D result registers, i.e., where the result of an A/D conversion is stored. ECE265 4/20/2017

Compare example problem PROBLEM: What programming steps are needed to compare the data at address $1031 with a set point value of $50 using accumulator A. Note that this address is one of the A/D result registers, i.e., where the result of an A/D conversion is stored. LDDA #$50 Load the set point into Reg A CMPA $1031 Compare A to memory (A-M) Results will indicate if A=M : Z=1 A>M : N=0 Z=0 A<M : N=1 Z=0 ECE265 4/20/2017

Another example If the data at address $1031 in the previous example was $45 which bits in the CC register are set or cleared? ECE265 4/20/2017

Test Instruction The test instructions Allows testing of values for positive, negative, or zero values. The instruction subtracts $00 from the location, setting the CC register bits. The contents of the location are not modified. ECE265 4/20/2017

Multiply and Divide instructions The processor can perform and 8-bit by 8-bit multiply and two forms of divide. The forms for divide are integer and fractional. ECE265 4/20/2017

The multiply Example 3.12 from text: What programming steps are needed to multiply the data at location $D500 with the data at location $D510. The result is to be stored at $D520 and $D521. LDAA $D500 Load value #1 into A accum LDAB $D510 Load value #2 into B accum MUL A x B -> D STD $D520 Store result (16 bits) ECE265 4/20/2017

Another multiply example Figure 3.5 ECE265 4/20/2017

Binary Multiplication Multiply in the previous example $FF = 1111 1111 255 $14 = 0001 0100 20 11 1111 1100 5100 1111 1111 0000 1 0011 1110 1100 ($13EC) Is this 5100? 4096 +512+256 +128+64+32 +8+4 4096 +768 +128+96 +12 4864 +140 +96 = 4864 + 236 = 5100  ECE265 4/20/2017

The Divide instruction 2 divide instructions IDIV Binary integer division Used when D is larger than X Divide D/X -> X with the remainder going into D FDIV Binary fractional division Used when X is larger than D Divide D/X -> X with the remainder (or continuation of the fractional part going into D ECE265 4/20/2017

Division Examples Integer and Fractional examples ECE265 4/20/2017

Lecture summary Have covered Cover data transfer instructions in Lecture 5 In this lecture went over the basic arithmetic instructions Add Subtract Increment and Decrement Testing data Multiply and Divide ECE265 4/20/2017

Assignment Problems Chapter 3 page 87 Problem 13 Problem 14 Problem 17 ECE265 4/20/2017