I have this code in 8051 assembler :
    MOV A,#04H
    RL A
    MOVC A,@A+PC
    SJMP Cont
Cont:   DB 10H, 20H, 30H, 40H, 50H, 60H, 70H, 80H
The question is that what is value of A after these instructions are executed; the answer was that A holds the value (A)=70H.
I have searched about MOV and RL instructions and I understood,but it is unclear to me,what do the rest of instructions and how did we get the value of register A?
                        
MOVC A, @A+PCmoves 8-bit of data from the program memory (MOVC stands for "MOVe Code" or similar) at the address given by A+PC and stores it into the accumulator.The presence of the
@is eloquent, it is used to denote a register indirect addressing mode, the full expression@A+PCspecify that it is actually an indexed addressing mode.Note that:
The
PChas already been incremented by the time it is used to do the memory access.Since
MOVC A, @A+PCis 1 byte long, its semantic is:In the symbolic expression
@A+PC, the@is meant to have less precedence than the+, so it should be understood as@(A+PC).SJMPis a Short JuMP and it simply execution to the target specified as the operand.MOV A, #04Hmoves the value 04h intoA.Here the symbol "#" denotes immediate addressing mode.
RL Asimply rotate rightAby one position.Let's assume the code starts at X, then
Simply put, when
MOVC A, @A+PCis executed, a byte is read from the address of the next instruction added by 8 (the value inA).Since
SJMP, the next instruction, is 1 byte long, it is like reading 7 bytes fromCont.The seventh item of
Contis 70h.