EtchedPixels / Fuzix-Compiler-Kit

Fuzix C Compiler Project
Other
49 stars 14 forks source link

add wtests/onetest6800 wtests/runtests6800 #136

Closed zu2 closed 4 weeks ago

zu2 commented 1 month ago

onetest6800

#!/bin/sh

if [ "$#" -ne 1 ]
then echo "Usage: $0 c_file"; exit 1
fi

# Make cprintf.o
fcc -m6800 -O -c cprintf.c

b=$(basename $1 .c)
echo "$1:"
fcc -m6800 -O -c $b.c

ld6800 -v -b -C256 -Z0 -m $b.map -o $b ../testcrt0_6800.o cprintf.o $b.o /opt/fcc/lib/6800/lib6800.a  /opt/fcc/lib/6800/libc.a
../emu6800 6800 $b $b.map 2> $b.log
#rm -f $b.o $b $b.map 
fcc -m6800 -O -S $b.c

runtest6800

#!/bin/sh
# Run each test and compare
# against known good output

# Make cprintf.o
fcc -m6800 -O -c cprintf.c

# Try to use each input source file
for i in input*c
# We can't do anything if there's no file to test against
do if [ ! -f "out.$i" -a ! -f "err.$i" ]
   then echo "Can't run test on $i, no output file!"

   # Output file: compile the source, run it and
   # capture the output, and compare it against
   # the known-good output
   else if [ -f "out.$i" ]
        then
      # Print the test name, compile it
      # with our compiler
      b=$(basename $i .c)
          echo -n $i
      fcc -m6800 -O -c $b.c
      echo $b*

      # Link the output, run it
      # and get the output in trial.$i

      ld6800 -v -b -C256 -Z0 -m $b.map -o $b ../testcrt0_6800.o cprintf.o $b.o /opt/fcc/lib/6800/lib6800.a  /opt/fcc/lib/6800/libc.a
#     ld6800 -v -b -C256 -Z0 -m \
#       ../testcrt0_6800.o cprintf.o \
#       $b.o -o $b  \
#       /opt/fcc/lib/6800/lib6800.a
#     ld6800 -b -C256 \
#       ../testcrt0_6800.o cprintf.o \
#       $b.o -o $b \
#       /opt/fcc/lib/6800/lib6800.a
      ../emu6800 6800 $b $b.map > trial.$i
      rm -f $b.o $b $b.map

      # Compare this agains the correct output
          cmp -s "out.$i" "trial.$i"

      # If different, announce failure
          # and print out the difference
          if [ "$?" -eq "1" ]
          then echo ": failed"
            diff -c "out.$i" "trial.$i"
            echo

      # No failure, so announce success
          else echo ": OK"
          fi

   # Error file: compile the source and
   # capture the error messages. Compare
   # against the known-bad output. Same
   # mechanism as before.
   #
   # NOTE: Warren took out all these tests
   # as the fcc error messages are different
   # to the acwj error messages.
   #
   else if [ -f "err.$i" ]
        then
          echo -n $i
          ../comp1 $i 2> "trial.$i"
          cmp -s "err.$i" "trial.$i"
          if [ "$?" -eq "1" ]
          then echo ": failed"
            diff -c "err.$i" "trial.$i"
            echo
          else echo ": OK"
          fi
        fi
     fi
   fi
   rm -f out out.s "trial.$i"
done
zu2 commented 1 month ago

testcrt0_6800.s was not unwinding the stack, which caused wtest/input010.c to fail.

--- ../Fuzix-Compiler-Kit/test/testcrt0_6800.s  2024-10-13 22:57:57
+++ test/testcrt0_6800.s    2024-10-27 13:08:02
@@ -48,11 +48,21 @@
    ldaa 2,x
    staa $fefc
    stab $fefc+1
-   rts
+   ldx 0,x
+   ins
+   ins
+   ins
+   ins
+   jmp 0,x

    .export _printchar
 _printchar:
    tsx
    ldab 3,x
    stab $FEFE
-   rts
+   ldx 0,x
+   ins
+   ins
+   ins
+   ins
+   jmp 0,x
EtchedPixels commented 4 weeks ago

Thanks