by Joker_vD · 1y ago · 0 comments
extern char fn(void);
char kekw(void) {
const char foo = fn() ^ 5;
return foo - (foo & 3);
}
as a running example, and while godbolt only has cc6502, that thing indeed generates worse code, with helper subroutine calls and doing some strange stack juggling.Their example output
jsr fn
eor #5
ldx #3
sax S
sec
sbc S
rts
Is better but not drastically so than the output of another 6502 compiler on godbolt: _kekw_sloc0_1_0:
.ds 1
_kekw:
jsr _fn
eor #0x05
tax
and #0x03
sta *_kekw_sloc0_1_0
txa
sec
sbc *_kekw_sloc0_1_0
rts