click below
click below
Normal Size Small Size show me how
3150 - Module #4
Adressing Mode
Question | Answer |
---|---|
What addressing modes does 8051 support? | 8051 supports: Register, Implied, Direct, Indirect, Immediate, Relative, Absolute, Long, and Indexed addressing modes. |
For register addressing, explain the instruction format. | You have 5 bits for the op.code and the 3 least significant bits to specify the register (1 byte). |
What addressing mode represents the following instruction? ADD A, R7 | This is register addressing mode. |
Is this a valid instruction? Why or why not? MOV R4, R7 | No, you can't move data between Rn registers. You must first move data into the accumulator then into the desired register. |
Is this a valid instruction? Why or why not? MOV DPTR, A | No, the source and destination registers must match in size. |
What addressing mode represents the following instruction? MOV A, 7 | This is register addressing mode. |
What addressing mode represents the following instructions? INC DPTR - and - MUL AB | This is implied addressing mode. |
For implied addressing, explain the instruction format. | When referring to specific registers, you don't need address bits. Therefore, only op.code indicates the register involved. |
What is direct addressing mode used for? | Direct addressing mode allows access to any on-chip variable or hardware register. |
For direct addressing, explain the instruction format. | You have 1 byte for op.code and 1 byte appended for the location being used. Therefore, direct addressing is 2 bytes. |
What addressing mode represents the following instruction? MOV P1, A | This is direct addressing mode. |
For indirect addressing, explain the instruction format. | You have 1 byte in total for indirect addressing, 7 bits of op.code and the least significant bit specifies which address (R0 or R1). |
Explain how indirect addressing mode works. | In 8051, R0 and R1 can essentially be a 'pointer' register. Indirect addressing is identified by "@" with either R0 or R1 following. |
What addressing mode represents the following instruction? MOV A, @R1 | This is indirect addressing. |
Explain how immediate addressing mode works. | Identified by the "#" symbol, the operand may be a numeric constant, a symbolic variable, or an arithmetic expression using constants, symbols, and operators. The assembler calculates the expression and substitutes the result into the instruction. |
For immediate addressing, explain the instruction format. | You have 1 byte for the op.code and 1 byte for the immediate data. |
Is this a valid instruction? Why or why not? MOV DPTR, #68975 | No because 68975 > 65535. |
What addressing mode represents the following instruction? MOV A, #12 | This is immediate addressing mode. |
How long is the following instruction? What's so special about this instruction? MOV DPTR, #8000H | This is a 3-byte instruction with a 16-bit constant. When using the data pointer, we need a 16-bit constant. |
For relative addressing, explain the instruction format. | You have 1 byte for op.code and 1 byte for the relative offset (positive or negative). |
When do we use relative addressing? | We use relative addressing mode with certain jump instructions. |
Explain how relative addressing mode works. | A relative address, an 8-bit signed value, is added to the contents of the PC. This forms the address of the next instruction to be fetched and executed. |
What's the jump range for relative addressing? | The range for jumping is -128 to +127 locations. |
For absolute addressing, explain the instruction format. | This is a 2-byte instruction, 11 bits for the destination address and 5 bits for the op.code. You have the 3 most significant bits for the destination address, 5 bits for the op.code, and the 8 least significant bits are also the destination address. |
When do we use absolute addressing? | We use absolute addressing for ACALL and AJMP instructions. We use absolute addressing to jump anywhere in external memory (64K bytes) |
Explain how absolute addressing mode works. | For absolute addressing, these 2-byte instructions allow branching within the current 2K page of code memory. |
What's the jump range for absolute addressing? Why? | You can jump anywhere within the same 2K page of code memory. This is because the upper 5 bits of the destination address are the current value of the upper 5 bits of the PC. |
For long addressing, explain the instruction format. | You have 1 byte for op.code and 2 bytes for the destination address. This results in a 3 byte long instruction. |
When do we use long addressing? | We use long addressing for LCALL and LJMP instructions. |
For index addressing, explain the instruction format. | This is a 1 byte instruction which is made up of the effective address. The effective address is determined by adding the base register (PC or DPTR) to the offset (accumulator). |
Explain how index addressing mode works. | Index addressing uses a base register (either the PC or DPTR) and an offset (ACC) in forming the effective addressing. |
When do we use index addressing? | We use index addressing for JMP and MOVC instructions. |
What must be within the same 2K page of code memory for absolute addressing? | The next instruction after the branch and the destination instruction must be within the same 2K page of code memory. |
How many 2K pages does 8051 have? | 32. This implies that there's 64K memory in 8051. |
MOV R5, R7 is ____________. | illegal |
Direct addressing allows access to _____________. | any on-chip variable or hardware register |
In 8051 assembly language, indirect addressing is identified as __________. | @ |
Relative addressing allows a jump in the range of ___________. | -128 to +127 bytes |
Absolute addressing is used with _______ and _________ instructions. | AJMP, ACALL |
Long addressing is used with _________ and _________ instructions. These instructions are _______ bytes long. | LCALL, LJMP, 3 |
Index addressing uses ________ and ________ as a base register. | program counter, data pointer |
MOV A, 55H means _______________________________________. | moves the value at 55H into the accumulator |
MOV A, #55H means ______________________________________. | moves the value 55H into the accumulator |
Direct addressing is a ______ bytes instruction. | 2 |