|
|
View previous topic :: View next topic |
Author |
Message |
sjbaxter
Joined: 26 Jan 2006 Posts: 141 Location: Cheshire, UK
|
Compiler inserting NOP's |
Posted: Tue Dec 05, 2006 4:42 am |
|
|
Has anyone else ever seen the following, where the compiler just inserts NOP's instead of code:
Code: | 602: // perform a reset of the serial parser
603: if (reset)
E40 CFE0 MOVFF 0xfe0, 0xfd
E42 F0FD NOP
604: {
605: value = 0;
E44 0100 MOVLB 0
E46 CFD8 MOVFF 0xfd8, 0xfe
606: valuelength = 0;
E48 F0FE NOP
E4A 6FFF MOVWF 0xff, BANKED
607: parameter = PARAMETER_UNKNOWN;
E4C CFE9 MOVFF 0xfe9, 0xfc
E4E F0FC NOP
608: reset = false;
E50 CFEA MOVFF 0xfea, 0xfb
609: }
610:
611: bytesinbuffer--;
E52 F0FB NOP
612: currentreadbyte++;
E54 CFFA MOVFF 0xffa, 0xf5
613: if (currentreadbyte >= MAX_BUFFER_LENGTH)
E56 F0F5 NOP
E58 CFFB MOVFF 0xffb, 0xf4
E5A F0F4 NOP
614: currentreadbyte = 0;
E5C 90D4 BCF 0xfd4, 0, ACCESS
|
I'm using MPLAB 7.50, ICD-2, PCH 3.236 (I'm only able to get upto 3.242 and they all give me grief above 3.236 when using structures !!)
PIC is an 18F1220, I'm upto 90% code and 57%-78% RAM.
Any clues anyone ? _________________ Regards,
Simon. |
|
|
Guest
|
|
Posted: Tue Dec 05, 2006 4:50 am |
|
|
Hi Simon,
This is a fairly common problem. To resolve it, go to Tools > Preferences, and uncheck the 'Insert Random NOP's' selection.
Cheers,
Jerry |
|
|
sjbaxter
Joined: 26 Jan 2006 Posts: 141 Location: Cheshire, UK
|
|
Posted: Tue Dec 05, 2006 5:04 am |
|
|
Oh yeah, why didn't I think of that !!! _________________ Regards,
Simon. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Dec 05, 2006 5:21 am |
|
|
They're not NOPs. The MOVFF instruction has two words, for the source
and the destination. The compiler may call it a NOP, but it's not.
I compiled a program with PCH vs. 3.249 under MPLAB, and I can't
make it give this NOP output. I tried setting the .LST file format to
"MPLAB format" and "Normal CCS format". Neither mode shows the NOPS. |
|
|
sjbaxter
Joined: 26 Jan 2006 Posts: 141 Location: Cheshire, UK
|
|
Posted: Tue Dec 05, 2006 5:26 am |
|
|
If I change the device to an 18F1320 (which has more program memory) the code generated is as I would expect.
i.e.
Code: | 631: // perform a reset of the serial parser
632: if (reset)
1224 A63D BTFSS 0x3d, 0x3, ACCESS
1226 EF1C GOTO 0x1238
633: {
634: value = 0;
122A 6B81 CLRF 0x81, BANKED
122C 6B80 CLRF 0x80, BANKED
635: valuelength = 0;
122E 6B83 CLRF 0x83, BANKED
1230 6B82 CLRF 0x82, BANKED
636: parameter = PARAMETER_UNKNOWN;
1232 6A7F CLRF 0x7f, ACCESS
1234 6A7E CLRF 0x7e, ACCESS
637: reset = false;
1236 963D BCF 0x3d, 0x3, ACCESS
638: }
639:
640: bytesinbuffer--;
1238 063B DECF 0x3b, F, ACCESS
641: currentreadbyte++;
123A 2A3A INCF 0x3a, F, ACCESS
642: if (currentreadbyte >= MAX_BUFFER_LENGTH)
123C 503A MOVF 0x3a, W, ACCESS
|
So I suspect the compiler is running out memory and trying to do something strange during the optimization.
I'm working on breaking the code down into smaller separate chunks to see if it is a page size related thing. _________________ Regards,
Simon. |
|
|
libor
Joined: 14 Dec 2004 Posts: 288 Location: Hungary
|
|
Posted: Tue Dec 05, 2006 6:12 am |
|
|
18F1220, 18F1320 datasheet, page 191 says:
...All instructions are a single word, except for three double-word instructions. These three instructions were made double-word instructions so that all the required information is available in these 32 bits. In the second word, the 4 MSbs are �1�s. If this second word is executed as an instruction (by itself), it will execute as a NOP. |
|
|
sjbaxter
Joined: 26 Jan 2006 Posts: 141 Location: Cheshire, UK
|
|
Posted: Tue Dec 05, 2006 6:27 am |
|
|
I had a switch statement before the code I posted (with about 20 cases in it). I have commented out about 5 cases and the code generates correctly. So I'm sort of happy for the moment. It does seem to be related to available space ... maybe the debug kernal is overwriting the top end of memory ... just a thought. _________________ Regards,
Simon. |
|
|
Ttelmah Guest
|
|
Posted: Tue Dec 05, 2006 7:40 am |
|
|
Hint.
Look at 'used rousources' in the MPLAB notes about ICD2.
For the 18F1220, program memory from E40, to FFF, and RAM from F0 to FF, is used by the debugger.
Best Wishes |
|
|
sjbaxter
Joined: 26 Jan 2006 Posts: 141 Location: Cheshire, UK
|
|
Posted: Tue Dec 05, 2006 8:33 am |
|
|
Thanks Ttelmah, that'll explain it ... Maybe I should read the doco a bit more. _________________ Regards,
Simon. |
|
|
|
|
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
|