This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Newbie dumb question

Why, when I use the Simulator on this code, does A return as 0 when it should be 3?

MAIN:
        NOP
        MOV     DPTR, #CommandTable
        MOVX    A, @DPTR                ; Get the offset
        MOV     DPTR, #Subroutines
        JMP     @A+DPTR

CommandTable:
        DB Low(GetStatus - Subroutines)

Subroutines:
SetStatus:
        NOP
        NOP
        RET
GetStatus:
        NOP
        NOP
        RET

END

Thanks for your help.

Steve

Parents
  • Is CommandTable in CODE space (as I would suspect) or in XDATA space?

    The MOVX is accessing XDATA space, not CODE. Have you configured simulator (or hardware) for common access? Probably not, at least for the simulator.

    If you get that logic right, then I concur that the answer should be 3.

Reply
  • Is CommandTable in CODE space (as I would suspect) or in XDATA space?

    The MOVX is accessing XDATA space, not CODE. Have you configured simulator (or hardware) for common access? Probably not, at least for the simulator.

    If you get that logic right, then I concur that the answer should be 3.

Children