You are on page 1of 38

Microprocessors and

Microcontrollers (EC3L007)

Instruction set of 8085 – Part 2


Arithmetic Instructions

2
Arithmetic Instructions

• These instructions perform the operations like:

• Addition

• Subtraction

• Increment

• Decrement

[27/08/2020, IIT BBS] | [Srinivas Boppu] | [SES] | [EC3L007] 3


Arithmetic Instructions
• The arithmetic operations Add and Subtract are performed in
relation to the contents of the accumulator.

• However, the Increment or the Decrement operations can be


performed in any register.

• These arithmetic instructions ( except INR and DCR)


• Assume implicitly that the accumulator is one of the
operands.
• Modify all the flags according to the data conditions of the
result.
• Place the result in the accumulator.
• Do not affect the contents of the operand register.
[27/08/2020, IIT BBS] | [Srinivas Boppu] | [SES] | [EC3L007] 4
Arithmetic Instructions
• The instructions INR and DCR

• Affect the contents of the specified register.

• Affect all flags except the CY flag.

[27/08/2020, IIT BBS] | [Srinivas Boppu] | [SES] | [EC3L007] 5


Addition

• Any 8-bit number, or the contents of register, or the contents


of memory location can be added to the contents of
accumulator.

• The result (sum) is stored in the accumulator.

• No two other 8-bit registers can be added directly.

• Example: The contents of register B cannot be added directly


to the contents of register C.

[27/08/2020, IIT BBS] | [Srinivas Boppu] | [SES] | [EC3L007] 6


Subtraction

• Any 8-bit number, or the contents of register, or the contents


of memory location can be subtracted from the contents of
accumulator.

• The result is stored in the accumulator.

• Subtraction is performed in 2’s complement form.

• If the result is negative, it is stored in 2’s complement form.

• No two other 8-bit registers can be subtracted directly.

[27/08/2020, IIT BBS] | [Srinivas Boppu] | [SES] | [EC3L007] 7


Increment / Decrement

• The 8-bit contents of a register or a memory location can be


incremented or decremented by 1.

• The 16-bit contents of a register pair can be incremented or


decremented by 1.

• Increment or decrement can be performed on any register or a


memory location.

[27/08/2020, IIT BBS] | [Srinivas Boppu] | [SES] | [EC3L007] 8


Arithmetic Instructions

Opcode Operand Description


ADD R Add register or memory to
M accumulator
• The contents of register or memory are added to the contents
of accumulator.

• The result is stored in accumulator.

• If the operand is memory location, its address is specified by


H-L pair.

• All flags are modified to reflect the result of the addition.

• Example: ADD B or ADD M


[27/08/2020, IIT BBS] | [Srinivas Boppu] | [SES] | [EC3L007] 9
Example:

[27/08/2020, IIT BBS] | [Srinivas Boppu] | [SES] | [EC3L007] 10


Example:

[27/08/2020, IIT BBS] | [Srinivas Boppu] | [SES] | [EC3L007] 11


Arithmetic Instructions

Opcode Operand Description


ADI 8-bit data Add immediate to accumulator

• The 8-bit data is added to the contents of accumulator.

• The result is stored in accumulator.

• All flags are modified to reflect the result of the addition.

• Example: ADI 35H

[27/08/2020, IIT BBS] | [Srinivas Boppu] | [SES] | [EC3L007] 12


Example:

• The addition of 4AH and 35H does not generate a carry and
will reset the previous Carry flag .

• Therefore, in adding numbers, it is necessary to count how


many times the CY flag is set.
[27/08/2020, IIT BBS] | [Srinivas Boppu] | [SES] | [EC3L007] 13
Arithmetic Instructions
Opcode Operand Description
ADC R Add register or memory to
M accumulator with carry
• The contents of register or memory and Carry Flag (CY) are
added to the contents of accumulator.

• The result is stored in accumulator.

• If the operand is memory location, its address is specified by


H-L pair.

• All flags are modified to reflect the result of the addition.

• Example: ADC B or ADC M


[27/08/2020, IIT BBS] | [Srinivas Boppu] | [SES] | [EC3L007] 14
Example:

[27/08/2020, IIT BBS] | [Srinivas Boppu] | [SES] | [EC3L007] 15


Arithmetic Instructions

Opcode Operand Description


ACI 8-bit data Add immediate to accumulator
with carry

• The 8-bit data and the Carry Flag (CY) are added to the
contents of accumulator.

• The result is stored in accumulator.

• All flags are modified to reflect the result of the addition.

• Example: ACI 45 H

[27/08/2020, IIT BBS] | [Srinivas Boppu] | [SES] | [EC3L007] 16


Arithmetic Instructions
Opcode Operand Description
SUB R Subtract register or memory from
M accumulator

• The contents of the register or memory location are subtracted


from the contents of the accumulator.
• The result is stored in accumulator.
• If the operand is memory location, its address is specified by
H-L pair.
• All flags are modified to reflect the result of subtraction.
• Example: SUB B or SUB M

[27/08/2020, IIT BBS] | [Srinivas Boppu] | [SES] | [EC3L007] 17


Example:

CASE 1

[27/08/2020, IIT BBS] | [Srinivas Boppu] | [SES] | [EC3L007] 18


Example:

CASE 2

[27/08/2020, IIT BBS] | [Srinivas Boppu] | [SES] | [EC3L007] 19


Example:
• The 8085 perform 2’s complement subtraction. After
subtraction, it will complement the carry alone.

• In 2’s complement subtraction, if CF=1, then the result is


positive and if CF=0, then the result is negative.

• In 8085, the carry is complemented after subtraction;


therefore, if CF=0, then the result is positive and if CF=1, then
the result is negative. If the result is negative, then it is in 2’s
complement form.

[27/08/2020, IIT BBS] | [Srinivas Boppu] | [SES] | [EC3L007] 20


Arithmetic Instructions

Opcode Operand Description


SUI 8-bit data Subtract immediate from
accumulator

• The 8-bit data is subtracted from the contents of the


accumulator.
• The result is stored in accumulator.
• All flags are modified to reflect the result of subtraction.
• Example: SUI 45 H
[27/08/2020, IIT BBS] | [Srinivas Boppu] | [SES] | [EC3L007] 21
Arithmetic Instructions
Opcode Operand Description
SBB R Subtract register or memory from
M accumulator with borrow
• The contents of the register or memory location and Borrow
Flag (i.e. CY) are subtracted from the contents of the
accumulator.
• The result is stored in accumulator.
• If the operand is memory location, its address is specified by
H-L pair.
• All flags are modified to reflect the result of subtraction.
• Example: SBB B or SBB M
[27/08/2020, IIT BBS] | [Srinivas Boppu] | [SES] | [EC3L007] 22
Arithmetic Instructions

Opcode Operand Description


SBI 8-bit data Subtract immediate from
accumulator with borrow

• The 8-bit data and the Borrow Flag (i.e. CY) is subtracted
from the contents of the accumulator.

• The result is stored in accumulator.

• All flags are modified to reflect the result of subtraction.

• Example: SBI 45 H
[27/08/2020, IIT BBS] | [Srinivas Boppu] | [SES] | [EC3L007] 23
Arithmetic Instructions

Opcode Operand Description


DAD Reg. pair Add register pair to H-L pair
( Double Addition )

• The 16-bit contents of the register pair are added to the


contents of H-L pair.
• The result is stored in H-L pair.
• If the result is larger than 16 bits, then CY is set.
• No other flags are changed.
• Example: DAD B

[27/08/2020, IIT BBS] | [Srinivas Boppu] | [SES] | [EC3L007] 24


Arithmetic Instructions

Opcode Operand Description


DAA - Accumulator contents are
changed from a binary value to
two 4-bit BCD digits.

• After an addition instruction

1. If the lower nibble (4 bits) is greater than 9, or if AC=1, add


0110 (6) to the lower 4 bits
2. If the upper nibble is greater than 9, or if CY=1, add 0110
(6) to the upper 4 bits

[27/08/2020, IIT BBS] | [Srinivas Boppu] | [SES] | [EC3L007] 25


Example:

[27/08/2020, IIT BBS] | [Srinivas Boppu] | [SES] | [EC3L007] 26


Arithmetic Instructions

Opcode Operand Description


INR R Increment register or memory by
M 1

• The contents of register or memory location are incremented


by 1.

• The result is stored in the same place.

• If the operand is a memory location, its address is specified by


the contents of H-L pair.

• Example: INR B or INR M


[27/08/2020, IIT BBS] | [Srinivas Boppu] | [SES] | [EC3L007] 27
Example:

[27/08/2020, IIT BBS] | [Srinivas Boppu] | [SES] | [EC3L007] 28


Example:

[27/08/2020, IIT BBS] | [Srinivas Boppu] | [SES] | [EC3L007] 29


Arithmetic Instructions

Opcode Operand Description


DCR R Decrement register or memory
M by 1

• The contents of register or memory location are decremented


by 1.

• The result is stored in the same place.

• If the operand is a memory location, its address is specified by


the contents of H-L pair.

• Example: DCR B or DCR M


[27/08/2020, IIT BBS] | [Srinivas Boppu] | [SES] | [EC3L007] 30
Example:

[27/08/2020, IIT BBS] | [Srinivas Boppu] | [SES] | [EC3L007] 31


Example:

[27/08/2020, IIT BBS] | [Srinivas Boppu] | [SES] | [EC3L007] 32


Arithmetic Instructions

Opcode Operand Description


INX R Increment register pair by 1

• The contents of register pair are incremented by 1.

• The result is stored in the same place.

• Example: INX H

[27/08/2020, IIT BBS] | [Srinivas Boppu] | [SES] | [EC3L007] 33


Example:

[27/08/2020, IIT BBS] | [Srinivas Boppu] | [SES] | [EC3L007] 34


Arithmetic Instructions

Opcode Operand Description


DCX R Decrement register pair by 1

• The contents of register pair are decremented by 1.

• The result is stored in the same place.

• Example: DCX H

[27/08/2020, IIT BBS] | [Srinivas Boppu] | [SES] | [EC3L007] 35


Example:

[27/08/2020, IIT BBS] | [Srinivas Boppu] | [SES] | [EC3L007] 36


Thank you, done for today !!!
References
• Ramesh Gaonkar, “Microprocessor, Architecture,
Programming, & Applications with the 8085 6/e”

• Various online resources.

• Reading:
Chapter 6 & 7, Ramesh Gaonkar

[27/08/2020, IIT BBS] | [Srinivas Boppu] | [SES] | [EC3L007] 38

You might also like