SpenceKonde/ATTinyCore

Compile error when using SPI library

jagot opened this issue · 2 comments

jagot commented

There is no byte result; in the reverse function anymore, preventing the compilation:

static byte reverse (byte x) {
asm("mov __tmp_reg__, %[out] \n\t"
"lsl __tmp_reg__ \n\t" /* shift out high bit to carry */
"ror %[out] \n\t" /* rotate carry __tmp_reg__to low bit (eventually) */
"lsl __tmp_reg__ \n\t" /* 2 */
"ror %[out] \n\t"
"lsl __tmp_reg__ \n\t" /* 3 */
"ror %[out] \n\t"
"lsl __tmp_reg__ \n\t" /* 4 */
"ror %[out] \n\t"
"lsl __tmp_reg__ \n\t" /* 5 */
"ror %[out] \n\t"
"lsl __tmp_reg__ \n\t" /* 6 */
"ror %[out] \n\t"
"lsl __tmp_reg__ \n\t" /* 7 */
"ror %[out] \n\t"
"lsl __tmp_reg__ \n\t" /* 8 */
"ror %[out] \n\t"
: [out] "+r" (x));
return(result);
}

I am not too good with assembly, but it seems that the reverse operation is performed in-place, and the result is then stored in x. I tried deleting the return statement, and the code compiles, but with a warning for missing return statement in a non-void function.

I believe return(result) shoudl be return(x)

jagot commented

Of course! That makes total sense.