#!/bin/sh
#
# mitToIris - convert mit format assembler to iris format
#
# modification history
# --------------------
# 01b,5nov87,jlf   Documentation update, mod history added
#
# SYNOPSIS: mitToIris [files...]
#
# DESCRIPTION
# This script reads the specified files (or standard input if no files
# are specified) as MIT format assembly language and writes to standard output
# the corresponding IRIS format assembly language.
#
# The transformations that take place involve putting all labels alone on
# their own line, translating "move[bwl]" into "mov[bwl]", and translating
# "tas" into "tasb".
#*/

# iris sed can't eat comments "#" when reading from a file??

cat <<'EOF' | sed -e "\1#1D" >mitToIris_sed.tmp

# put labels on their own line

/^[a-zA-Z0-9_\$\.]*[ 	]*:.*[^ 	].*/s/:/:\
/

# output labels and delete them from current line
/^[a-zA-Z0-9_\$\.]*[ 	]*:/{
P
D
}

# move[bwl] -> mov[bwl]
# tas	    -> tasb

s/^[ 	]move\([bwl]\)/	mov\1/
s/^[ 	]tas/	tasb/


EOF

sed -f mitToIris_sed.tmp $*

rm mitToIris_sed.tmp
