CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

while(TRUE) size limit

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
JoeO



Joined: 22 Jun 2005
Posts: 1

View user's profile Send private message

while(TRUE) size limit
PostPosted: Wed Jun 22, 2005 7:27 am     Reply with quote

Hello
I have a large while(TRUE) loop in my main routine. Above a certain size of code (in the while loop) the goto function that implements the while loop goto's some strange area, reduce the code and it goto's the correct place. Is there some fundamental limit within the compiler?

i.e (the dissassembly screen)

584: while(TRUE)
585: {

....lots of code

742: }
000ACD 285D GOTO 0x5d

which is obviously broken, whereas: remove some of the code in the while loop and

584: while(TRUE)
585: {
586: while(!kbhit())
587: {
000613 1A8C BTFSC 0xc, 0x5
000614 2E17 GOTO 0x617
.............

742: }
0007F9 2E13 GOTO 0x613

whis is OK. I am using a 16F628, CCS ver 3.226, mplab v7.00.

Whats going on?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jun 22, 2005 1:20 pm     Reply with quote

I tried to duplicate your problem but could not do so.
I compiled the program below with PCM vs. 3.226, and
it made a large loop that starts at address 0x28E:
Code:

0000                01624 .................... while(1) 
0000                01625 ....................   { 
0000                01626 ....................    a = 123.45678;   
028E 30DF       01627 MOVLW  DF


It goes down to address 0x7B3 (near the end of ROM for the 16F628)
and jumps back up to 0x28E properly.
Code:
07B1 0877       02967 MOVF   77,W
07B2 00B1       02968 MOVWF  31
0000                02969 ....................   } 
07B3 2A8E       02970 GOTO   28E
0000                02971 ....................   
0000                02972 .................... } 
0000                02973 .................... 
07B4 0063       2974 SLEEP


I think you need to post a test program that demonstrates the
problem. My program below creates a large while() loop but
it doesn't show a problem.
Code:
#include <16F628.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)

#include <math.h>
//========================================
void main()
{
float a;
float b;
float c;
float d;
float result;

while(1)
  {
   a = 123.45678;
   b = 456.78901;
   c = 789.01234;
   d = 246.13579;

   result = a + b + c + d;
   result = a - b - c - d;
   result = a * b * c * d;
   result = a / b / c / d;

   result = a + b + c + d;
   result = a - b - c - d;
   result = a * b * c * d;
   result = a / b / c / d;

   result = a + b + c + d;
   result = a - b - c - d;
   result = a * b * c * d;
   result = a / b / c / d;

   result = a + b + c + d;
   result = a - b - c - d;
   result = a * b * c * d;
   result = a / b / c / d;

   result = a + b + c + d;
  }

}
Guest








PostPosted: Wed Jun 22, 2005 3:11 pm     Reply with quote

I have thousands of lines in a do{ }while(true); loop. I don't think there's any limit beyond what the chip can physically hold.
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Wed Jun 22, 2005 4:14 pm     Reply with quote

Wow Surprised
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jun 22, 2005 4:18 pm     Reply with quote

Or, mark it down as Rolling Eyes


Edited to add:
To be fair, he probably meant he has a couple thousand lines of
ASM code in his loop, which is possible. Treitmey and I thought
he meant 2000 lines of C source code.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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