×
Nothing in the world is more common than unsuccessful people with talent.
--Your friends at LectureNotes
Close

Note for Microcontroller and Applications - MCA By Swapnil Kaware

  • Microcontroller and Applications - MCA
  • Note
  • 417 Views
  • Uploaded 1 month ago
Swapnil Kaware
Swapnil Kaware
0 User(s)
Download PDFOrder Printed Copy

Share it with your friends

Leave your Comments

Text from page-1

Instruction Set of 8051 Microcontroller Depending on operation they perform, all instructions are divided in several groups:      Arithmetic Instructions Branch Instructions Data Transfer Instructions Logic Instructions Bit-oriented Instructions The first part of each instruction, called MNEMONIC refers to the operation an instruction performs (copy, addition, logic operation etc.). Mnemonics are abbreviations of the name of operation being executed. For example:  INC R1 - Means: Increment register R1 (increment register R1);  LJMP LAB5 - Means: Long Jump LAB5 (long jump to the address marked as LAB5);  JNZ LOOP - Means: Jump if Not Zero LOOP (if the number in the accumulator is not 0, jump to the address marked as LOOP); The other part of instruction, called OPERAND is separated from mnemonic by at least one whitespace and defines data being processed by instructions. Some of the instructions have no operand, while some of them have one, two or three. If there is more than one operand in an instruction, they are separated by a comma. For example:  RET - return from a subroutine;  JZ TEMP - if the number in the accumulator is not 0, jump to the address marked as TEMP;  ADD A,R3 - add R3 and accumulator;  CJNE A,#20,LOOP - compare accumulator with 20. If they are not equal, jump to the address marked as LOOP; 1|Page 8051 Microcontroller Notes By Er. Swapnil V. Kaware (svkaware@yahoo.co.in)

Text from page-2

Arithmetic instructions Arithmetic instructions perform several basic operations such as addition, subtraction, division, multiplication etc. After execution, the result is stored in the first operand. For example: ADD A,R1 - The result of addition (A+R1) will be stored in the accumulator. ARITHMETIC INSTRUCTIONS Mnemonic Description Byte Cycle ADD A,Rn Adds the register to the accumulator 1 1 ADD A,direct Adds the direct byte to the accumulator 2 2 ADD A,@Ri Adds the indirect RAM to the accumulator 1 2 ADD A,#data Adds the immediate data to the accumulator 2 2 ADDC A,Rn Adds the register to the accumulator with a carry flag 1 1 ADDC A,direct Adds the direct byte to the accumulator with a carry flag 2 2 ADDC A,@Ri Adds the indirect RAM to the accumulator with a carry flag 1 2 ADDC A,#data Adds the immediate data to the accumulator with a carry flag 2 2 SUBB A,Rn Subtracts the register from the accumulator with a borrow 1 1 SUBB A,direct Subtracts the direct byte from the accumulator with a borrow 2 2 SUBB A,@Ri Subtracts the indirect RAM from the accumulator with a borrow 1 2 SUBB A,#data Subtracts the immediate data from the accumulator with a borrow 2 2 INC A Increments the accumulator by 1 1 1 INC Rn Increments the register by 1 1 2 2|Page 8051 Microcontroller Notes By Er. Swapnil V. Kaware (svkaware@yahoo.co.in)

Text from page-3

INC Rx Increments the direct byte by 1 2 3 INC @Ri Increments the indirect RAM by 1 1 3 DEC A Decrements the accumulator by 1 1 1 DEC Rn Decrements the register by 1 1 1 DEC Rx Decrements the direct byte by 1 1 2 DEC @Ri Decrements the indirect RAM by 1 2 3 INC DPTR Increments the Data Pointer by 1 1 3 MUL AB Multiplies A and B 1 5 DIV AB Divides A by B 1 5 DA A Decimal adjustment of the accumulator according to BCD code 1 1 Branch Instructions There are two kinds of branch instructions: Unconditional jump instructions: upon their execution a jump to a new location from where the program continues execution is executed. Conditional jump instructions: a jump to a new program location is executed only if a specified condition is met. Otherwise, the program normally proceeds with the next instruction. BRANCH INSTRUCTIONS Mnemonic Description Byte Cycle ACALL addr11 Absolute subroutine call 2 6 LCALL addr16 Long subroutine call 3 6 RET Returns from subroutine 1 4 3|Page 8051 Microcontroller Notes By Er. Swapnil V. Kaware (svkaware@yahoo.co.in)

Text from page-4

RETI Returns from interrupt subroutine 1 4 AJMP addr11 Absolute jump 2 3 LJMP addr16 Long jump 3 4 SJMP rel Short jump (from –128 to +127 locations relative to the following instruction) 2 3 JC rel Jump if carry flag is set. Short jump. 2 3 JNC rel Jump if carry flag is not set. Short jump. 2 3 JB bit,rel Jump if direct bit is set. Short jump. 3 4 JBC bit,rel Jump if direct bit is set and clears bit. Short jump. 3 4 JMP @A+DPTR Jump indirect relative to the DPTR 1 2 JZ rel Jump if the accumulator is zero. Short jump. 2 3 JNZ rel Jump if the accumulator is not zero. Short jump. 2 3 CJNE A,direct,rel Compares direct byte to the accumulator and jumps if not equal. Short jump. 3 4 CJNE A,#data,rel Compares immediate data to the accumulator and jumps if not equal. Short jump. 3 4 CJNE Rn,#data,rel Compares immediate data to the register and jumps if not equal. Short jump. 3 4 CJNE @Ri,#data,rel Compares immediate data to indirect register and jumps if not equal. Short jump. 3 4 DJNZ Rn,rel Decrements register and jumps if not 0. Short jump. 2 3 DJNZ Rx,rel Decrements direct byte and jump if not 0. Short jump. 3 4 NOP No operation 1 1 4|Page 8051 Microcontroller Notes By Er. Swapnil V. Kaware (svkaware@yahoo.co.in)

Lecture Notes