main.c:
#include <stdint.h>
uint8_t getRandomNumber(){
uint8_t whatever = 4;
for(uint8_t i = 0; i < 4; ++i){
++whatever;
--whatever;
}
whatever %= 7;
return whatever;
}
void main(){
getRandomNumber();
}
compile.sh:
#!/bin/sh
CFLAGS="--debug --nolospre --no-peep --nogcse"
CC="${SDCCBIN}sdcc -mgbz80 --fsigned-char -c ${CFLAGS}"
LD="${SDCCBIN}sdldgb"
mkdir -p build
${CC} -o build/main.rel main.c
${LD} -nmyjwxi build/main.ihx build/main.rel
There are a couple of things going wrong with this main.c
i if --nogcse is used:S:Lmain.getRandomNumber$i$1_0$1({1}SC:U),R,0,0,[]whatever %= 7; should be promoted to integer.for(i = 0; i < 4; ++i)but not for for(uint8_t i = 0; i < 4; ++i)--noloopreverse should be enabled by --debug
Diff: