• AVR Freaks

Helpful ReplyHot!Debugging disassembly view vs Program Memory view

Author
_dex
Starting Member
  • Total Posts : 72
  • Reward points : 0
  • Joined: 2008/03/19 13:57:34
  • Location: 0
  • Status: offline
2019/08/16 06:50:24 (permalink)
0

Debugging disassembly view vs Program Memory view

I am debugging part of the code and in a disassembly view I see each of the routine instruction 4 times whereas in the Program memory view, it looks normal, single NOP as it should be. I  marked it in the picture by the red Arrows.
The addresses are mixed as well. It looks like I see other parts of the code which share/use the same routine, in this case DebounceDelay.
Why is this so is this made for purpose, or Is this a IDE settings ?
 
X5.20 + XC16, DSPIC33
 
Attachments are not available: Download requirements not met
post edited by _dex - 2019/08/16 07:03:29

Attachment(s)

Attachments are not available: Download requirements not met
#1
ric
Super Member
  • Total Posts : 23581
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: Debugging disassembly view vs Program Memory view 2019/08/16 07:02:40 (permalink)
+1 (1)
There appear to be four duplicate copies of that function.
Have you declared it as "inline" somewhere?
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#2
mbrowning
USNA79
  • Total Posts : 1511
  • Reward points : 0
  • Joined: 2005/03/16 14:32:56
  • Location: Melbourne, FL
  • Status: offline
Re: Debugging disassembly view vs Program Memory view 2019/08/16 07:06:01 (permalink)
+1 (1)
Not very familiar with xc16, but to me it looks like that function got inlined 4 times. Note there's no return at 0xb40 for the instance you are showing.

Go Navy! Beat Army!
#3
_dex
Starting Member
  • Total Posts : 72
  • Reward points : 0
  • Joined: 2008/03/19 13:57:34
  • Location: 0
  • Status: offline
Re: Debugging disassembly view vs Program Memory view 2019/08/16 07:09:32 (permalink)
0
I am not sure If I correct understand Inline declaration? example Please.
I have searched entired project for the:
void DebounceDelay(void)
 
And the result appears to be in general.h ( main function Prototype) and in PMSM.c file where this routine exists.
post edited by _dex - 2019/08/16 07:15:53
#4
ric
Super Member
  • Total Posts : 23581
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: Debugging disassembly view vs Program Memory view 2019/08/16 07:14:55 (permalink)
0
_dex
I am not sure If I correct understand Inline declaration? example Please.
I have searched entired project for the:
void DebounceDelay(void)
 
And result  appears to be in general.h and in PMSM.c file
So two times not four.


How many different places is that function called from?
 
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#5
_dex
Starting Member
  • Total Posts : 72
  • Reward points : 0
  • Joined: 2008/03/19 13:57:34
  • Location: 0
  • Status: offline
Re: Debugging disassembly view vs Program Memory view 2019/08/16 07:17:08 (permalink)
0
4 times exactly.
#6
ric
Super Member
  • Total Posts : 23581
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: Debugging disassembly view vs Program Memory view 2019/08/16 07:17:15 (permalink) ☄ Helpfulby _dex 2019/08/27 02:38:58
+2 (2)
Possibly you have selected "optimise for speed", so the compiler has automatically "inlined" that function.
This means it never calls a central copy of the function, rather the contents of the function are placed "inline at every location where you call it.
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#7
_dex
Starting Member
  • Total Posts : 72
  • Reward points : 0
  • Joined: 2008/03/19 13:57:34
  • Location: 0
  • Status: offline
Re: Debugging disassembly view vs Program Memory view 2019/08/16 07:22:36 (permalink)
0
I do not see this option. The only one I found is "Allow call optimization" in xc1-as General Options. And it is not selected.
Optimization level is 2.
 
post edited by _dex - 2019/08/16 07:33:05
#8
Jerry Messina
Super Member
  • Total Posts : 417
  • Reward points : 0
  • Joined: 2003/11/07 12:35:12
  • Status: offline
Re: Debugging disassembly view vs Program Memory view 2019/08/16 08:30:50 (permalink)
+2 (2)
As to your other question/comment...
The addresses are mixed as well

This is a "feature" of the MPLABX disassembly view, and IMHO one that makes it pretty much useless.
 
To make any sense out of it you pretty much have to use the LST files (or the program view).
 
#9
_dex
Starting Member
  • Total Posts : 72
  • Reward points : 0
  • Joined: 2008/03/19 13:57:34
  • Location: 0
  • Status: offline
Re: Debugging disassembly view vs Program Memory view 2019/08/17 06:59:04 (permalink)
+1 (1)
Why is it so?
The PC stopped at 0xC20 address line, and we see at C22 line(the next one) a BTSTS PORTG,6 instruction is located, for me this corresponds to the second button testing if(pinButton2) after the DebounceDelay; txt line 340.

The next C instruction is DebounceDelay. For me at C22 should be a jmp instruction (or call)  which execute DebounceDelay routine. Where is a jump to DebounceDelay in Program Memory view?


I am mixed up, is something wrong with my thinking? I do not understand why between two button testing instructions a DebounceDelay routine in asm is missing.
Attachments are not available: Download requirements not met
post edited by _dex - 2019/08/17 07:51:47

Attachment(s)

Attachments are not available: Download requirements not met
#10
dan1138
Super Member
  • Total Posts : 3194
  • Reward points : 0
  • Joined: 2007/02/21 23:04:16
  • Location: 0
  • Status: offline
Re: Debugging disassembly view vs Program Memory view 2019/08/17 14:23:21 (permalink) ☄ Helpfulby _dex 2019/08/26 06:13:26
+1 (1)
_dex
... I am mixed up, is something wrong with my thinking? ...



I do not think you are wrong or mixed up. Your screen shot seems to me a clear example of the XC16 compiler being too aggressive with optimizations.
 
In other words this looks like a C compiler code generation bug.
post edited by dan1138 - 2019/08/19 16:49:43
#11
_dex
Starting Member
  • Total Posts : 72
  • Reward points : 0
  • Joined: 2008/03/19 13:57:34
  • Location: 0
  • Status: offline
Re: Debugging disassembly view vs Program Memory view 2019/08/26 06:13:06 (permalink)
0
thank you ( I am back after short holiday). I was really confused and did not know what is going on. With level 2 of optimization the label DebounceDelay completely disappeared. I think this is really bad if the optimization is changing flow of the program.
#12
Jump to:
© 2019 APG vNext Commercial Version 4.5