SDCC generates wrong code for simple function: unsigned int is_equal_10(unsigned char a) { return a == 10; } Here is produced code: ;tests.c:14: unsigned int is_equal_10(unsigned char a) ; --------------------------------- ; Function is_equal_10 ; --------------------------------- _is_equal_10:: ;tests.c:16: return a == 10; ld hl, #2+0 add hl, sp ld a, (hl) sub a, #0x0a jr NZ, 00103$ ld a, #0x01 .db #0x20 00103$: xor a, a 00104$: ld l, a ld h, #0x00 ;tests.c:19: } ret ;tests.c:21: unsigned int is_greater_10_unsigned_u8(unsigned char a) Since "xor a, a" the fall-thru with the ".db #0x20" is 20 AF which is "JR nz, ". Strangely, the equivalent C function: unsigned int is_equal_10(unsigned char a) { if (a == 10) return 1; return 0; } compiles fine.