Jump to content

Boostc < Operator Creates <= Code


Recommended Posts

Using BoostC 6.6 in MPLAB IDE

 

This function:

if(iVariable < 0xFFE0)

{ more code here}

return

 

Results in this assembly:

MOVLW 0xFF

BCF STATUS, RP0

BCF STATUS, RP1

SUBWF gbl_iVariable+D'1', W

BTFSS STATUS,Z

GOTO label1

MOVLW 0xE0

SUBWF gbl_iVariable, W

label1

BTFSS STATUS,C

GOTO label2

BTFSS gbl_iVariable+D'1',7

RETURN

label2

more code here

 

If I am reading this code correctly.

If iVariable = 0xFFE0.

After the second SUBWF status bit C will be zero and it will execute 'more code here' when it should actually return.

Thoughts?

Robert

Link to post
Share on other sites
Using BoostC 6.6 in MPLAB IDE

 

This function:

if(iVariable < 0xFFE0)

{ more code here}

return

 

Results in this assembly:

...

 

If I am reading this code correctly.

If iVariable = 0xFFE0.

After the second SUBWF status bit C will be zero and it will execute 'more code here' when it should actually return.

Thoughts?

Robert

 

No errors here.You didn't specify datatype of iVariable. Assuming it's signed short it's value will always be smaller than 0xFFE0 which is 65504.

 

Regards,

Pavel

Link to post
Share on other sites
Using BoostC 6.6 in MPLAB IDE

 

This function:

if(iVariable < 0xFFE0)

{ more code here}

return

 

Results in this assembly:

...

 

If I am reading this code correctly.

If iVariable = 0xFFE0.

After the second SUBWF status bit C will be zero and it will execute 'more code here' when it should actually return.

Thoughts?

Robert

 

No errors here.You didn't specify datatype of iVariable. Assuming it's signed short it's value will always be smaller than 0xFFE0 which is 65504.

 

Regards,

Pavel

 

It was type INT.

It was code I ported from C2C where INT was always unsigned.

Thanks,

Robert

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