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

Program is too large error
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Tue Jul 24, 2012 7:25 am     Reply with quote

Quote:

better than using a delay_ms(10)


You can always try and see Very Happy
Code:

.................... unsigned int16 tix=1;
// 20 instructions for routine
.................... void delay_utix256(void){
*
0041:  CLRF   12
....................    unsigned int8 newtimer, oldtimer=0;
....................    set_timer0(0);
0042:  CLRF   01
.................... do{
....................     newtimer=get_timer0();
0043:  MOVF   01,W
0044:  MOVWF  11
....................     if (newtimer<oldtimer) --tix; // detect overflow
0045:  MOVF   12,W
0046:  SUBWF  11,W
0047:  BTFSC  03.0
0048:  GOTO   04D
0049:  MOVF   0D,W
004A:  BTFSC  03.2
004B:  DECF   0E,F
004C:  DECF   0D,F
....................      oldtimer=newtimer;
004D:  MOVF   11,W
004E:  MOVWF  12
....................
....................     // also you can check an early exit condition HERE and RETURN;
....................
....................   }while(tix);
004F:  MOVF   0D,W
0050:  IORWF  0E,W
0051:  BTFSS  03.2
0052:  GOTO   043
.................... }
0053:  BCF    03.5
0054:  GOTO   07F (RETURN)


Code:

// then  when called    just 4 instructions each time you use it

....................            tix=100;
007B:  CLRF   0E
007C:  MOVLW  64
007D:  MOVWF  0D
....................            delay_utix256();
007E:  GOTO   041
----------------------------using delay syntax -----------

0010:  MOVF   12,W    18 instructions for 0-255 range of delay
0011:  BTFSC  03.2
0012:  GOTO   021
0013:  MOVLW  01
0014:  MOVWF  09
0015:  CLRF   08
0016:  DECFSZ 08,F
0017:  GOTO   016
0018:  DECFSZ 09,F
0019:  GOTO   015
001A:  MOVLW  4A
001B:  MOVWF  08
001C:  DECFSZ 08,F
001D:  GOTO   01C
001E:  GOTO   01F
001F:  DECFSZ 12,F
0020:  GOTO   013
0021:  RETLW  00


//3 instr to call
....................            delay_ms(10);
007F:  MOVLW  0A
0080:  MOVWF  12
0081:  CALL   010


---------------------------------------

for 16 bit integer 

// 7 bytes to call
....................            delay_ms(300);
0082:  MOVLW  02
0083:  MOVWF  11
0084:  MOVLW  96
0085:  MOVWF  12
0086:  CALL   010
0087:  DECFSZ 11,F
0088:  GOTO   084
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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