#!/bin/bash -x
set -e
for i in hw3 hw3a ; do ../../816-tcc -I. -o $i.asm -c $i.c ; done
for i in hw3 hw3a ; do python ../../816-opt.py $i.asm >$i.opt.asm ; done
#for i in hw3 hw3a ; do cp $i.asm $i.opt.asm ; done
for i in hw3 hw3a ; do ../../../wla_dx/wla-65816 -io $i.opt.asm $i.obj ; done
../../../wla_dx/wla-65816 -io asmfptest.asm asmfptest.obj
../../../wla_dx/wlalink/wlalink -dvSn test.lnk test.smc
gcc -m32 hw3.c hw3a.c
./a.out >output.gcc || true
../../../bsnes/bsnes test.smc >output.snes || exit 1
diff -u output.gcc output.snes
rm -f hw3.asm hw3a.asm test.sym test.smc hw3.obj hw3a.obj output.gcc a.out output.snes
