|
|
View previous topic :: View next topic |
Author |
Message |
allenhuffman
Joined: 17 Jun 2019 Posts: 563 Location: Des Moines, Iowa, USA
|
Generating assembly in large multi-unit projects |
Posted: Tue Feb 25, 2020 11:21 am |
|
|
When I do a simple, small test program, I see each file represented by assembly source in the .lst file.
But in a large project here, we haven't been able to find the source in all files. I finally made a simple test program and called it from main():
Code: | void main()
{
Test();
...
|
And then Test() exists in a separate file. When I check the resulting list, I find the Test() file in the comments:
Line 463216:
Code: |
.............................. void Test()
.............................. {
.............................. printf ("Test()\r\n");
.............................. }
.............................. |
But there is no source around it. From main(), I see where it's calling:
Code: | .............................. Test();
0E4EE 02684A 000000 CALL 684A :
|
...and when I check for 684A, I find source there:
Line 135446:
Code: | *
0684A 200001 MOV #0,W1 : W1 = 0
0684C 780001 MOV W1,W0 : W0 = W1
0684E EF6001 CLR.B 1 : W0H = 0
*
06854 E80081 INC W1,W1 : W1 = W1 + 1
06856 781F81 MOV W1,[W15++] : Push W1 to TOS
06858 F83456 PUSH 3456 : PUSH [3456] to TOS
0685A 9FFFE0 MOV.B W0L,[W15-#2] : [W15+-2] = W0L
0685C F93456 POP 3456 : POP TOS to [3456]
*
06862 7800CF MOV [--W15],W1 : POP TOS to [--W15]
06864 200080 MOV #8,W0 : W0 = 8
06866 E60800 CPSGT W1,W0 : Skip if W1 > W0
06868 37FFF1 BRA 684C : GoTo 684C
0686A 060000 RETURN : Return
..............................
..............................
..............................
..............................
.............................. |
The asm is a few hundred thousand lines away from the C source, and the C source is surrounded by thousands of lines of ".....".
Is there a trick to get the assembly to be inlined near the C source code in the comments? _________________ Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Tue Feb 25, 2020 11:35 am |
|
|
Allen you sure do find things that I've never seen since PCM v2.453 !
As for why the asm code is 'far, far away', that's explained in the manual FAQ or Q&A section. In a nutshell, the single pass compiler has to fit code into available 'bank' spaces and can't overflow. It will rearrange functions to try to maximize complete code in a bank. You'll see posts about 'Out of ROM' with lots of ROM actually left, but you can't put two 5KB functions into one 8KB bank. You also can't 'split' a function over 2 banks.
At least not long time ago.
If you want a listing to appear in 'code space' sequence, import to a program that will sort based on memory address. I did that 4 decades ago while cutting Z80 assembler. |
|
|
allenhuffman
Joined: 17 Jun 2019 Posts: 563 Location: Des Moines, Iowa, USA
|
|
Posted: Tue Feb 25, 2020 11:39 am |
|
|
I found a reference to the out-of-order .lst in the FAQ (something I'd been wondering about):
http://www.ccsinfo.com/faq.php?page=lst_out_of_order
It does make the assembly rather useless when you can't (easily?) figure out what asm belong to what code.
In this case, I'm trying to track down the printfs() that are printing the wrong string, to look at the good vs bad asm and see what the difference is. _________________ Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Tue Feb 25, 2020 11:54 am |
|
|
gee Allen, I started PICkin when all PICs had quartz skylights and erase meant time for another 15 minute coffee break PICs are easy to code in assembler, only 35 instructions, far less than Z80 or 8080s. Sadly today's PICs have more fuses than instructions.
Surely there's some 'fancy' Windoze 'ap' you can import and sort the listing ? Even the old DOS 'sort.exe' might work... |
|
|
allenhuffman
Joined: 17 Jun 2019 Posts: 563 Location: Des Moines, Iowa, USA
|
|
Posted: Tue Feb 25, 2020 11:55 am |
|
|
temtronic wrote: |
Surely there's some 'fancy' Windoze 'ap' you can import and sort the listing ? Even the old DOS 'sort.exe' might work... |
Not sure that helps. There's no reference around the C source to know what it belongs with. I only found it manually by looking at a CALL then finding that. _________________ Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Tue Feb 25, 2020 1:00 pm |
|
|
I was under the impression you wanted the listing to be in same order the physical PIC memory is, not 'splattered all over the place'.... |
|
|
allenhuffman
Joined: 17 Jun 2019 Posts: 563 Location: Des Moines, Iowa, USA
|
|
Posted: Tue Feb 25, 2020 1:45 pm |
|
|
temtronic wrote: | I was under the impression you wanted the listing to be in same order the physical PIC memory is, not 'splattered all over the place'.... |
Well, yes, that would be nice because I had wondered why there were huge gaps -- but in this case, I just want to find the code for a printf() and sprintf() and look at why it's using the wrong string.
Now that I have learned that the gaps are not gaps (necessarily), sorting in Notepad++ works great. I was quite puzzled by seeing things jump around like that. _________________ Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Tue Feb 25, 2020 4:28 pm |
|
|
I think it goes back to the 'try to fill each bank with complete code' algorithm for the compiler.
Initially it may try to do it inline but decide it can't fit a complete function or 'chunk' of contiguous code into a bank. It may then attempt to do a 'best fit' approach. I know in the past you could NOT have a function cross a boarder between banks, especilally tables !
Over the years PICs have got bigger so I assume CCS has more 'smarts' in the compiler to figure all this stuff out. To complicate things, there's more 'features' and 'C' compatibilty to deal with. Originally CCS C wasn't 'official' C ( whatever that means.....) |
|
|
allenhuffman
Joined: 17 Jun 2019 Posts: 563 Location: Des Moines, Iowa, USA
|
|
Posted: Wed Feb 26, 2020 1:30 pm |
|
|
temtronic wrote: | I think it goes back to the 'try to fill each bank with complete code' algorithm for the compiler. |
Thanks! I really need to start doing a series on PIC/CCS on my site. I think there's some great "newbies need to know this" stuff I've learned here that would have been great to know when I started and "[spam]-u-me'd" it was a normal C compiler. _________________ Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Wed Feb 26, 2020 1:43 pm |
|
|
Well.. there's no such thing as a 'normal C compiler', never has, never will be. Every mfr of a compiler has their 'quirks' and of course there is no official, died in the wool, cast in granite C language. Everything 'evolves'.
CCS does a darn good job of getting THEIR version of 'C' to run in PICs and obviously CCS C won't run in an Ardunio.
I'm not a trained C programmer, rather I've muddled through, self taught since PCM 2.534+-. My programs may not be coded in 'official C' practices, but they work. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|