sim2c
741 Bytes
#! /bin/sh
if [ -d /usr/share/sim2c ]; then
LIBDIR=/usr/share/sim2c
else
LIBDIR=$PWD
fi
( cat $LIBDIR/defs.m4
cat $LIBDIR/prologue.m4
tr 'A-Z' 'a-z' | \
sed \
-e 's/[ ]*[;#].*//' \
-e '/^[ ]*$/d' \
-e 's/^[ ][ ]*//' \
-e 's/^push[ ]\(.*\)/push(\1)/' \
-e 's/\([a-zA-Z][a-zA-Z0-9_]*\):[ ]*\.word[ ]*\(.*\)/_def_word_(\1,\2)/' \
-e 's/\([a-zA-Z][a-zA-Z0-9_]*\):[ ]*\.space[ ]*\(.*\)/_def_space_(\1,\2)/' \
-e 's/^\([a-zA-Z][a-zA-Z0-9_]*\):/label(\1)/' \
-e 's/^\.word[ ]*\([-0-9][0-9]*\)/_word_(\1)/' \
-e 's/^\.word[ ]*\(.*\)/_word_(\1)/' \
-e 's/^\.data$/_data_/' \
-e 's/^\.text$/_text_/'
cat $LIBDIR/epilogue.m4 ) | m4 '-DLIBDIR=`'$LIBDIR"'"