| 
	
	|  |  |  
	
		| View previous topic :: View next topic |  
		| Author | Message |  
		| joshkeys 
 
 
 Joined: 16 Aug 2005
 Posts: 37
 Location: Fredericton,NB
 
 
			        
 
 | 
			
				| Unwanted Automated ASM code |  
				|  Posted: Thu Dec 14, 2006 12:48 pm |   |  
				| 
 |  
				| Hello all, 
 I have been using ASM code throughout my programs to get certain aspects of my code more efficient. The problem I am running into is that when i compile, the compiler inserts unecessary ASM lines that I dont want, such as is shown below.
 
 
  	  | Code: |  	  | .................... BSF    0x05.2
 0076:  BCF    03.5
 0077:  BSF    05.2
 
 | 
 
 The problem here is that I do not want it to set the bank to bank 0 because I have already done this a few lines before and the status register is still set to bank 0. But yet it sets it for me, and also at the end of a while statement, it goes ahead and sets teh status register to bank 0 again. I am really desperate for CPU cycles here and would like to save as many as possbile. so how can i stop it from doing this. Thanks
 
 Josh[/code]
 |  |  
		|  |  
		| drh 
 
 
 Joined: 12 Jul 2004
 Posts: 193
 Location: Hemet, California USA
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Thu Dec 14, 2006 1:42 pm |   |  
				| 
 |  
				| Are you using #asm...#endasm directives? If so, using #asm ASIS will stop the compiler
 from setting the banks.
 _________________
 David
 |  |  
		|  |  
		| joshkeys 
 
 
 Joined: 16 Aug 2005
 Posts: 37
 Location: Fredericton,NB
 
 
			        
 
 | 
			
				|  |  
				|  Posted: Thu Dec 14, 2006 1:48 pm |   |  
				| 
 |  
				| yes, I use #asm and #endasm. It still decides to add a line when it feels like to make sure the proper bank has been set. 
 Josh
 |  |  
		|  |  
		| PCM programmer 
 
 
 Joined: 06 Sep 2003
 Posts: 21708
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Thu Dec 14, 2006 2:57 pm |   |  
				| 
 |  
				|  	  | Quote: |  	  | yes, I use #asm and #endasm. It still decides to add a line when it feels like to make sure the proper bank has been set.
 
 | 
 I tested the ASIS directive with PCM vs. 3.249 and I found that it is
 effective in preventing the compiler from putting in bank switching code.
 
 Here is the result with ASIS.  There's no bank select code:
 
  	  | Code: |  	  | .................... #asm    ASIS
 .................... MOVF EECON1,W
 000C:  MOVF   0C,W
 .................... MOVF EEDATA,W
 000D:  MOVF   0C,W
 .................... MOVF TXSTA,W
 000E:  MOVF   18,W
 .................... MOVF RCREG,W
 000F:  MOVF   1A,W
 .................... #endasm
 | 
 
 
 With ASIS commented out, the compiler puts in bank select code:
 
  	  | Code: |  	  | .................... #asm //   ASIS
 .................... MOVF EECON1,W
 000C:  BSF    03.6
 000D:  MOVF   0C,W
 .................... MOVF EEDATA,W
 000E:  BCF    03.5
 000F:  MOVF   0C,W
 .................... MOVF TXSTA,W
 0010:  BSF    03.5
 0011:  BCF    03.6
 0012:  MOVF   18,W
 .................... MOVF RCREG,W
 0013:  BCF    03.5
 0014:  MOVF   1A,W
 .................... #endasm
 | 
 
 Here's the test program:
 
  	  | Code: |  	  | #include <16F877.H>
 #fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
 #use delay(clock=4000000)
 
 #byte RCREG  = 0x1A
 #byte TXSTA  = 0x98
 #byte EEDATA = 0x10C
 #byte EECON1 = 0x18C
 
 //============================
 void main()
 {
 
 #asm //   ASIS
 MOVF EECON1,W
 MOVF EEDATA,W
 MOVF TXSTA,W
 MOVF RCREG,W
 #endasm
 
 while(1);
 }
 | 
 |  |  
		|  |  
		| joshkeys 
 
 
 Joined: 16 Aug 2005
 Posts: 37
 Location: Fredericton,NB
 
 
			        
 
 | 
			
				|  |  
				|  Posted: Thu Dec 14, 2006 4:48 pm |   |  
				| 
 |  
				| As usual, thanks PCM Programmer. Worked 100%. Now no more unexpected timing issues! Thanks! 
 Josh
 |  |  
		|  |  
		| drh 
 
 
 Joined: 12 Jul 2004
 Posts: 193
 Location: Hemet, California USA
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Fri Dec 15, 2006 9:05 am |   |  
				| 
 |  
				|  	  | joshkeys wrote: |  	  | As usual, thanks PCM Programmer. Worked 100%. Now no more unexpected timing issues! Thanks! Josh
 | 
 Did you read all of my reply?
 _________________
 David
 |  |  
		|  |  
		| joshkeys 
 
 
 Joined: 16 Aug 2005
 Posts: 37
 Location: Fredericton,NB
 
 
			        
 
 | 
			
				| Sorry |  
				|  Posted: Fri Dec 15, 2006 2:49 pm |   |  
				| 
 |  
				| drh, i apologize, I guess I did not read the whole thing, well i am sure i did, but i guess as soon as i read the #asm and #endasm In my mind I had already formed an answer..  .. I apologize, I am not usually so quick to read something, I was in a rush at that time. My bad.. Thanks for the tip   
 Josh
 |  |  
		|  |  
		|  |  
  
	| 
 
 | 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
 
 |