|
|
View previous topic :: View next topic |
Author |
Message |
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
Is this code really kosher ??? |
Posted: Wed Sep 30, 2015 10:16 am |
|
|
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: 19541
|
|
Posted: Wed Sep 30, 2015 2:15 pm |
|
|
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. |
|
|
|
|
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
|