Arithmetic and logical instructions 8051 microcontroller

2,746 views 21 slides Apr 23, 2020
Slide 1
Slide 1 of 21
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21

About This Presentation

Explains the mnemonics for arithmetic and logical instructions in 8051 microcontroller


Slide Content

Arithmetic Logical Instructions for 8051 Microcontroller A.Usha Rani , Lecturer, Department of Physics and Electronics, St.Ann’s College for Women

ARITHMETIC INSTRUCTIONS These instructions perform arithmetic operations. The arithmetic operations modify Carry, Overflow and Auxiliary carry flags based on the result of the operation The status of the flags can be used a test conditions.

ADDITION The mnemonic for addition is ADD. ADD A, source //Add contents of A with operand source and store result in A All addressing modes can be used for this instruction. The register A is always the destination as well as one of the source operands.

ADD A, # data //Add contents of A with immediate data and store result in A ADD A, #10H // Add the value 10H to the contents of A and store the result in A ADD A,Rn //Add contents of A with contents of Rn and store result in A ADD A, R3 //Add contents of A with contents of register R3 and store result in A

ADD A, direct //Add contents of A with contents of address direct and store result in A ADD A, 45H //Add contents of A with contents of address 45 H and store result in A ADD A, @ Ri // Add contents of A with contents of address in Ri ADD A, @R0 // Add contents of A with contents of address in R0

SUBTRACTION The mnemonic is SUBB SUBB A, Source //Subtract the operand source from contents of A and store result in A

SUBB A, # data // Subtract immediate data and carry from A and store result in A SUBB A, #10H // Subtract immediate data 10H and carry from A and store result in A SUBB A,Rn //Subtract contents of Rn and carry from A and store result in A SUBB A, R3 //Subtract contents of R3 and carry from A and store result in A

SUBB A, direct // Subtract contents of address direct and carry from A and store result in A SUBB A, 45H // Subtract contents of address 45H and carry from A and store result in A SUBB A, @ Ri //Subtract contents and carry of address in Ri from A and store result in A SUBB A, R0 //Subtract contents and carry of address in R0 from A and store result in A

MULTIPLICATION Multiplication uses only the registers A and B as source and destination. MUL AB //Multiply the contents of A with B and put lower byte of result in A and higher byte of result in B.

DIVISION Division uses only the registers A and B as source and destination. The number in A is divided by the number in B. Quotient is placed in A and remainder is placed in B. DIV AB // Divide the contents of A with contents of B and result (quotient)in A and remainder in B.

INCREMENT Used to add 1 to a operand. Supports all addressing modes. No flags are effected. Useful to repeat the operations i.e to increment till the desired result is obtained. INC destination // Add 1 to the destination operand.

INC A //Increment the contents of A by 1 INC A //Increment the contents of A by 1 INC Rn // Increment the contents of Rn by 1 INC R3 // Increment the contents of R3 by 1 INC @ Ri // Increment the contents of address pointed by Ri by1 INC @R0 // Increment the contents of address pointed by R0 by1

INC Direct //Increment the contents of direct address by 1 INC 45H //Increment the contents of direct address 45H by 1 INC DPTR //Increment the contents of DPTR by 1 INC DPTR //Increment the contents of DPTR by 1

DECREMENT Used to subtract 1 from a operand. Supports all addressing modes. No flags are effected. Useful to repeat the operations i.e to increment till the desired result is obtained. DEC destination //Subtract 1 from destination operand

DEC A // Decrement the contents of A by 1 DEC A // Decrement the contents of A by 1 DEC Rn // Decrement the contents of Rn by 1 DEC R3 // Decrement the contents of R3 by 1 DEC @ Ri // Decrement the contents of address pointed by Ri by1 DEC @R0 // Decrement the contents of address pointed by R0 by1

DEC Direct // Decrement the contents of direct address by 1 DEC 45H // Decrement the contents of direct address by 1 DEC DPTR //Decrement the contents of DPTR by 1 DEC DPTR //Decrement the contents of DPTR by 1

LOGICAL INSTRUCTIONS 8051 supports the following logical operations AND OR EX_OR NOT

AND Operation ANL A,#data //Bitwise AND operation of A with data ANL A,Rn // Bitwise AND operation of A with Rn ANL A,@Ri //Bitwise AND operation of A with data pointed by Ri ANL A,direct // Bitwise AND operation of A with data in direct ANL direct, #data // Bitwise AND operation of data in direct with immediate data ANL direct, A // Bitwise AND operation of data in address direct with A

OR Operation ORL A,#data // Bitwise OR operation of A with data ORL A,Rn // Bitwise OR operation of A with Rn ORL A,@Ri // Bitwise OR operation of A with data pointed by Ri ORL A,direct // Bitwise OR operation of A with data in direct ORL direct, #data // Bitwise OR operation of data in direct with immediate data ORL direct, A // Bitwise OR operation of data in address direct with A

Ex-OR Operation XRL A,#data // Bitwise X-OR operation of A with data XRL A,Rn // Bitwise X-OR operation of A with Rn XRL A,@Ri // Bitwise X-OR operation of A with data pointed by Ri XRL A,direct // Bitwise X-OR operation of A with data in direct XRL direct, #data // Bitwise X-OR operation of data in direct with immediate data XRL direct, A // Bitwise X-OR operation of data in address direct with A

UNARY OPERATIONS XRL A,#data //Bitwise X-OR operation of A with data XRL A,Rn // Bitwise X-OR operation of A with Rn XRL A,@Ri //Bitwise X-OR operation of A with data pointed by Ri XRL A,direct // Bitwise X-OR operation of A with data in direct XRL direct, #data //Bitwise X-OR operation of data in direct with immediate data XRL direct, A // Bitwise X-OR operation of data in address direct with A