#!/bin/sh
#FILE
#	conv2mri
#
#	Copyright(c) 1995, FMI, Fujitsu Microelectronics, Inc.
#	All rights reserved.
#
#	This software (including any documentation) is untested, has not been
#	fully tested for viruses and has been provided to you without charge.
#	ACCORDINGLY, IT IS DELIVERED "AS IS" WITH NO WARRANTIES EXPRESS OR
#	IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY,
#	FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.  You bear all 
#	risk of nonperformance, loss of data and other problems and Fujitsu
#	Microelectronics, Inc. and Fujitsu Limited will not be liable under any
#	contract, negligence, strict liability or other theory for any damages
#	including, without limitation, direct, consequential or incidental nor
#	be required to provide substitute goods, services or technology.
#
# This file contains a UNIX shell script that converts the assembly (.s)
#   files in ../src from Cygnus/SUN assembler compatible to MRI compatible.
#
# To invoke, type:
#	conv2mri filename
#
# This conversion program is very specific to the src files in ../src and
#   is not a general purpose conversion program for MRI.  Any changes to
#   the ../src files may result in unpredictable behavior.  The output of
#   this program should be checked extensively for proper conversion.

sed 's/\/\*/!/' ../src/$1 \
	| sed 's/\*\///' \
	| sed 's/\#ifdef/\.ifdef/'  \
	| sed 's/\#ifndef/\.ifndef/' \
	| sed 's/\#endif/\.endif/' \
	|  sed 's/\#else/\.else/'  \
	| sed '/\#.*define.*(.*[^\\]$/s/$/\
.endm/' \
	| sed '/\#.*define.*(.*).*\\/s/\\//' \
	| sed '/\#.*define.*(.*)[ 	$]/s/)/)\
/' \
	| sed '/\#.*define.*(/s/\#.*define/.macro/' \
	| sed '/\.macro.*(.*)/s/(/,/' \
	| sed '/\.macro.*,.*)/s/)//' \
	| sed '/\.macro.*CC1/s/\\//' \
	| sed '/^[^\.].*CC1_.*(/s/)//' \
	| sed '/^[^\.].*CC1_.*(/s/(//' \
	| sed '\/ALIGN.*;.*\\/s/(src).*;.*\\/ src/' \
	| sed '\/ALIGN/s/(dest)/ dest/' \
	| sed '/CC1_ASI.*;.*\\/s/;.*\\//' \
	| sed 's/\#.*define/\.def   /' \
	| sed 's/\.def[ 	]*[^ 	]*/&,/' \
	| sed 's/\#include/\.include/' \
	| sed '/! End macro/s/^/.endm /' \
	| sed 's/_edata/edata/' \
	> $1
