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
Can't you answer that question by single-stepping in the Simulator, and observing where the "unexpected" value comes from...?
Why do you think it should be 3?
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.
Yes, CommandTable is in CODE space. The books I have didn't tell me anything about XDATA space. Could you recommend a resource? Thanks for your help.
"XDATA" is Keil's name for the memory addressed by the DPTR and MOVX, and it is also widely used elsewhere.
For details of the Keil C51 address spaces, see: http://www.keil.com/support/man/docs/c51/c51_le_memareas.htm
For general details, see the so-called "bible" for the 8051:
Chapter 1 - 80C51 Family Architecture: www.nxp.com/.../80C51_FAM_ARCH_1.pdf
Chapter 2 - 80C51 Family Programmer's Guide and Instruction Set: www.nxp.com/.../80C51_FAM_PROG_GUIDE_1.pdf
Chapter 3 - 80C51 Family Hardware Description: www.nxp.com/.../80C51_FAM_HARDWARE_1.pdf
Here are some other introductory & reference materials: http://www.keil.com/books/8051books.asp www.8052.com/books.phtml www.8052.com/tutorial.phtml
That's awesome! Thanks for the references.
How do I configure Simulator for common access?
What do you mean by that?
I think he wants to give you remote access to his simulator so that you can solve the problem for him :) easiler (maybe) than to google :)
Guess he wants to be able to access both CODE and XDATA via MOVX and/or MOVC
Sorry, I'm not that familiar with the simulator, maybe someone else can advise.
Guess he wants
I strongly suggest we don't waste our time guessing. Let's wait for a question that's asked in sufficient precision to be answerable.
There is no need for guessing. The question is in direct relation to this comment earlier in this thread:
The MOVX is accessing XDATA space, not CODE.
E.g. the SILabs chips can be (via a SFR) be set to MOVX access code space, for flash writing purposes.
Also, I have, when it was advatageous to the application, on occasion 'rewired' the '51 to be a VonNeuman machine.
I doubt very much that this is what the OP is strugglinhg with, but the statement "MOVX is accessing XDATA space, not CODE" is not correct in SOME cases.
Erik
"The question is in direct relation to this comment earlier in this thread"
Ah yes - so it is!
So the real questions is what laarus rag meant by it?
The context does suggest that he's thinking of CODE and XDATA both mapped to the same physical memory addresses...
Having never done that, I don't know if it's possible or, if it is, how to do it. I guess the MAP Debug command would be the place to start...
The deductive powers of the professionals gives me that feeling of awe ;)
A.k.a. a von-Neumann memory architecture.
Having never done that, I don't know if it's possible or, if it is, how to do it.
It's easy with external memory (just combine the chip enable signals). For chips with internal flash and XRAM, this is a feature the chip designer would have to set up.
OTOH, there's really no point doing that for the OP's case. MOVC exists.