#! /bin/sh

#
# CONFIGURATION SECTION
#
if [ -z "$PIC30_CD" ]; then
    echo "Environmental variable PIC30_CD must be set up.";
    exit 1;
fi

AS30=$PIC30_CD/bin/pic30-as
NM30=$PIC30_CD/bin/pic30-nm

#
# END CONFIGURATION
#

# process args
vflag=off
while [ $# -gt 0 ]
do
    case "$1" in
        -v)  vflag=on;;
    esac
    shift
done

rm -f t.exe
$AS30 -o t1.o t1.s || exit 99
err=$?
if [ $vflag = "on" ]; then
    echo "$AS30 -o t1.o t1.s"
    echo $err
fi

if [ $vflag = "on" ]; then
    $NM30 t1.o || exit 99
    echo
fi

rm -f test.out
$NM30 t1.o > test.out

echo
echo `head -1 info.txt`

if [ $vflag = "on" ]; then
    diff -b -B test.out expect.out
else
    diff -b -B test.out expect.out > /dev/null
fi


if [ $? -ne 0 ]; then
    echo "ERRORs Detected!!"
    echo
    exit 199
fi

echo "All Tests Pass"
echo
exit 0
