0% found this document useful (0 votes)
13 views26 pages

9-Arithmetic Instructions and Pin Diagram-17!01!2024

The document outlines arithmetic instructions for the 8051 microcontroller, including addition, subtraction, increment, decrement, multiplication, division, and decimal adjustment. Each instruction is described with examples demonstrating how to use them with the accumulator and registers. The decimal adjustment instruction (DA A) is specifically highlighted for converting hex addition to BCD format.

Uploaded by

Piyush Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views26 pages

9-Arithmetic Instructions and Pin Diagram-17!01!2024

The document outlines arithmetic instructions for the 8051 microcontroller, including addition, subtraction, increment, decrement, multiplication, division, and decimal adjustment. Each instruction is described with examples demonstrating how to use them with the accumulator and registers. The decimal adjustment instruction (DA A) is specifically highlighted for converting hex addition to BCD format.

Uploaded by

Piyush Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

Microprocessors and Microcontrollers : BECE204L

Lecture 8
Arithmetic Instructions

Dr. Vikas Vijayvargiya


Associate Professor
Department of Micro and Nano-Electronics Dr Vikas Vijayvargiya
School of Electronics Engineering
8051 Addressing
Arithmetic modes
Instructions of 8051

Instructions :

1. Addition

2. Subtraction

3. Increment

4. Decrement

5. Multiplication

6. Division

7. Decimal Adjustment
Dr Vikas Vijayvargiya
8051 Addressing
Arithmetic modes
Instructions of 8051

1. Addition Instruction

❖ ADD

❖ ADDC

Dr Vikas Vijayvargiya
8051 Addressing
Arithmetic modes
Instructions of 8051

1. Addition Instruction

❖ ADD : it will add accumulator data with 8 bit and stores result into A

Example :

ADD A, #50H; ;A : A+50H

Dr Vikas Vijayvargiya
8051 Addressing
Arithmetic modes
Instructions of 8051

1. Addition Instruction

❖ ADD : it will add accumulator data with 8 bit and stores result into A

Example :

ADD A, #50H; ;A : A+50H

ADD A , R1 ; A: A+R1

Dr Vikas Vijayvargiya
8051 Addressing
Arithmetic modes
Instructions of 8051

1. Addition Instruction

❖ ADD : it will add accumulator data with 8 bit and stores result into A

Example :

ADD A, #50H; ;A : A+50H

ADD A , R1 ; A: A+R1

ADD A, 17H ; A: A+ [17H]

Dr Vikas Vijayvargiya
8051 Addressing
Arithmetic modes
Instructions of 8051

1. Addition Instruction

❖ ADD : it will add accumulator data with 8 bit and stores result into A

Example :

ADD A, #50H; ;A : A+50H

ADD A , R1 ; A: A+R1

ADD A, 17H ; A: A+ [17H]

ADD A, @R1 ; A: A+ [R1]

Dr Vikas Vijayvargiya
8051 Addressing
Arithmetic modes
Instructions of 8051

1. Addition Instruction

❖ ADDC : it will add accumulator data with 8 bit along with carry and

stores result into A

Example :

ADDC A, #50H; ;A : A+50H+ Carry

ADDC A , R1 ; A: A+R1+ Carry

Dr Vikas Vijayvargiya
8051 Addressing
Arithmetic modes
Instructions of 8051

1. Addition Instruction

❖ ADDC : it will add accumulator data with 8 bit along with carry and

stores result into A

Example :

ADDC A, #50H; ;A : A+50H+ Carry

ADDC A , R1 ; A: A+R1+ Carry

ADDC A, 17H ; A: A+ [17H]+ Carry

ADDC A, @R1 ; A: A+ [R1]+ Carry


Dr Vikas Vijayvargiya
8051 Addressing
Arithmetic modes
Instructions of 8051

2. Subtraction Instructions

❖ SUBB : it will sub accumulator data with 8 bit along with carry and

stores result into A

Example :

SUBB A, #50H ;A : A-50H- Carry

Dr Vikas Vijayvargiya
8051 Addressing
Arithmetic modes
Instructions of 8051

2. Subtraction Instructions

❖ SUBB : it will sub accumulator data with 8 bit along with carry and

stores result into A

Example :

SUBB A, #50H ;A : A-50H- Carry

SUBB A , R1 ; A: A-R1- Carry

SUBB A, 17H ; A: A- [17H]- Carry

SUBB A, @R1 ; A: A- [R1]- Carry


Dr Vikas Vijayvargiya
8051 Addressing
Arithmetic modes
Instructions of 8051

3. Increment Instructions

❖ INC : it will Increment Register, Pointer or data of memory locations

Example :

INC A ;A : A+1

INC R1 ; R1: R1+1

Dr Vikas Vijayvargiya
8051 Addressing
Arithmetic modes
Instructions of 8051

3. Increment Instructions

❖ INC : it will Increment Register, Pointer or data of memory locations

Example :

INC A ;A : A+1

INC R1 ; R1: R1+1

INC 25H ; [25H]: [25H]+1

INC @R1 ; [R1]: [R1]+1

Dr Vikas Vijayvargiya
8051 Addressing
Arithmetic modes
Instructions of 8051

3. Increment Instructions

❖ INC : it will Increment Register, Pointer or data of memory locations

Example :

INC A ;A : A+1

INC R1 ; R1: R1+1

INC 25H ; [25H]: [25H]+1

INC @R1 ; [R1]: [R1]+1

INC DPTR ; DPTR: DPTR+1


Dr Vikas Vijayvargiya
8051 Addressing
Arithmetic modes
Instructions of 8051

4. Decrement Instructions

❖ DEC : it will decrement Register, Pointer or data of memory locations

Example :

DEC A ;A : A-1

DEC R1 ; R1: R111

DEC 25H ; [25H]: [25H]-1

DEC @R1 ; [R1]: [R1]-1

Dr Vikas Vijayvargiya
8051 Addressing
Arithmetic modes
Instructions of 8051

4. Decrement Instructions

❖ DEC : it will decrement Register, Pointer or data of memory locations

Example :

DEC A ;A : A-1

DEC R1 ; R1: R111

DEC 25H ; [25H]: [25H]-1

DEC @R1 ; [R1]: [R1]-1

DEC DPTR ; Does not exit


Dr Vikas Vijayvargiya
8051 Addressing
Arithmetic modes
Instructions of 8051

5. Multiplication Instructions

❖ MUL AB : it will Multiply A and B and answer will be stored in BA where

B stores Higher Byte and A hold lower byte

Dr Vikas Vijayvargiya
8051 Addressing
Arithmetic modes
Instructions of 8051

5. Multiplication Instructions

❖ MUL AB : it will Multiply A and B and answer will be stored in BA where

B stores Higher Byte and A hold lower byte

MUL AB ; (Bhigher byte Alower byte ): A × B

Dr Vikas Vijayvargiya
8051 Addressing
Arithmetic modes
Instructions of 8051

6. Division Instruction

❖ DIV AB : it will Divide A by B and answer remainder will be stored in B

and Quotient will be stored in A.

DIV AB ; (BRemainder AQuotient ): A/B

Dr Vikas Vijayvargiya
8051 Addressing
Arithmetic modes
Instructions of 8051
6. Decimal Adjustment Instruction-- DA A :
Few Attributes of DA :

✓ It will be used after ADD Instruction

✓ It is used to convert that given Hex addition in BCD addition

✓ Normal addition is done by ADD that is binary or Hex addition

✓ After when you use DA A, it adjust that addition in BCD form

✓ DA A performs following adjustments

i. if lower nibble >9 or Auxiliary carry is 1 then Add 06H with A

ii. if higher nibble >9 or carry is 1 then Add 60H with A

Dr Vikas Vijayvargiya
8051 Addressing
Arithmetic modes
Instructions of 8051
6. Decimal Adjustment Instruction-- DA A :
Few Attributes of DA :

✓ DA A performs following adjustments

i. if lower nibble >9 or Auxiliary carry is 1 then Add 06H with A

ii. if higher nibble >9 or carry is 1 then Add 60H with A

Example

ADD A, R1 ;A: A +R1

DA A ; BCD Addition Adjustment

Dr Vikas Vijayvargiya
8051 Addressing
Arithmetic modes
Instructions of 8051
6. Decimal Adjustment Instruction-- DA A :
Few Attributes of DA :

✓ DA A performs following adjustments

i. if lower nibble >9 or Auxiliary carry is 1 then Add 06H with A

ii. if higher nibble >9 or carry is 1 then Add 60H with A

Example

ADD A, R1 ;A: A +R1

DA A ; BCD Addition Adjustment

Dr Vikas Vijayvargiya
8051 Addressing
Arithmetic modes
Instructions of 8051
6. Decimal Adjustment Instruction-- DA A :
Few Attributes of DA :

✓ DA A performs following adjustments

i. if lower nibble >9 or Auxiliary carry is 1 then Add 06H with A

ii. if higher nibble >9 or carry is 1 then Add 60H with A

Example

ADD A, R1 ;A: A +R1

DA A ; BCD Addition Adjustment

Dr Vikas Vijayvargiya
8051 Addressing
Arithmetic modes
Instructions of 8051
6. Decimal Adjustment Instruction-- DA A :
Few Attributes of DA :

✓ DA A performs following adjustments

i. if lower nibble >9 or Auxiliary carry is 1 then Add 06H with A

ii. if higher nibble >9 or carry is 1 then Add 60H with A

Example

ADD A, R1 ;A: A +R1

DA A ; BCD Addition Adjustment

Dr Vikas Vijayvargiya
8051 Addressing
Arithmetic modes
Instructions of 8051
6. Decimal Adjustment Instruction-- DA A :
Few Attributes of DA :

✓ DA A performs following adjustments

i. if lower nibble >9 or Auxiliary carry is 1 then Add 06H with A

ii. if higher nibble >9 or carry is 1 then Add 60H with A

Example

ADD A, R1 ;A: A +R1

DA A ; BCD Addition Adjustment

Dr Vikas Vijayvargiya
8051 Addressing
Arithmetic modes
Instructions of 8051
6. Decimal Adjustment Instruction-- DA A :
Few Attributes of DA :

✓ DA A performs following adjustments

i. if lower nibble >9 or Auxiliary carry is 1 then Add 06H with A

ii. if higher nibble >9 or carry is 1 then Add 60H with A

Example

ADD A, R1 ;A: A +R1

DA A ; BCD Addition Adjustment

Dr Vikas Vijayvargiya

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy