Jump to content
Sign in to follow this  
onyx

Boostc Generates No Bcf For Clear_bit(var,bit)

Recommended Posts

Bug description:

BoostC generates no BCF instructions in clear_bit(var,bit)

Steps to reproduce:

compile the following example with boostc

 

#include <system.h>

char beta;

void main()
{
 beta = 0x0f;
 set_bit(beta, 5);
 clear_bit(beta, 3);
}

 

compiles with boostC to the following

void main()
1FF9           main; function begin

{
 beta = 0x0f;
1FF9          ; {
1FF9          ; {
1FF9   0F30            MOVLW	0x0F
1FFA           
1FFA   A000            MOVWF gbl_beta
1FFB          ; }

 set_bit(beta, 5);
1FFB          ; {
1FFB   A016            BSF gbl_beta,5
1FFC          ; }

 clear_bit(beta, 3);
1FFC          ; {
1FFC   F730            MOVLW	0xF7
1FFD   A005            ANDWF gbl_beta
1FFE          ; }

}
1FFE           
1FFE   0800            RETURN
1FFF          ; }
1FFF          ; main function end - Exit PCLATH/Uncertainty: 0x3:0x0

 

 

Expected behaviour:

Compiler should generate BCF gbl_beta,3 for the expression clear_bit(beta, 3)

this code generation is not wrong, but it would be much nicer using BCF, than

loading a literal constant and anding it with the variable

 

Reproduceable:

always

 

SourceBoost DE version: 5.6.1

Compiler: BoostC 1.3 Alpha

 

Remark: C2C 5.6.1e generates the expected code

 

OS: Win2000

Share this post


Link to post
Share on other sites

Fixed in BoostC 1.4 Alpha release. I also discovered that when 16 bit variable is used inside clear_bit macro compiler generates unoptimized code (8 instructions). This has been changed too (now only 1 instruction is generated).

 

Regards,

Pavel

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