8051 Arithmetic Instructions
1) Students should visit first: https://www.tutorialspoint.com/arithmetic-group-in-8051,
“Arithmetic group in 8051”.
2) Binary addition and subtraction: i) Write a program to add two 8-bit numbers, and
send the result to port P1. ii) Write a program to perform 8-bit subtraction of numbers
stored in internal RAM, and send the result to port P1.
3) Addition of two 16 numbers: Add a 16-bit number stored in internal RAM locations
[31H:30H] to another number stored in internal RAM locations [33H:32H] and store
the result in internal RAM locations [35H:34H]
4) Addition of 16-bit number with 32-bit number: Add a 16-bit (2 byte) number stored
in internal RAM locations [31H:30H] to another 32-bit number (4 byte) stored in
internal RAM locations [35H-32H] and store the result in internal RAM locations [39H-
36H]
5) BCD addition – add two BCD numbers 05H + 05H to produce result of 10H.
Table 1. Arithmetic Instructions
Mnemonics Instruction Execution time,
size in MCycles
Bytes
ADD A, Rn 1 1
ADD A, a8 2 1
ADD A, @Ri 1 1
ADD A, #d8 2 1
ADDC A, Rn 1 1
ADDC A, a8 2 1
ADDC A, @Ri 1 1
ADDC A, #d8 2 1
SUBB A, Rn 1 1
SUBB A, a8 2 1
SUBB A, @Ri 1 1
SUBB A, #d8 2 1
INC A 1 1
INC Rn 1 1
INC a8 2 1
INC @Ri 1 1
DEC A 1 1
DEC Rn 1 1
DEC a8 2 1
DEC @Ri 1 1
INC DPTR 1 2
MUL AB 1 4
DIV AB 1 4
DA A 1 1