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

what is the most simple function for Z and C flag decisions

 
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

what is the most simple function for Z and C flag decisions
PostPosted: Sun Dec 02, 2007 11:02 am     Reply with quote

re 16F/C family :
when doing a series of bit shifts << , >> etc of varying lengths -
and then seeing results of a specific single BIT shifted out of the variable register - reading the C or Z flag in assembler was direct and EZ

yet i find there are no compiler defined functions to just read the
flags after an operation on the order of
a zflag() or Cflag() function.

Or are there ?
so far i've been using the ( obvious) defined bit read functions of register 03 to make decisions- but is there a better way or a defined function i simply don't see? is there a reason there is no compiler defined function for these two obvious, and important flags?

am i just being excessively thick here ?

what IS the most code efficient way to do it ?
asmboy



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

View user's profile Send private message AIM Address

sorry forgot the example
PostPosted: Sun Dec 02, 2007 11:55 am     Reply with quote

i'm just trying to find out if there is a predefined or lower instrux count function than this:

.................... int1 Zflag() {
.................... return ( bit_test ( *StatusReg ,2));
*
0053: MOVLW 00
0054: BTFSC 03.2
0055: MOVLW 01
0056: MOVWF 78
.................... }
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Dec 02, 2007 3:05 pm     Reply with quote

The compiler manual shows this method:
Code:

#bit CY = GETENV("bit:C")
#bit Z  = GETENV("bit:Z")


Then use CY and Z in your code as if they were variables.
Guest








i checked the .LST
PostPosted: Mon Dec 03, 2007 8:20 am     Reply with quote

WOW - i tried it and checked the resulting LST file -
Now thats as efficient as it gets!

THANKS and my apology
- i should have looked that up in the index of the compiler manual -
( if only there WAS an index ) it would have saved a lot of head scratching.

i have some old code to go clean up now with the improvement
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