We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi, I'm working with LPC1768 MC & using the MDK simulator. My assembly code is involving strings. When I declare the string in data segment, it doesnt get reflected in memory window during the debug session. But if I declare the string in code segment, it gets reflected in the memory window during the debug session. Can anyone let me know, why this is happening?
Simulation is limited with Keil MDK, as it is impossible to simulate the behavior of the on-chip peripherals for more than 7500 devices supported today.
https://www.keil.com/support/docs/3726.htm
Beside, do always confirm the version of your product - in this case MDK - in use.
At the moment MDK 5.31 is our latest release:
http://www.keil.com/update/relnotes/MDK531.htm
I recommend to compare with this release.
The latest release of Keil MDK is always offered at:
http://www2.keil.com/mdk5
rkopsch said:Simulation is limited
Nowadays, with the ready availability of low-cost hardware having on-chip debug, the usefulness of simulation is also limited!
shruthi84 - why not just run your code on real hardware using the debugger?
Can you show an example? A picture or some code showing how you declare/define the strings that work and those that don't?
Simulating an LPC1768 in Keil MDK 5.31 seems to work just fine: strings defined as constant data, on the stack, or on the heap show up in the debugger as strings.
Thanks for replying. Here are the code examples.
For the simple code below the ascii value of the string appears in the memory window. Here the string is declared after the code.
AREA data1, DATAADD1 EQU 0x1000000
AREA prog, CODE ENTRY EXPORT __main2__main2 LDR R1, = ADD1 LDR R2, =string LDRB R3, [R2] stop B stop string DCB "abcd" END
But for the code below the ascii value does not appear in the memory window. Here the string is declared separately in data segment.
AREA data1, DATAstring DCB "abcd"
ALIGN
ADD1 EQU 0x1000000
AREA prog, CODE ENTRY EXPORT __main2__main2 LDR R1, = ADD1 LDR R2, =string LDRB R3, [R2] stop B stop END
Please let me know the reason behind this issue.
we are actually preparing some assignments for students to learn & work from home (COVID). Hence using the simulator.
Sir, I'm using MDK 5.31.
//Example of string being declared in code segment. AREA data1, DATA ADD1 EQU 0x1000000 AREA prog, CODE ENTRY EXPORT __main2 __main2 LDR R1, = ADD1 LDR R2, =string LDRB R3, [R2] stop B stop string DCB "abcd" END
//Example of code being declared in Code segment AREA data1, DATA ADD1 EQU 0x1000000 string DCB "abcd" AREA prog, CODE ENTRY EXPORT __main2 __main2 LDR R1, = ADD1 LDR R2, =string LDRB R3, [R2] stop B stop END
I suspect that your memory window configuration is what's causing the issue. If I set the address of the memory window to r2 (which will take the value of register r2), then I see the correct strings when I step through the functions. I modified your code a little to make each function C callable, to better work with my existing project. For example, when stepping through the code, I see the following (once r2 has been set):
Note also that if you want to define a C string you need to add the NULL terminator, e.g.,
string DCB "c string",0
This is explained in the armasm User Guide.