1994-07-05 21:56:52 +04:00
|
|
|
#!/bin/sh
|
1998-08-15 07:51:30 +04:00
|
|
|
# $NetBSD: asm2gas,v 1.6 1998/08/15 03:51:31 mycroft Exp $
|
1994-07-05 21:56:52 +04:00
|
|
|
|
|
|
|
#
|
1998-08-15 07:51:30 +04:00
|
|
|
# Copyright (c) 1998 The NetBSD Foundation, Inc.
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
# by Charles M. Hannum.
|
1994-07-05 21:56:52 +04:00
|
|
|
#
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions
|
|
|
|
# are met:
|
|
|
|
# 1. Redistributions of source code must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer in the
|
|
|
|
# documentation and/or other materials provided with the distribution.
|
|
|
|
# 3. All advertising materials mentioning features or use of this software
|
|
|
|
# must display the following acknowledgement:
|
1998-08-15 07:51:30 +04:00
|
|
|
# This product includes software developed by the NetBSD
|
|
|
|
# Foundation, Inc. and its contributors.
|
|
|
|
# 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
# contributors may be used to endorse or promote products derived
|
|
|
|
# from this software without specific prior written permission.
|
1994-07-05 21:56:52 +04:00
|
|
|
#
|
1998-08-15 07:51:30 +04:00
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
# POSSIBILITY OF SUCH DAMAGE.
|
1994-07-05 21:56:52 +04:00
|
|
|
#
|
|
|
|
|
|
|
|
# This ugly script converts assembler code from Motorola's format to a
|
|
|
|
# form that gas (MIT syntax) can digest.
|
|
|
|
|
|
|
|
cat $1 | sed -e '
|
1994-07-07 05:51:18 +04:00
|
|
|
# format canonicalization
|
|
|
|
|
1997-10-01 01:47:22 +04:00
|
|
|
s/^#/|#/
|
1994-07-05 21:56:52 +04:00
|
|
|
/[ ]IDNT[ ]/{s/^/|/;p;d;}
|
1994-07-07 05:51:18 +04:00
|
|
|
/^\*/{s//|/;p;d;}
|
1994-07-05 21:56:52 +04:00
|
|
|
s/;/|/
|
|
|
|
/[ ]equ[ ]/{
|
|
|
|
s/\([A-Za-z_][A-Za-z0-9_]*\)[ ]*equ[ ]*/\1,/
|
|
|
|
s/[ ][ ]*\(.*\)$/ |\1/
|
|
|
|
s/ ||/ |/
|
|
|
|
s/^/ .set /
|
|
|
|
p;d
|
|
|
|
}
|
|
|
|
s/^\([A-Za-z_][A-Za-z0-9_]*\)[ ][ ]*/\1: /
|
|
|
|
s/^\([A-Za-z_][A-Za-z0-9_]*\)$/\1:/
|
|
|
|
/^[A-Za-z_][A-Za-z0-9_]*:/{
|
|
|
|
h
|
|
|
|
s/:.*$/:/
|
|
|
|
p
|
|
|
|
g
|
|
|
|
s/^.*:[ ]*/ /
|
|
|
|
/^ $/d
|
|
|
|
}
|
1994-07-07 05:51:18 +04:00
|
|
|
/^[ ][ ]*\([.a-zA-Z][.a-zA-Z0-9]*\)/{
|
1994-07-05 21:56:52 +04:00
|
|
|
h
|
1994-07-07 05:51:18 +04:00
|
|
|
s///
|
|
|
|
s/^[ ][ ]*//
|
1994-07-05 21:56:52 +04:00
|
|
|
s/[ ][ ]*\(.*\)$/ |\1/
|
|
|
|
s/ ||/ |/
|
|
|
|
x
|
1994-07-07 05:51:18 +04:00
|
|
|
s/^[ ][ ]*//
|
1994-07-05 21:56:52 +04:00
|
|
|
s/[ ][ ]*.*$/ /
|
|
|
|
y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
|
|
|
|
s/^/ /
|
|
|
|
G
|
|
|
|
s/\n//
|
|
|
|
}
|
|
|
|
' | sed -e '
|
1994-07-07 05:51:18 +04:00
|
|
|
# operator conversion
|
|
|
|
|
|
|
|
s/^ section 7/ .text/
|
|
|
|
s/^ section 8/ .text/
|
|
|
|
s/^ section 15/ .data/
|
|
|
|
/^ include/{s/include[ ]/.include "/;s/\.h[ ]*$/.defs"/;p;d;}
|
|
|
|
s/^ xref/| xref/
|
|
|
|
s/^ end/| end/
|
|
|
|
s/^ xdef/ .global/
|
|
|
|
|
|
|
|
s/^ dc\.l/ .long/
|
|
|
|
s/^ dc\.w/ .short/
|
|
|
|
s/^ dc\.b/ .byte/
|
|
|
|
|
|
|
|
/^ [aceg-z]/{
|
|
|
|
/^ add[aiqx]*\.[bwl] /{s/\.//;p;d;}
|
|
|
|
/^ andi*\.[bwl] /{s/\.//;p;d;}
|
|
|
|
/^ as[lr]\.[bwl] /{s/\.//;p;d;}
|
|
|
|
/^ clr\.[bwl] /{s/\.//;p;d;}
|
|
|
|
/^ cmp[i2]*\.[bwl] /{s/\.//;p;d;}
|
|
|
|
/^ eori*\.[bwl] /{s/\.//;p;d;}
|
|
|
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|
|
|
/^ b[a-eg-z][a-z]*\.w /{s/\.w//;p;d;}
|
|
|
|
/^ b[a-eg-z][a-z]*\.l /{s/\.l/l/;p;d;}
|
|
|
|
/^ db[a-z][a-z]*\.w /{s/\.w//;p;d;}
|
|
|
|
/^ fb[a-eg-z][a-z]*\.w /{s/\.w//;p;d;}
|
|
|
|
/^ fb[a-eg-z][a-z]*\.l /{s/\.l/l/;p;d;}
|
1994-07-05 21:56:52 +04:00
|
|
|
' | sed -e '
|
1994-07-07 05:51:18 +04:00
|
|
|
# operand conversion
|
|
|
|
|
|
|
|
s/\([^_a-zA-Z0-9]\)FPIAR\([^_a-zA-Z0-9]\)/\1FPI\2/g
|
|
|
|
s/\([^_a-zA-Z0-9]\)FPIAR\([^_a-zA-Z0-9]\)/\1FPI\2/g
|
|
|
|
s/\([^_a-zA-Z0-9]\)FPIAR$/\1FPI/g
|
1994-07-05 21:56:52 +04:00
|
|
|
s/\([^_a-zA-Z0-9]\)fpiar\([^_a-zA-Z0-9]\)/\1fpi\2/g
|
|
|
|
s/\([^_a-zA-Z0-9]\)fpiar\([^_a-zA-Z0-9]\)/\1fpi\2/g
|
|
|
|
s/\([^_a-zA-Z0-9]\)fpiar$/\1fpi/g
|
|
|
|
|
1997-10-01 01:47:22 +04:00
|
|
|
s/\$\([0-9a-fA-F]\)/0x\1/g
|
1994-07-07 05:51:18 +04:00
|
|
|
s/#:/#:0x/g
|
1994-07-05 21:56:52 +04:00
|
|
|
|
1994-07-07 05:51:18 +04:00
|
|
|
s/-(\([sSpPaA][pPcC0-7]\))/\1@-/g
|
|
|
|
s/(\([sSpPaA][pPcC0-7]\))+/\1@+/g
|
|
|
|
s/\([-+A-Za-z0-9_]*\)(\([sSpPaA][pPcC0-7]\)\([),]\)/\2@(\1\3/g
|
1994-07-05 21:56:52 +04:00
|
|
|
|
|
|
|
s/\.\([bBwWlL])\)/:\1/g
|
|
|
|
s/\.\([bBwWlL]\)\*\([0-9][0-9]*)\)/:\1:\2/g
|
|
|
|
s/\*\([0-9][0-9]*\))/:l:\1)/g
|
|
|
|
s/{\([0-9][0-9]*\):\([0-9][0-9]*\)}/{#\1:#\2}/g
|
1994-07-07 05:51:18 +04:00
|
|
|
s/{\([dD][0-7]\):\([0-9][0-9]*\)}/{\1:#\2}/g
|
1994-07-05 21:56:52 +04:00
|
|
|
|
1994-07-07 05:51:18 +04:00
|
|
|
s/@(0*)/@/g
|
1994-07-05 21:56:52 +04:00
|
|
|
s/(,/(/g;s/:)/)/g
|
|
|
|
|
|
|
|
# make up for a gas bug
|
|
|
|
/^ fmovemx /{
|
1994-07-07 05:51:18 +04:00
|
|
|
s/ \([fF][pP][0-7]\),/ \1-\1,/
|
|
|
|
s/,\([fF][pP][0-7]\) /,\1-\1 /
|
|
|
|
s/,\([fF][pP][0-7]\)$/,\1-\1/
|
1994-07-05 21:56:52 +04:00
|
|
|
}
|
|
|
|
'
|