Wednesday, March 2, 2016

8051 MOVC Instruction

Move Code

InstructionMOVC A,@A+ base-reg
FunctionMove Code byte
DescriptionThe MOVC instructions load the Accumulator with a code byte or constant from program memory. The address of the byte fetched is the sum of the original unsigned 8-bit Accumulator contents and the contents of a 16-bit base register, which may be either the Data Pointer or the PC. In the latter case, the PC is incremented to the address of the following instruction before being added with the Accumulator; otherwise the base register is not altered. Sixteen-bit addition is performed so a carry-out from the low-order eight bits may propagate through higher-order bits.
ExampleA value between 0 and 3 is in the Accumulator. The following instructions will translate the value in the Accumulator to one of four values defined by the DB (define byte) directive.
REL_PC: INC A
MOVC A,@A+PC
RET
DB 66H
DB 77H
DB 88H
DB 99H
If the subroutine is called with the Accumulator equal to 01H, it returns with 77H in the Accumulator. The INC A before the MOVC instruction is needed to “get around” the RET instruction above the table. If several bytes of code separate the MOVC from the table, the corresponding number is added to the Accumulator instead.
VariantsMOVC A,@A+DPTR
MOVC A,@A+PC

InstructionMOVC A,@A+DPTR
Bytes1
Cycles2
Encoding1 0 0 1 0 0 1 1
OperationA = (A + DPTR)
Flags AffectedC AC F0 RS1 RS0 OV P
ExampleMOVC A, @A+DPTR
Bytes: Number of bytes required to encode the instruction.
Cycles: Number of instruction cycles required to execute the instruction. Note that there are 12 oscillator cycles to one instruction cycle on a standard 8051.
Encoding: Lists the byte encoding for the instruction.
Operation: Lists, step-by-step, the operations performed by the instruction.
Flags Affected: are highlighted in Bold

InstructionMOVC A,@A+PC
Bytes1
Cycles1
Encoding1 0 0 0 0 0 1 1
OperationPC = PC + 1
A = (A+PC)
Flags AffectedC AC F0 RS1 RS0 OV P
ExampleMOVC A, @A+PC
Bytes: Number of bytes required to encode the instruction.
Cycles: Number of instruction cycles required to execute the instruction. Note that there are 12 oscillator cycles to one instruction cycle on a standard 8051.
Encoding: Lists the byte encoding for the instruction.
Operation: Lists, step-by-step, the operations performed by the instruction.
Flags Affected: are highlighted in Bold



Related topics:
8051 Data Transfer Instructions   |   8051 MOV Instruction   |   8051 MOVX Instruction   |   8051 PUSH Instruction   |   8051 POP Instruction   |   8051 XCH Instruction   |   8051 XCHD Instruction

List of topics: 8051

No comments:

Post a Comment