Page 46 - DCAP210_INTRODUCTION__TO_MICROPROCESSORS
P. 46
Introduction to Microprocessors
Notes 3.3.2 Arithmetic Operations
These instructions perform arithmetic operations such as addition, subtraction, increment, and
decrement.
Addition: Any 8-bit number or the contents of a register or the contents of a memory location can
be added to the contents of the accumulator and the sum is stored in the accumulator. No two
other 8-bit registers can be added directly (e.g. the contents of register B cannot be added directly
to the contents of the register C). The instruction DAD is an exception; it adds 16-bit data directly
in register pairs.
Subtraction: Any 8-bit number or the contents of a register or the contents of a memory location
can be subtracted from the contents of the accumulator and the results stored in the accumulator.
The subtraction is performed in 2’s compliment, and the results if negative, are expressed in 2’s
complement. No two other registers can be subtracted directly.
Increment/Decrement: The 8-bit contents of a register or a memory location can be incremented or
decrement by 1. Similarly, the 16-bit contents of a register pair (such as BC) can be incremented or
decrement by 1. These increment and decrement operations differ from addition and subtraction in
an important way; i.e. they can be performed in any one of the registers or in a memory location.
The ADD, ADI, SUB, SUI instructions have following properties:
(a) Implicitly assumes that the Accumulator is one of the operand and so the second byte is not
passed in 2-byte instruction.
(b) The result is stored in the Accumulator.
(c) The contents of the operand register is not affected.
(d) The result can alter all the flags.
R represents any of registers A, B, C, D, E, H, and L.
The INR, DCR instructions have following properties:
(a) Both the instructions are 1-byte instruction.
(b) Both affect the contents of the specified register.
(c) Only CY flag is unaffected, all other flags are altered. This is because these instructions also
involve other registers which cannot directly affect the status flag register. The status of the
flags is determined by the result of an operation; in most instances, the result is in the
accumulator. In increment (INR) operation, results can be in register other than the
accumulator.
The ADD, ADI instructions perform addition of register or 8-bit with the contents of the
Accumulator. If the sum is larger than 8-bits, it sets the carry flag.
Key Points about Arithmetic Operation:
1. In all arithmetic operations, one operand is the contents of the Accumulator.
2. The result of these operations is also stored in the Accumulator. This replaces the previous
contents of Accumulator with current one.
3. The contents of source register are not changed.
4. If the sum is larger than 8-bit then the carry flag (CY) is set.
5. The subtraction is performed by 2’s complement method.
6. If the result of subtraction is a negative number then the carry flag is set and the result is
represented in the 2’s complement form.
7. Carry flag is affected both in addition and subtraction. For subtraction CY is called Borrow
flag.
8. Sign flag (S) is ignored, when unsigned arithmetic operations are done.
40 LOVELY PROFESSIONAL UNIVERSITY