# Arithmetic Instructions 8085

Dec 14, 2020

Arithmetic Instructions:
The different instructions under this category are listed in table below:

 1 ADDReg/Mem Adds accumulator with Reg or Memory word Acc ← Acc + Reg/Mem 2 ADC Reg/Mem Adds acc with carry to Reg or Memory Acc ← Acc + Reg/Mem + Cy 3 ADI 8-bit data Adds 8-bit immediate data to Accumulator Acc ← Acc + 8-bit data 4 ACI 8-bit data Adds with carry 8-bit data to Accumulator Acc ← Acc + 8-bit data + Cy 5 DAD Rp Add Register pair to HL HL ← HL + Rp 6 SUB Reg/Mem Subtract reg/Mem from accumulator Acc ← Acc + Reg/Mem 7 SBB Reg / Mem Subtract reg/Mem from acc with borrow Acc ← Acc – Reg/Mem – Cy 8 SUI 8-bit data subtract 8-bit data from acc Acc ← Acc – 8-bit data 9 SBI 8-bit data subtract 8-bit data from acc with borrow Acc ← Acc – 8-bit data – Cy 10 INR Reg / Mem Increments the content of Register or Memory 11 DCR Reg / Mem Increments the content of Register or Memory 12 INX Reg pair Increments content of a register pair 13 DCX Reg Pair Decrements the content of Register Pair 14 DAA Decimal Adjust Accumulator, when executed converts the hex result in Decimal

Example programs:

Ex-1: WAP in AL to add two 8-bit numbers

MVI A, 55h

MVI B, 45h

STA 2050h

HLT

Ex-2: WAP in AL to fetch two data bytes from the memory, add them and store the result back to memory.

Answer: Assuming that the data is at memory location 2020h and 2021h and after addition it is to be stored at memory location 2050h

LXI H, 2020h

MOV A, M

INX H

STA 2050h

HLT

Ex-3: WAP in AL to add two 16-bit numbers and store the result in memory location 2020h(low byte) and at 2021h(high Byte)

Answer: Assuming that the numbers are known, so we can use immediate addressing mode to load the HL and DE registers with 16-bit immediate data. We can make used of DAD instruction to add two 16-bit numbers. The requirement of this instruction is that one number must be in HL, and another:

LXI H, 2345H

LXI D, 1234H

XCHG

LXI H, 2020H

MOV M, E

INX H

MOV M, D

HLT

SECOND METHOD

Assuming that the two 16-bit numbers are stored in memory at locations 2020,2021 and 2nd number at 2022h and 2023h. The low byte of two umbers are at 2020h and 2022h and the high byte of two numbers are at location2021h and 2023h. We would need two pointers to point to LSB of two numbers and since the memory active pointer is always the HL pair, we will need XCHG instruction to move to 2nd number.

LXI H, 2020h

LXI D, 2022h

MOV A, M

XCHG

STA 2030h

INX H

INX D

XCHG

MOV A, H

XCHG

STA 2051h

HLT