8XC251SA, SB, SP, SQ USER’S MANUAL
A-96
MOVC A,@A+<base–reg>
Function: Move code byte
Description: Loads 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 the 16 LSBs of the data pointer or 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.
Flags:
Example: The accumulator contains a number between 0 and 3. The following instruction sequence
translates the value in the accumulator to one of four values defined by the DB (define byte)
directive.
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 separated the MOVC from the table, the
corresponding number would be added to the accumulator instead.
Variations
MOVC A,@A+PC
Binary Mode Source Mode
Bytes: 11
States: 66
Hex Code in: Binary Mode = [Encoding]
Source Mode = [Encoding]
Operation: MOVC
(PC) (PC) + 1
(A)((A) + (PC))
MOVC A,@A+DPTR
Binary Mode Source Mode
Bytes: 11
States: 66
CY AC OV N Z
—————
RELPC: INC
MOVC
RET
DB
DB
DB
DB
A
A,@A+PC
66H
77H
88H
99H
[Encoding] 1 0 0 0 0 0 1 1
[Encoding] 1 0 0 1 0 0 1 1