Jump to content
Reynard

Casting To A Bool

Recommended Posts

I am unable to cast any data type greater than a char to a bool.

 

bool			myFlag = false;
unsigned int	myInt;

void main()
{
myInt = 0xffff;
myFlag = (myInt & 0x0100);
}

 

Produces:-

bool			myFlag = false;
001C  9003		  BCF gbl_myFlag,0

unsigned int	myInt;

void main()

{
myInt = 0xffff;
0008  6801		  SETF gbl_myInt
000A  6802		  SETF gbl_myInt+D'1'

myFlag = (myInt & 0x0100);
000C  0E00		  MOVLW 0x00
000E  1401		  ANDWF gbl_myInt, W
0010  6E04		  MOVWF CompTempVar586
0012  9003		  BCF gbl_myFlag,0
0014  5004		  MOVF CompTempVar586, W
0016  A4D8		  BTFSS STATUS,Z
0018  8003		  BSF gbl_myFlag,0

}

 

It doesn't know "myInt" is an int.

 

SB 7.01, PIC18F4580, XP Pro SP3

 

Cheers

 

Reynard

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

×
×
  • Create New...