Jump to content
Sign in to follow this  

While Loop Eficiency.....

Recommended Posts

Hi, example (C2C+ 5.5.1):

     while (pir1 & 100000b);

compiler makes:

btfss _pir1, 5
goto label_0071
goto label_0070

This is absolutely OK.


But if I want this:

     while (~pir1 & 100000b);  (or while ((pir1 & 100000b))!=1; )

compiler makes:

comf _pir1, W
andlw D'32'
sublw 0
btfsc STATUS, Z
goto label_0059
goto label_0058

instead of: (it's enough simply :)

btfsc _pir1,5   
goto label_59   
goto label_58


Is there some way, how to "learn :)" compiler to make this better code ?


Of course, this is only some instr. more than in asm, but sometimes is this important.

Regards PetrM.

Share this post

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...