CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Is this code really kosher ???

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

Is this code really kosher ???
PostPosted: Wed Sep 30, 2015 10:16 am     Reply with quote

what am i seeing here?
compiled with 5.042
* in spite of the int1 function typing both functions seems to return a byte
* line 174, 176 and 15E,160 are confusing too --A branch following a branch but no earlier "refer" to the implied GOTO lines ?


Code:

.................... unsigned int8 iscomplex(void){
....................    IF (OUTMODE&0B00001100) return(1);
*
0016A:  MOVF   xA7,W
0016C:  ANDLW  0C
0016E:  BZ    0178
00170:  MOVLW  01
00172:  MOVWF  01
00174:  BRA    017C
00176:  BRA    017C
....................    else return(0);
00178:  MOVLW  00
0017A:  MOVWF  01
0017C:  GOTO   018A (RETURN)
.................... }
.................... 
.................... int1 iscomplex2(void){
....................    IF (OUTMODE&0B00001100) return(1);
*
00154:  MOVF   xA7,W
00156:  ANDLW  0C
00158:  BZ    0162
0015A:  MOVLW  01
0015C:  MOVWF  01
0015E:  BRA    0166
00160:  BRA    0166
....................    else return(0);
00162:  MOVLW  00
00164:  MOVWF  01
00166:  GOTO   0182 (RETURN)
.................... }
Ttelmah



Joined: 11 Mar 2010
Posts: 19433

View user's profile Send private message

PostPosted: Wed Sep 30, 2015 2:15 pm     Reply with quote

Simple answer is, 'how can a function return less than a byte'?.

However, if you then use the byte in a function outside, involving a logic test for example, the int8 version will be be cast to an int1 before use, while the int1 version is already implicitly one.

int1's are smaller used as flags for example where they are not 'returned', but as a returned type, an int8 still has to be used to contain them.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group