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

Using instruction timing in Assembler

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
RLScott



Joined: 10 Jul 2007
Posts: 465

View user's profile Send private message

Using instruction timing in Assembler
PostPosted: Tue Jul 10, 2007 8:44 am     Reply with quote

When using in-line assembler to generate precise timing with instruction timing, it is often useful to do something like this to optionally add in one more instruction cycle:

Code:

    btfsc   STATUS,C
    goto    $+1         ; one cycle or two, depending on STATUS,C


Problem 1: "$+1" is not recognized by the CCS assember (I am using an older version - perhaps the newer version does recognize it?) Of course this problem has an easy solution. Just use:

Code:

     btfsc   STATUS,C
     goto   L123
L123:


Problem 2: With #OPT set any higher than 0, the goto L123 is entirely optimized away as unnecessary, which of course breaks the intention of my code. The only work-around I can find for this is to use #OPT 0, which is global and precludes the use of any optimizations elsewhere.

Any comments?

Robert Scott
Real-Time Specialties
Ypsilanti, Michigan
Ttelmah
Guest







PostPosted: Tue Jul 10, 2007 8:56 am     Reply with quote

Add 'asis' to the start of your assembler block.
The 'assembler' syntax, is C like in form, and hence the 'idea' of '$' for the current PC, doesn't exist.
#asm asis
btfsc STATUS,C
goto L123
L123:
#endasm

Best Wishes
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