Single Stepping Debugger w/assembler code

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Single Stepping Debugger w/assembler code

464 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bryanrj on Tue Apr 27 20:34:06 MST 2010
When single stepping with the debugger through assembler language code that has labels, the debugger gets out of step with the source code. Attached is a ZIP file, Nancy.zip, containing the project files. Unzip, build and run under the debugger. Single step through the code and see what happens.

I want to trust the debugger. Behavior like that displayed with the attached project causes doubts. Please restore my trust.

Hopefully,
Robert J Bryan
0 Kudos
Reply
1 Reply

435 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Wed Apr 28 01:31:34 MST 2010
OK, single stepping through your example, I can see that I appear to "double step" instructions around a local label within your assembler subroutine.

This appears to be an issue with the assembler's debug information generation. The local label within your assembler routine is being flagged as ARM rather than Thumb, even though we are in the middle of Thumb code and assembling for a Thumb-only architecture.

However this is simple to workaround, simply mark the local label with [FONT=Courier New].thumb_func[/FONT]....

  .syntax unified
  .cpu cortex-m0
  .align 2
  .global  my_subroutine
  .type   my_subroutine, function
  .thumb
  .thumb_func
my_subroutine:
  movs  r0,#0x00
  [B].thumb_func[/B]
my_local_label:
  movs  r3,#0x33
       :
       :
After adding this, you will then be able to single step through your assembler subroutine without this apparent "double stepping".

A few other comments...

[LIST=1]
[*]I would recommend the use of [FONT=Courier New].syntax unified[/FONT] which is the format of instructions used by ARM for their Cortex processors. Doing this may require a few tweaks if you are pulling in existing assembly language code though.
[*]I recognise that the example project you provided is just a simple test case, but be aware that when writing assembler code that interfaces with C that you need to adhere to the rule of the ARM Procedure Call standard - and take great care over which registers you can/cannot corrupt in your assembler code
[*]There are a few previous threads on assembler programming with LPCXpresso which may provide you with further useful information. A good starting point would be http://knowledgebase.nxp.com/showthread.php?t=251. Doing a google for "assembler site:knowledgebase.nxp.com" will throw up a few more.
[/LIST]
Regards,
CodeRedSupport
0 Kudos
Reply