Jump to content
Sign in to follow this  
hurley78

Asm Error In Built-In Assembly

Recommended Posts

I'm getting an error on this asm code line.

 

asm bcf STATUS,C

Both STATUS and C are defined in the pic16f877.h file.

 

The error is "(line#:5): error: error in built-in assembly"

 

Using BoostC V7.10.

 

Any help?

 

 

hurley78

Share this post


Link to post
Share on other sites

I'm getting an error on this asm code line.

 

asm bcf STATUS,C

Both STATUS and C are defined in the pic16f877.h file.

 

The error is "(line#:5): error: error in built-in assembly"

 

STATUS and C are defined as integer constants so after preprocessing compiler will see "asm bcf 0x0003,0x0000" which is not valid assembly. Take a look at the BoostC help as the "Inline Assembly" chapter.

 

Pavel

Share this post


Link to post
Share on other sites

Ok, I have tried what the BoostC Help says:

 

asm("bcf STATUS,C"); get the same error

 

What does work is:

 

asm("bcf STATUS,0");

 

Not sure what is happening. This code worked with C2C.

 

All is working now.

 

Thanks,

hurley78

Share this post


Link to post
Share on other sites

...Not sure what is happening...

 

OK lets break our thinking process into steps:

 

1. assembly instructions operate on PIC registers

2. in BoostC registers are mapped to variables with fixed addresses (see Register mapped variables in BoostC help)

3. variable that is mapped to STATUS register is called status (see PORTB vs portb or notes about naming convention in BoostC help)

4. when referencing to a C variable from built-in assembly variable name must be prefixed with underscore (see Variable Referencing in asm in BoostC help)

5. all together gives us asm bcf _status,C

 

Pavel

Share this post


Link to post
Share on other sites

Hi

 

There is allways the BoostC/easy/smart way of doing it:

 

set_bit(status,C);

 

By the way don't forget also

clear_bit(status,C);

and

if(test_bit(status,C)) .......................

 

 

 

Best regards

Jorge

Edited by JorgeF

Share this post


Link to post
Share on other sites

JorgeF,

Hi

 

There is allways the BoostC/easy/smart way of doing it:

 

set_bit(status,C);

 

By the way don't forget also

clear_bit(status,C);

and

if(test_bit(status,C)) .......................

 

status.C = 1;
...
status.C = 0;
...
if( status.c )
...

 

This works because of support for individual bit addressing in the form "var.bitNumb", where bitNumb is a constant.

And C is declared as the appropriate bit number in the target header files.

 

Regards

Dave

Share this post


Link to post
Share on other sites

Hi

 

I know that Dave.

 

I never tested the code generated for any differences, but when in doubt, I tend to use the approach...

"if they botter to create this, they must have had good reasons for it"

... thats why I didn't recommend any other alternatives.

 

 

Best regards

Jorge

Edited by JorgeF

Share this post


Link to post
Share on other sites

JorgeF,

Hi

 

I know that Dave.

 

I never tested the code generated for any differences, but when in doubt, I tend to use the approach...

"if they botter to create this, they must have had good reasons for it"

... thats why I didn't recommend any other alternatives.

Sorry I misread your post and thought you where asking for a neater smater way - whoops.

 

The set_bit() and clear_bit() functions are there because they existed before the method I described.

 

Regards

Dave

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.

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...
Sign in to follow this  

×
×
  • Create New...