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 support@ccsinfo.com

the pseudo opcode CLRF

 
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

the pseudo opcode CLRF
PostPosted: Wed Apr 22, 2009 4:52 pm     Reply with quote

I notice that when I initialize
Code:
unsigned int16 adccon[4]={0,0,0,0};

that it generates very efficient code with
with a string of
Code:
CLRF 3F     pseudo op instrux
CLRF 40 
CLRF 41
CLRF 42
etc etc   

however RE initing the array with a loop or whatever is very awkward
and code hoggy

since the 4.08x compiler (#ASM directive)
wont accept the pseudo op CLRF
I've been re initializing with code like this
Code:

#ASM
  movlw 0
  movwf 0x3F
  etc and so on - matching the original static zeroing out code
#ENDASM

I know what i have to track and be careful of - in regard not getting compiler stung ( i think )

BUT is there better way to let the compiler do the reinit
like it did when i declared the vars ?

I have a number of small arrays, of different sizes - that i want to reinit together and i find that looping to do it,
sucks code space horribly- and the above ASM hack appears to do it with minimum clocks

I'd be grateful if there is a better way to let the compiler do it - but still achieve decent efficiency.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Apr 22, 2009 5:25 pm     Reply with quote

Both the methods shown below generate CLRF statements in the .LST file.
The first one is better since it's in C.
Code:
#include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

//======================================
void main()
{
int8 array[5];

array[0] = 0;
array[1] = 0;
array[2] = 0;
array[3] = 0;
array[4] = 0;


#asm
CLRF array[0]
CLRF array[1]
CLRF array[2]
CLRF array[3]
CLRF array[4]
#endasm

while(1);
}
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