The document discusses different addressing modes of the 8051 microcontroller including immediate, register direct, memory direct, memory indirect, and indexed addressing. It also summarizes the main instruction sets of the 8051 including arithmetic, logical, data transfer, branching and looping, and bit manipulation instructions. Common instructions from each set are listed such as ADD, AND, MOV, JMP, SETB.
The document discusses different addressing modes of the 8051 microcontroller including immediate, register direct, memory direct, memory indirect, and indexed addressing. It also summarizes the main instruction sets of the 8051 including arithmetic, logical, data transfer, branching and looping, and bit manipulation instructions. Common instructions from each set are listed such as ADD, AND, MOV, JMP, SETB.
The document discusses different addressing modes of the 8051 microcontroller including immediate, register direct, memory direct, memory indirect, and indexed addressing. It also summarizes the main instruction sets of the 8051 including arithmetic, logical, data transfer, branching and looping, and bit manipulation instructions. Common instructions from each set are listed such as ADD, AND, MOV, JMP, SETB.
The document discusses different addressing modes of the 8051 microcontroller including immediate, register direct, memory direct, memory indirect, and indexed addressing. It also summarizes the main instruction sets of the 8051 including arithmetic, logical, data transfer, branching and looping, and bit manipulation instructions. Common instructions from each set are listed such as ADD, AND, MOV, JMP, SETB.
Download as PPT, PDF, TXT or read online from Scribd
Download as ppt, pdf, or txt
You are on page 1of 19
UNIT-5
Micro Controller Programming
and Applications 8051 ADDRESSING MODES Addressing Mode The CPU can access data in various ways, which are called addressing modes ◦ Immediate Addressing ◦ Register Direct Addressing ◦ Memory Direct Addressing ◦ Memory indirect Addressing ◦ Indexed Addressing The last three modes actually access memory Immediate Addressing Mode ◦ The data to be manipulated is given in the instruction itself ◦ The immediate data must be preceded by the sign, “#” ◦ Can load information into any registers, including 16-bit DPTR register ◦ EX: ADD A, #80H Register Direct Addressing Mode Use registers to hold the data to be manipulated EX : ADD A, R0
The source and destination registers must
match in size ◦ MOV DPTR,A will give an error R0-R7 are used in register direct addressing Memory Direct Addressing Mode It is most often used the direct addressing mode to access RAM locations 30 – 7FH ◦ The entire 128 bytes of RAM can be accessed ◦ ADD A, 74H ◦ This instruction adds the data in the accumulator to that stored in the memory address 74H Memory Indirect Addressing Mode The register containing the memory address of the data is specified in the instruction. Register specified is preceded by @ symbol Ex: ADD A, @R0 Value stored in the register R0 is the address of memory location of data to be fetched. Indexed Addressing Mode The instruction consists of two parts ◦ Base address ◦ Offset This type of addressing is useful in relative memory accessing and relative jumping Base address is stored in DPTR Offset value is stored in the accumulator Ex: MOVC A, @A+DPTR Useful in accessing lookup table data's Instruction set of 8051
8051 has simple instruction set in
different groups. There are: Arithmetic instructions Logical instructions Data transfer instructions Branching and looping instructions Bit Manipulation instructions Arithmetic instructions These instructions are used to perform various mathematical operations like addition, subtraction, multiplication, and division etc., ADD A, R1 // Add the content of register1to Accumulator ADDC A,#2 // Add 2 to accumulator with carry SUBB A,R2 // Subtract content of register2 from Accumulator Logical instructions The logical instructions are the instructions which are used for performing some operations like AND, OR, NOT, X-OR etc., on the operands. ANL A, Rn // AND register to accumulator ORL A, Rn // OR register to accumulator XRL A, Rn // Exclusive OR Reg to Acc CLR A // Clear Accumulator CPL A // Complement Accumulator Data Transfer Instructions These instruction are used to transfer the data from source operand to destination operand. All the store, move, load, exchange input and output instructions belong to this to this group. MOV A, Rn // Move Reg to Acc MOVX A,@DPTR // Move external RAM to Accumulator PUSH direct // PUSH direct byte on to stack POP direct // POP direct byte from stack Branch and Looping Instructions These instructions are used for both branching as well as looping. These instructions include conditional & unconditional jump or loop instructions. JC // Jump if carry equal to one JNC // Jump if carry equal to zero JB // Jump if bit equal to one JNB // Jump if bit equal to zero JBC // Jump if bit equal to one and clear bit LJMP addr//Jump to address Bit Manipulation instructions 8051 microcontroller handle bit data as well as byte. Internal data memory map of the 8051 has a bit addressable area also. ANL C, bit//C=C AND bit SETB C MOV C, bit