0% found this document useful (0 votes)
2 views18 pages

Arithmetic Operations

The document outlines various arithmetic operations in microprocessor and microcontroller systems, focusing on instructions such as ADD, ADDC, SUBB, INC, and DEC. It explains the functionality of each instruction, including how they handle carry and borrow conditions, and provides examples for adding and subtracting 16-bit numbers. Additionally, it highlights the effects of INC and DEC instructions on operands.

Uploaded by

zainerjuanillo54
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)
2 views18 pages

Arithmetic Operations

The document outlines various arithmetic operations in microprocessor and microcontroller systems, focusing on instructions such as ADD, ADDC, SUBB, INC, and DEC. It explains the functionality of each instruction, including how they handle carry and borrow conditions, and provides examples for adding and subtracting 16-bit numbers. Additionally, it highlights the effects of INC and DEC instructions on operands.

Uploaded by

zainerjuanillo54
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

ARITHMETIC OPERATIONS

MICROPROCESSOR AND MICROCONTROLLER SYSTEMS


TOPICS

o INTRODUCTION
o ADD INSTRUCTION
o ADDC INSTRUCTION
o SUBB INSTRUCTION
o INC INSTRUCTION
INTRODUCTION

❑ 8 Mnemonics for Arithmetic Operations:


ADD INSTRUCTION

❑ Two mnemonics for arithmetic addition operations: ADD and ADDC.


❑ ADD: carry is not considered
❑ ADDC: the condition of carry flag (CY) is taken into account at the time of addition.
❑ For multiple bytes addition, it is applicable where carry plays an important role.
ADD INSTRUCTION

❑ Example:

Assume that memory locations, 04H and 05H, contain two unsigned 8-bit numbers. Write a
program to add these two numbers and store it in memory location 30H. Assume that register
bank #0 is selected.
ADD INSTRUCTION
❑ Example:

Assume that memory locations, 04H and 05H, contain two unsigned 8-bit numbers. Write a
program to add these two numbers and store it in memory location 30H. Assume that register
bank #0 is selected.
ADD INSTRUCTION
❑ Example:

Assume that memory locations, 04H and 05H, contain two unsigned 8-bit numbers. Write a
program to add these two numbers and store it in memory location 30H. Assume that register
bank #0 is selected.
ADD INSTRUCTION
❑ Example:

Assume that memory locations, 04H and 05H, contain two unsigned 8-bit numbers. Write a
program to add these two numbers and store it in memory location 30H. Assume that register
bank #0 is selected.
ADD INSTRUCTION
❑ Example:

Assume that memory locations, 04H and 05H, contain two unsigned 8-bit numbers. Write a
program to add these two numbers and store it in memory location 30H. Assume that register
bank #0 is selected.
ADDC INSTRUCTION

❑ the ADDC instruction takes into account the condition of the CY flag at the time of
performing the 8-bit addition.
❑ When used for I/O ports, ADDC would get the data from the port pins and not from the
port latch.
❑ ADDC instruction is useful for multiple-byte addition.
ADDC INSTRUCTION
❑ Example:

Write a program to add two 16-bit numbers, say B7C2H and 549AH. The first 16-bit number is
located in registers R2 and R3 of bank #0 (currently selected) with lower of the two bytes in R2 and
the higher in R3. Th e second 16-bit number is located in memory location 09H and 0AH with its
lower byte in 09H and higher byte in 0AH. Store the result in 2FH (lower byte) and 30H (higher byte).
ADDC INSTRUCTION
ADDC INSTRUCTION
SUBB INSTRUCTION

❑ The SUBB instruction always considers the borrow (or CY flag condition) during its operation.

❑ In case of subtraction, the source operand is always subtracted from the content of the
accumulator. Therefore, whatever be the adopted addressing mode, the accumulator must
be properly loaded before the subtraction operation.
SUBB INSTRUCTION
❑ EXAMPLE:

Write a program to subtract a 16-bit number, say B7C2H from another, say, 549AH. The first 16-
bit number is located in registers R2 and R3 of bank #0 (currently selected) with lower of the
two bytes in R2 and the higher in R3. Th e second 16-bit number is located in memory location
09H and 0AH with its lower byte in 09H and higher byte in 0AH. Store the result in 2FH (lower
byte) and 30H (higher byte).
SUBB INSTRUCTION
❑ EXAMPLE:

Write a program to subtract a 16-bit number, say B7C2H from another, say, 549AH. The first 16-
bit number is located in registers R2 and R3 of bank #0 (currently selected) with lower of the
two bytes in R2 and the higher in R3. Th e second 16-bit number is located in memory location
09H and 0AH with its lower byte in 09H and higher byte in 0AH. Store the result in 2FH (lower
byte) and 30H (higher byte).
INC INSTRUCTION
❑ INC instruction increments the content of the source operand by one.
❑ No flags are affected by this increment.

❑ INC DPTR is the only instruction that takes care of a 16-bit increment.
❑ If the original content of DPTR is FFFFH before execution of this instruction, then it would
contain 0000H afterwards.
DEC INSTRUCTION
❑ The DEC instruction decrements the content of the source operand by one, which is the
opposite of the INC instruction.

You might also like