MEGA65 / mega65-libc

Simple C library for the MEGA65
Other
25 stars 20 forks source link

Fix fc_nyblswap on LLVM #60

Closed zeldin closed 3 months ago

zeldin commented 3 months ago

With a constraint "a", %0 will expand to "A" in the asm, meaning "ld%0" will become "ldA" without any address. But since we have constrained the operand to already be in A, there is no need to add any load or store instructions anyway, so just remove them.

Also the global variable "swp" is not needed either, so remove that as well when using LLVM.

Checklist

Thanks a lot for your contribution! Please tick off the following:

Also tested palette loading with xemu, worked fine both with cc65 and llvm-mos. Without this fix linking fails on llvm-mos with:

ld.lld: error: ld-temp.o <inline asm>:1:2: too few operands for instruction
        ldA
        ^
ld.lld: error: ld-temp.o <inline asm>:8:1: too few operands for instruction
stA
^
ld.lld: error: ld-temp.o <inline asm>:1:2: too few operands for instruction
        ldA
        ^
ld.lld: error: ld-temp.o <inline asm>:8:1: too few operands for instruction
stA
^
ld.lld: error: ld-temp.o <inline asm>:1:2: too few operands for instruction
        ldA
        ^
ld.lld: error: ld-temp.o <inline asm>:8:1: too few operands for instruction
stA
^
mos-mega65-clang: error: ld.lld command failed with exit code 1 (use -v to see invocation)