Jump to content

Recommended Posts

For a PIC16F device, I have a section of Asm code that places a value in W, and now I want to compare it or use it in other C expressions. However, to do that seems to require more and more Asm code because I can't treat W like a value directly in C. For example, I'd like to do something like:

asm swapf _var, W;   //example code: value is now in W
if (W == 4) ... //use W in a compare, or ...
var = W;   //save W, or do something else with it

 

To do this, I need to add more and more Asm code:

//  (value is in W)

//to compare W to 4, the following is needed:
asm xorlw 4
btfss _status, Z
goto not_equal

//to save W to a var:
asm movwf _var

ie, it takes more and more Asm code to manipulate W, instead of jumping back into C and manipulating it there.

 

Is there a syntactical way to refer directly to W in BoostC instead of adding extra Asm (and typically extra temps to hold it)?

 

don

Edited by djulien
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.

Guest
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.

Loading...
×
×
  • Create New...