Microcontroller Fundamentals & Programming Arithmetic Instructions.

Slides:



Advertisements
Similar presentations
H. Huang Transparency No.1-1 The HCS12/MC9S12 Microcontroller Copyright © 2010 Delmar Cengage Learning HCS12 Instruction Examples The LOAD and STORE Instructions.
Advertisements

Ch.3 Representation and Manipulation of Information From Introduction to Embedded Systems: Interfacing to the Freescale 9s12 by Valvano, published by CENGAGE.
Microprocessors.
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)
Programming 68HC11.
EE 362 Microprocessor Systems and Interfacing © 1-1 Lecture 1: Introduction to Microprocessor Based Systems Microprocessor Architecture Microprocessor.
ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS
EET 2261 Unit 5 Tables; Decision Trees & Logic Instructions
Revised: Aug 1, EE4390 Microprocessors Lesson 6,7 Instruction Set, Branch Instructions, Assembler Directives.
HCS12 Arithmetic Lecture HC12 Arithmetic Addition and Subtraction Shift and Rotate Instructions Multiplication Division.
Addressing Modes & Instruction Set By: Prof. Mahendra B. Salunke Asst. Prof., Department of Computer Engg., SITS, Pune-41 URL:
© 2010 Kettering University, All rights reserved..
Assembler Programming Chapter 6. EEL-4746 Best Practices.
The 68HC11 Microcontroller Minnesota State University, Mankato
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.
© 2006 Pearson Education, Upper Saddle River, NJ All Rights Reserved.Brey: The Intel Microprocessors, 7e Chapter 5 Arithmetic and Logic Instructions.
1 ECE 372 – Microcontroller Design Basic Assembly Programming for(j=0; j
Dr Masri Ayob TK 2633: Microprocessor & Interfacing Lecture 5: Arithmetic and Logic Instructions.
Microcontroller Fundamentals & Programming
© 2010 Kettering University, All rights reserved..
The M68HC11 Basic Instruction Set Basic Arithmetic Instructions
Chapter 2: 68HC11 Assembly Programming
H. Huang Transparency No.2-1 The 68HC11 Microcontroller Chapter 2: 68HC11 Assembly Programming The 68HC11 Microcontroller.
Lab 1 – Assembly Language and Interfacing Start date: Week 3 Due date: Week 4 1.
The 8051 Microcontroller and Embedded Systems
ME4447/6405 The George W. Woodruff School of Mechanical Engineering ME4447/6405 Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics.
Microprocessors A microprocessor is essentially a computer on a single chip. It is also an example of a complex finite state machine or clocked sequential.
EECC250 - Shaaban #1 Lec # 20 Winter Microcontroller Basics A microcontroller is a small, low-cost computer-on-a-chip which usually includes:
ECE 265 – LECTURE 8 The M68HC11 Basic Instruction Set The remaining instructions 10/20/ ECE265.
Physics 413 Chapter 4 A Fork in the Road LDAB # $ 13 here :ADDA # $ 24 DEC B BNE here WAI BNE is the new instruction. Branch if not equal to zero.
© 2010 Kettering University, All rights reserved..
ECE 447: Lecture 12 Logic, Arithmetic, Data Test and Control Instructions of MC68HC11.
ME4447/6405 The George W. Woodruff School of Mechanical Engineering ME4447/6405 Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics.
Ass. Prof. Dr Masri Ayob Lecture 5: Arithmetic and Logic Instructions TK 2633: Microprocessor & Interfacing.
Motorola MC68HC811E2 Microcontrollers
Machine Language ELEC 330 Digital Systems Engineering Dr. Ron Hayne.
1 ECE 372 – Microcontroller Design Assembly Programming HCS12 Assembly Programming Addressing Modes Stack Operations Subroutines.
1 Introduction to Microcontroller Microcontroller Fundamentals & Programming.
Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 8.
1 Microcontroller Fundamentals & Programming Addressing Modes.
CHAPTER 6 ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS.
ECE 447: Lecture 11 Introduction to Programming in Assembly Language.
Embedded Systems Lecture 5 January 25 th, 2016.
1 ECE 372 – Microcontroller Design Assembly Programming – Arrays unsigned short a[10]; for(j=0; j
1 ECE 372 – Microcontroller Design Basic Assembly Programming for(j=0; j
نظام المحاضرات الالكترونينظام المحاضرات الالكتروني 8085 Instruction Set Instruction types. data transfer group. Arithmetic group.
The 68HC11 Microcontroller Minnesota State University, Mankato
Addressing Modes in Microprocessors
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
Digital Arithmetic Wen-Hung Liao, Ph.D..
ECE 3430 – Intro to Microcomputer Systems
ECE 3430 – Intro to Microcomputer Systems
ECE 3430 – Intro to Microcomputer Systems
Instruction Groups The 8051 has 255 instructions.
Memory Organisation Source: under
Arithmetic operations Programming
The 8051 Assembly Language Arithmetic & Logic Instructions
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME4447/6405 Microprocessor Control of Manufacturing Systems and
Chapter 11 © 2011, The McGraw-Hill Companies, Inc.
ECE 3430 – Intro to Microcomputer Systems
Arithmetic Instructions By Dr. S. N. Sampat, Team leader Ms. R. P
Chapter 5 Arithmetic and Logic Instructions
ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS
Indexing Through Memory
Presentation transcript:

Microcontroller Fundamentals & Programming Arithmetic Instructions

2 The 68HC11 Arithmetic Instructions are :  ADD, ADD with Carry,  SUBTRACT, SUBTRACT with Carry,  DECIMAL ADJUST Instruction,  INCREMENT, DECREMENT,  COMPARE,  MULTIPLICATION, and  DIVISION

3 Example: ADDA, ADDB, ADDD  Add contents in accumulator with contents in memory.  The result after addition will be placed in accumulator.  The flag bits in CCR will change according to the result of the addition Memory ACC + Result Goes Back ADD Instructions xx

4 LDAA #$29ACCA = ADDA #$3A3A = Result: ACCA = $63 Binary= Hex = 6 3 The flag bits in the CCR change as follow: H = 1A “1” is carried over from bit-3 to bit-4 N = 0Answer or result is positive Z = 0The result is not zero V = 0No overflow. Answer is correct. C = 0No carry. Example: ADD Instruction

5 Example: ADCA, ADCB  Add the contents in accumulator with contents in memory and with the C-bit in the CCR. ACC Result Memory C-bit ADD with Carry Instructions CCR xx

6 The flag bits in the CCR change as follow: H = 1A “1” is carried over from bit-3 to bit-4 N = 0Answer or result is positive Z = 0The result is not zero V = 0No overflow. Answer is correct. C = 0No carry. SEC ; Set Carry to “1” LDAA #$29 ; ACCA = ADCA #$3A ; $3A = C-bit = Result: ACCA = $64 Binary = Hex. = 6 4 Example: ADD with CARRY instruction

7 The flag bits in the CCR change as follow: H = XNot use. N = 0Answer or result is positive. Z = 0The result is not zero V = 0Answer is correct. C = 0No carry. LDD #$2299 ACCD = ADDD #$0800 ;$0800 = Result: ACCD = $2A99 ;Binary = Hex. = 2 A9 9 Example: ADDD (Add 16-bit values)

8 Example: SUBA, SUBB, SUBD  Subtract memory contents from the accumulator.  The result after subtraction placed in accumulator.  Flag bits in CCR will change according to the result of subtraction Memory ACC Result _ SUBTRACT Instructions xx

9 The flag bits in the CCR change as follow: H = XNot use. N = 1Answer or result is negative Z = 0The result is not zero V = 0Answer is correct. C = 1$3A larger than $29, so a borrow is required. C = 1 LDAA #$29 ; ACCA = SUBA #$3A ; $3A = Result: ACCA = $EF Binary = Hex. = E F Example: SUBTRACT instruction

10 Example: SBCA, SBCB  Subtract memory contents and the C-bit from accumulator.  The result after the subtraction will be placed in accumulator.  The flag bits in CCR will change according to the result of subtraction Memory ACC _ C-bit Result Subtract with Carry Instructions xx CCR

11 The flag bits in the CCR change as follow: H = XNot use N = 0Answer or result is positive Z = 0The result is not zero V = 0No overflow. Answer is correct. C = 0No borrow.. SEC ; Set Carry to “1” LDAA #$3A ; ACCA = SBCA #$23 ;$23 = C-bit = Result:ACCA = $16 Binary = Hex. = 1 6 Example: Subtract with Carry Instruction

12 Example: DAA  DAA instruction adjusts accumulator A contents immediately following an ADDA or ADCA only.  DAA will adjust the result to BCD format. LDAA#$29 ; ACCA = $2 9 ADDA#$3A ; $3A = $3 A + DAA ; before DAA = $6 3 (6) + Result: ACCA = $69 ; after DAA = $6 9 Decimal Adjusted Instruction

13 Example: DAA Rule for BCD addition  If result is equal or less than 9 and a carry is not produced, then answer is correct. (No adjustment needed)  If result is greater than 9 or a carry is produced, a correction of +6 must be added to the sum. Decimal Adjusted Instruction (Rule)

14 Examples of DAA (1) Example 1: Equal or less than 9 and NO carry LDAA#$25 ; ACCA = $2 5 ADDA#$33 ; $33 = $3 3 + DAA ; before DAA = $5 8 Result: ACCA = $58 ; after DAA = $5 8

15 Examples of DAA (2) Example 2: Greater than 9 and NO carry LDAA#$25 ; ACCA = $2 5 ADDA#$36 ; $36 = $3 6 + DAA ; before DAA = $5 B 6 + Result: ACCA = $61 ; after DAA = $6 1

16 Examples of DAA (3) Example 3: Greater than 9 and a carry LDAA#$66 ; ACCA = $6 6 ADDA#$3A ; $3A = $3 A + DAA ; before DAA = $A Result: ACCA = $06 ; after DAA = $10 6 C-bit =1

17 Example: INC, INCA, INCB, INX, INY After executing the increment instruction a value of one is added to the memory or registers. Flag bits N, Z, V will be affected. Increment Instructions

18 LDX #$2000; IX = $2000 LDAA #$20; ACCA = $20 LDAB #$35 ; ACCB = $35 STAA $1200 ; Memory ($1200) = $20 INCA; ACCA = $20 + $01 = $21 INCB; ACCB = $35 + $01 = $36 INC $1200 ; Memory ($1200) = $20+$01=$21 INX; IX = $2000+$01 = $2001 WAI Examples: INCREMENT instructions

19 Example: DEC, DECA, DECB, DEX, DEY After executing the decrement instruction a value of one is subtracted from the memory or registers. Flag bits N, Z, V will be affected. Decrement Instructions

20 LDX #$205A; IX = $205A LDAA #$2E; ACCA = $2E LDAB #$89; ACCB = $89 STAB $1500 ; Memory ($1500) = $89 DECA; ACCA = $2E - $01 = $2D DECB; ACCB = $89 - $01 = $88 DEC $1500 ; Memory ($1500)= $89 - $01= $88 DEX; IX = $205A - $01 = $2059 WAI Examples: DECREMENT instructions

21 Example: CMPA, CMPB, CMPD, CPX, CPY  are used to compare the contents of registers and memory data.  after instruction has been executed: −the flag bits are updated according to the result. −contents of register and memory data will not change.  Compare and conditional branch instructions are usually use together. Compare Instructions

22 LDAA #$09 ; ACCA = $09 CMPA #$09 ; ACCA subtract $09 BEQ DISP; if result equal = zero ; branch to DISPLAY ; content of ACCA = $ DISP LDX $1000 Example: Compare

23 Thank You