Jump to content
Sign in to follow this  
FredericG

While(6); Vs While(5+1);

Recommended Posts

} while (i<(5+1));

0CDB 0813 MOVF get_wp_00000_1_i, W

0CDC 3C06 SUBLW 0x06

0CDD 3C00 SUBLW 0x00

0CDE 0213 SUBWF get_wp_00000_1_i, W

0CDF 1803 BTFSC STATUS,C

0CE0 3A06 XORLW 0x06

0CE1 1D03 BTFSS STATUS,Z

0CE2 2CD0 GOTO label151

0CE3 label152

 

versus:

} while (i<6);

0CDB 3006 MOVLW 0x06

0CDC 0213 SUBWF get_wp_00000_1_i, W

0CDD 1C03 BTFSS STATUS,C

0CDE 2CD0 GOTO label151

 

I don't have the courage to delve into this, but it have a feeling that when I write (5+1) the compiler starts treating it as a signed value...

 

} while (i<(unsigned char)(5+1));

0CDB 3006 MOVLW 0x06

0CDC 0213 SUBWF get_wp_00000_1_i, W

0CDD 1C03 BTFSS STATUS,C

0CDE 2CD0 GOTO label151

 

 

The variable i is also unsiged.

 

Frederic

Edited by FredericG

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