| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| JoeO 
 
 
 Joined: 22 Jun 2005
 Posts: 1
 
 
 
			    
 
 | 
			
				| while(TRUE) size limit |  
				|  Posted: Wed Jun 22, 2005 7:27 am |   |  
				| 
 |  
				| 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
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Wed Jun 22, 2005 1:20 pm |   |  
				| 
 |  
				| 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 
 
 
 
 
 
 
 
			
			
			
			
			
			
			
			
			
 
 | 
			
				|  |  
				|  Posted: Wed Jun 22, 2005 3:11 pm |   |  
				| 
 |  
				| 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
 
 
			      
 
 | 
			
				|  |  
				|  Posted: Wed Jun 22, 2005 4:14 pm |   |  
				| 
 |  
				| Wow  |  | 
	
		|  | 
	
		| PCM programmer 
 
 
 Joined: 06 Sep 2003
 Posts: 21708
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Wed Jun 22, 2005 4:18 pm |   |  
				| 
 |  
				| Or, mark it down as   
 
 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.
 |  | 
	
		|  | 
	
		|  |