ARITHMATIC OPERATIONS
IN 8085 MICROPROCESSOR
B.RAMA PRABHA
ASSISTANT PROFESSOR,
DEPARTMENT OF COMPUTER SCIENCE,
K.C.S.KASI NADAR COLLEGE OF ARTS & SCIENCE,
CHENNAI-21 aa ;ARITHMETIC OPERATIONS
The 8085 microprocessor performs various arithmetic operations such as addition,
subtraction, increment and decrement operations. These arithmetic operations ha’
following mnemonics. ¥
* ADD - Add (Add the content of a register) q
“> ADI-Add Immediate (Add 8 bit data)
** SUB — Subtract (Subtract the content of a register)
“+ SUI — Subtract Immediate (subtract 8 bit data)
“> INR — Increment (Increase the content of register by 1)
* DCR — Decrement(Decrease the content of register by 1)Addition in 8085
* Any 8-bit value, or the contents of any register, or even the contents
memory location pointed by HL pair, can be summed up with the
contents of the accumulator register.
** The added value, i.e., the result is then stored in the accumulator registe
itself.
* This function cannot be be used for two other registers together — the
addition has to be performed with the accumulator being one of the
addends.
“> Thus, for example, the contents of, say, register C cannot be summed up
directly to the contents of register B.ADD
Add register to the
fi accumulator
ADD Add contents from the
a location pointed by the HL
pair (M) to the contents of the
accumulator
This is a 1 byte instruction,
As discussed earlier, the contents of any register or memory location are added to the
contents of the accumulator register. The corresponding sum is then saved in the
accumulator. If the second addend is a memory, its address is specified by the H-L pair, All
flags linked with the addition are updated with the result of the addition performed.
DD BADC(ADD WITH CARRY)
Add register to the
fi accumulator with cary
ADC ‘Add the content of the
a location pointed by the value
in the HL pair (M) to the
accumulator with carry.
This i
The only difference between the ADD and the ADC operations is that the ADC condition
considers the carry value as well. Thus, the Carry flag plays an important role and becomes
the third addend..
a | byte instruction.ADI(ADD IMMEDIATE WITH DATA)
Add immediate value to the
ADI &-bit immediate data accumulator
[Al < [A] + data
This is a 2 byte instruction.
The contents of the accumulator register are added with immediate 8-bit data using the ADT
instruction. The sum is thus stored in the accumulator. All flags are correspondingly
modified..DAD(ADD 16 BIT DATA)
‘Add contents of register pair
to contents of H-L pair. The
result is stored in the H-L
pair.
DAD Register pair
This is a 2 byte instruction.
The 16-bit contents of any 8085 register pair are added to the contents of the H-L register
pair. The result is also stored in the H-L pair. The carry flag is also updated with the result of
the addition operation. No other flag bits are affected.Subtraction in 8085
Any 8-bit value, or the contents of any register, or even the contents of
memory location can be subtracted from the contents of the accumulat«
register.
The difference of this operation is stored in the accumulator.
The subtraction is performed in 2’s complement form. (You can revisit
the concept of 2’s complement over here.)
Also, if the result of the subtraction is negative, it is stored in its 2’s
complement form.
Similar to the addition operation, no two 8-bit registers can be subtracted
directly, unless it is subtracted from the accumulator.SUB(SUBTRACT TO THE REGISTER)
R Subtract register from the
accumulator
SUB Subtract contents of the
M location pointed by HL pair
(M) from the accumulator
This is a | byte instruction.
The contents of any register or memory location are subtracted from the contents of the
accumulator register. The corresponding difference is then saved in the accumulator register
If the operand is a memory, its address is specified by the H-L pair. All flags linked with the
subtraction operation are updated with the result of the operation performed.
ple: SUBBSBB(SUBTRACT TO THE REGISTER WITH BORROW)
Subtract register from the
R accumulator with borrow
considered
SBB Subtract the contents of the
location pointed by the HL
pair (M) from the accumulator
with borrow considered
This is a 1 byte instruction.
The contents of any register or memory location AND the borrow value (the CY flag in this
case) are subtracted from the contents of the accumulator register. The corresponding
difference aved in the accumulator register. If the operand is a memory, its address is
specified by the H-L pair.SUI(SUBTRACT IMMEDIATE WITH DATA)
Meer Ske ecu)
Dee
This is a 2 byte instruction.
The contents of the accumulator register are subtracted with immediate 8-bit data usin;
SUI instruction. The answer is thus stored in the accumulator. All flags are correspondit
modified to reflect the difference
Example : SUI 04HSBI(SUBTRACT IMMEDIATE WITH BORROW)
Subtract an immediate value
SBI 8-bit immediate data from the accumulator with
Borrow considered
This is a2 byte instruction.
The contents of the accumulator register are subtracted with immediate 8-bit data AND the
borrow value (specified by the CY flag) using the SBI instruction. The answer is thus stored
in the accumulator. All flags are correspondingly modified to reflect the difference.SBI(SUBTRACT IMMEDIATE WITH BORROW)
Subtract an immediate value
SBI 8-bit immediate data from the accumulator with
Borrow considered
This is a2 byte instruction.
The contents of the accumulator register are subtracted with immediate 8-bit data AND the
borrow value (specified by the CY flag) using the SBI instruction. The answer is thus stored
in the accumulator. All flags are correspondingly modified to reflect the difference.Increment or Decrement in 8085
Every register or memory location holds contents of size 8-bits.
contents can be incremented and/or decremented by a value of 1.
If we consider register pairs, then the 16-bit contents can also be
incremented or decremented by a value of 1.INR(INCREMENT BY 1)
Increment Register contents
by one
INR Increment the content at the
M memory location pointed by
the HL pair by one
This is a 1 byte instruction.
The INR command is used to increment/increase the contents of a register or of the data at
the location pointed by HL pair(M) by one. The result is stored in the same location itself, In
the case of the operand being M, the value at the memory location given by the HL pair is
incremented by one. The value in the HL register pair does not change.INX(INCREMENT REGISTER PAIR BY -
Ue od
The Operand De
"This is a | byte instruction.
"The INX instruction increments the contents of a register-pair by the value of one. The
is stored in the same place itself.
Example : INX HDCR(DECREMENT BY 1)
Decrement Register contents
by one
DCR Decrement the content at the
M memory location pointed by
the HL pair by one
This is a 1 byte instruction.
The DCR command is used to decrement/decrease the contents of a register or of a memory
location by the value of one. The result after this operation is stored in the same location
itself. If the operand happens to be a memory location, its address is then specified by the
contents of the H-L pair.DCX(DECREMENT REGISTER PAIR BY
ke ed Mee eli) De al
This is a | byte instruction.
The DCX instruction decrements the contents of the register-pair by the value of one.
result is stored in the same place itself.
Example : DCX H é