Hi, I've been following the example in App Note 154 to develop a simulator DLL. The result works fine with "simple and small" (un-banked) target firmware (uP is SDA5550). The problem is, when I have to use code banking in the target firmware, I cannot get my AGSI DLL to work with banking. Keil debugger always show "Access Violation" on the first jumping (LJMP) to other bank during initialization (even before going to main() ). I checked the SFR PC always be in "C:xxxx", it never change to "B0:xxxx" or "B1:xxxx" as it should be. However, the banked firmware works fine on a real system (with real uP onboard) without AGSI DLL. Is there any extra banking stuff I need to handle in my AGSI DLL during initialization? Please advice. Thanks!
The D500.DLL shipped with Keil can not deal with banking properly. You shall handle it within your AGSI DLL. Except for banking issue in the simulation, you will face on the banking issue in the real firmware if it becomes more compilicated. For example, if you happen to use a large switch/case statement, Keil C sometimes will generate wrong code: the jump table will be located in current bank, which may cause fatal error if MEX2 does not point to current bank. I had implemented the simulator for SDA5550, supporting all MEX1, MEX2, MEX3 and DPSEL. A lot lot lot of work need to do if you are going to implement a full functional DLL. It can not be easy to describe here. In short, you have to interpet all key opecodes by yourself, like MOVC, ACALL, LCALL, LJMP, RET, IRET, etc..
Thanks! I don't see any AGSI api can be used to trap a specific opcode, e.g. 'LJMP'(0x02). AgsiSetWatchOnMemory() can set a watch on "memory range" acces, but not OpCode. How did you intercept all key opecodes ( like MOVC, ACALL, LCALL, LJMP, RET, IRET, etc.. ) in AGSI DLL?
Currently I'm using a Timer:
static void OpecodeStart(void) { ...... Agsi.SetTimer(OpecodeTimer, 1); } bool TSDATool::AddWatch(void) { ...... OpecodeTimer = Agsi.CreateTimer(OpecodeStart); ...... }
Thanks a lot! But I don't see any API to change PC(ProgramCounter), only AgsiGetProgramCounter() can be used to read current PC value. Is there any AGSI API can change PC? or maybe AgsiDefineVTR("PC", ...) can handle this?
Hi, I tried to use AgsiExecuteCommand("$ = xxxx"); to change PC. But it doesn't work in the timer function OpecodeStart(). I cannot change PC in timer function, however, other debug command is ok... Is there anything wrong?? Example 1: this is ok:
static void OpecodeStart(void) { ...... AgsiExecuteCommand("DIR VTREG"); // THIS IS OK Agsi.SetTimer(OpecodeTimer, 1); }
static void OpecodeStart(void) { ...... AgsiExecuteCommand("$ = C:0000"); // this doesn't work, why??? Agsi.SetTimer(OpecodeTimer, 1); }
You can use:
AgsiExecuteCommand("G XXXX");