Hello,
The compiler does not analyse the actions of the assembly code, so it does not take into account that you are already returning the required value in the accumulator. To avoid the warning, you need to create a local variable, assign the accumulator value to the variable, and return the variable. Of course this reduces the efficiency of the code.
byte Get_IMask_Status(void){ byte temp; #asm tpa ; Read contents of CCR to A and #0x08 ; isolate I mask bit asla ; shift left by one bit nsa ; nibble swap, Acc has the content of I bit sta temp; #endasm return temp;}
This results in the following assembly code for the sub-routine. The additional code associated with the variable is indicated. The routine occupies eleven bytes.
.
pshh
tpa
and #0x08
lsla
nsa
tsx
sta ,x
lda ,x
pulh
rts
.
Here is an alternative version of the function, requiring nine bytes of code.
byte Get_IMask_Status(void){ byte temp = 0; __asm bmc B1; temp++; __asm B1: return temp;}
However, you do not need to use either of these functions to return the I-bit status. An intrinsic function is already available to do this, and requires smaller code. The function prototype can be found within the file <intrinsics_hc08.h>, present in the CW installation.
char __isflag_int_enabled( void);
Functions to return other status bits may also be of interest.
Regards,
Mac