Home | History | Annotate | Line # | Download | only in fpsp
asm2gas revision 1.6
      1  1.1  mycroft #!/bin/sh
      2  1.6       is #	$NetBSD: asm2gas,v 1.6 2000/12/06 21:31:05 is Exp $
      3  1.1  mycroft 
      4  1.1  mycroft #
      5  1.5  mycroft # Copyright (c) 1998 The NetBSD Foundation, Inc.
      6  1.5  mycroft # All rights reserved.
      7  1.5  mycroft #
      8  1.5  mycroft # This code is derived from software contributed to The NetBSD Foundation
      9  1.5  mycroft # by Charles M. Hannum.
     10  1.1  mycroft #
     11  1.1  mycroft # Redistribution and use in source and binary forms, with or without
     12  1.1  mycroft # modification, are permitted provided that the following conditions
     13  1.1  mycroft # are met:
     14  1.1  mycroft # 1. Redistributions of source code must retain the above copyright
     15  1.1  mycroft #    notice, this list of conditions and the following disclaimer.
     16  1.1  mycroft # 2. Redistributions in binary form must reproduce the above copyright
     17  1.1  mycroft #    notice, this list of conditions and the following disclaimer in the
     18  1.1  mycroft #    documentation and/or other materials provided with the distribution.
     19  1.1  mycroft # 3. All advertising materials mentioning features or use of this software
     20  1.1  mycroft #    must display the following acknowledgement:
     21  1.5  mycroft #        This product includes software developed by the NetBSD
     22  1.5  mycroft #        Foundation, Inc. and its contributors.
     23  1.5  mycroft # 4. Neither the name of The NetBSD Foundation nor the names of its
     24  1.5  mycroft #    contributors may be used to endorse or promote products derived
     25  1.5  mycroft #    from this software without specific prior written permission.
     26  1.1  mycroft #
     27  1.5  mycroft # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     28  1.5  mycroft # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     29  1.5  mycroft # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     30  1.5  mycroft # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     31  1.5  mycroft # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     32  1.5  mycroft # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     33  1.5  mycroft # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     34  1.5  mycroft # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     35  1.5  mycroft # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     36  1.5  mycroft # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     37  1.5  mycroft # POSSIBILITY OF SUCH DAMAGE.
     38  1.1  mycroft #
     39  1.1  mycroft 
     40  1.1  mycroft # This ugly script converts assembler code from Motorola's format to a
     41  1.1  mycroft # form that gas (MIT syntax) can digest.
     42  1.1  mycroft 
     43  1.1  mycroft cat $1 | sed -e '
     44  1.2  mycroft   # format canonicalization
     45  1.2  mycroft 
     46  1.1  mycroft   /[ 	]IDNT[ 	]/{s/^/|/;p;d;}
     47  1.2  mycroft   /^\*/{s//|/;p;d;}
     48  1.1  mycroft   s/;/|/
     49  1.1  mycroft   /[ 	]equ[ 	]/{
     50  1.1  mycroft     s/\([A-Za-z_][A-Za-z0-9_]*\)[ 	]*equ[ 	]*/\1,/
     51  1.1  mycroft     s/[ 	][ 	]*\(.*\)$/		|\1/
     52  1.1  mycroft     s/		||/		|/
     53  1.1  mycroft     s/^/	.set	/
     54  1.1  mycroft     p;d
     55  1.1  mycroft   }
     56  1.1  mycroft   s/^\([A-Za-z_][A-Za-z0-9_]*\)[ 	][ 	]*/\1:	/
     57  1.1  mycroft   s/^\([A-Za-z_][A-Za-z0-9_]*\)$/\1:/
     58  1.1  mycroft   /^[A-Za-z_][A-Za-z0-9_]*:/{
     59  1.1  mycroft     h
     60  1.1  mycroft     s/:.*$/:/
     61  1.1  mycroft     p
     62  1.1  mycroft     g
     63  1.1  mycroft     s/^.*:[ 	]*/	/
     64  1.1  mycroft     /^	$/d
     65  1.1  mycroft   }
     66  1.2  mycroft   /^[ 	][ 	]*\([.a-zA-Z][.a-zA-Z0-9]*\)/{
     67  1.1  mycroft     h
     68  1.2  mycroft     s///
     69  1.2  mycroft     s/^[ 	][ 	]*//
     70  1.1  mycroft     s/[ 	][ 	]*\(.*\)$/		|\1/
     71  1.1  mycroft     s/		||/		|/
     72  1.1  mycroft     x
     73  1.2  mycroft     s/^[ 	][ 	]*//
     74  1.1  mycroft     s/[ 	][ 	]*.*$/	/
     75  1.1  mycroft     y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
     76  1.1  mycroft     s/^/	/
     77  1.1  mycroft     G
     78  1.1  mycroft     s/\n//
     79  1.1  mycroft   }
     80  1.1  mycroft ' | sed -e '
     81  1.2  mycroft   # operator conversion
     82  1.2  mycroft 
     83  1.2  mycroft   s/^	section	7/	.text/
     84  1.2  mycroft   s/^	section	8/	.text/
     85  1.2  mycroft   s/^	section	15/	.data/
     86  1.2  mycroft   /^	include/{s/include[ 	]/.include "/;s/\.h[ 	]*$/.defs"/;p;d;}
     87  1.2  mycroft   s/^	xref/|	xref/
     88  1.2  mycroft   s/^	end/|	end/
     89  1.2  mycroft   s/^	xdef/	.global/
     90  1.2  mycroft 
     91  1.2  mycroft   s/^	dc\.l/	.long/
     92  1.2  mycroft   s/^	dc\.w/	.short/
     93  1.2  mycroft   s/^	dc\.b/	.byte/
     94  1.2  mycroft 
     95  1.2  mycroft   /^	[aceg-z]/{
     96  1.2  mycroft     /^	add[aiqx]*\.[bwl]	/{s/\.//;p;d;}
     97  1.2  mycroft     /^	andi*\.[bwl]	/{s/\.//;p;d;}
     98  1.2  mycroft     /^	as[lr]\.[bwl]	/{s/\.//;p;d;}
     99  1.2  mycroft     /^	clr\.[bwl]	/{s/\.//;p;d;}
    100  1.2  mycroft     /^	cmp[i2]*\.[bwl]	/{s/\.//;p;d;}
    101  1.2  mycroft     /^	eori*\.[bwl]	/{s/\.//;p;d;}
    102  1.2  mycroft     /^	lea\.l	/{s/\..//;p;d;}
    103  1.2  mycroft     /^	ls[lr]\.[bwl]	/{s/\.//;p;d;}
    104  1.2  mycroft     /^	move[acmqs]*\.[bwl]	/{s/\.//;p;d;}
    105  1.2  mycroft     /^	mul[su]\.[wl]	/{s/\.//;p;d;}
    106  1.2  mycroft     /^	neg\.[bwl]	/{s/\.//;p;d;}
    107  1.2  mycroft     /^	ori*\.[bwl]	/{s/\.//;p;d;}
    108  1.2  mycroft     /^	ro[lrx]*\.[bwl]	/{s/\.//;p;d;}
    109  1.2  mycroft     /^	sub[aiqx]*\.[bwl]	/{s/\.//;p;d;}
    110  1.2  mycroft     /^	swap\.w	/{s/\..//;p;d;}
    111  1.2  mycroft     /^	s\([a-tv-z][a-z]*\)\.b	/{s/\..//;p;d;}
    112  1.2  mycroft     /^	tst\.[bwl]	/{s/\.//;p;d;}
    113  1.2  mycroft     p;d
    114  1.2  mycroft   }
    115  1.2  mycroft 
    116  1.2  mycroft   /^	bchg\.[bl]	/{s/\..//;p;d;}
    117  1.2  mycroft   /^	bclr\.[bl]	/{s/\..//;p;d;}
    118  1.2  mycroft   /^	bset\.[bl]	/{s/\..//;p;d;}
    119  1.2  mycroft   /^	btst\.[bl]	/{s/\..//;p;d;}
    120  1.2  mycroft   /^	div[sul]*\.[wl]	/{s/\.//;p;d;}
    121  1.2  mycroft   /^	fabs\.[sdx]	/{s/\.//;p;d;}
    122  1.2  mycroft   /^	fadd\.[sdxbwl]	/{s/\.//;p;d;}
    123  1.2  mycroft   /^	fcmp\.[sdxbwl]	/{s/\.//;p;d;}
    124  1.2  mycroft   /^	fdiv\.[sdx]	/{s/\.//;p;d;}
    125  1.2  mycroft   /^	fmove[mx]*\.[sdxbwl]	/{s/\.//;p;d;}
    126  1.2  mycroft   /^	fmul\.[sdx]	/{s/\.//;p;d;}
    127  1.2  mycroft   /^	fneg\.[sdx]	/{s/\.//;p;d;}
    128  1.2  mycroft   /^	fsqrt\.[sdx]	/{s/\.//;p;d;}
    129  1.2  mycroft   /^	fsub\.[sdxbwl]	/{s/\.//;p;d;}
    130  1.2  mycroft   /^	ftst\.[sdx]	/{s/\.//;p;d;}
    131  1.2  mycroft 
    132  1.2  mycroft   /^	b[a-eg-z][a-z]*\.b	/{s/\.b/s/;p;d;}
    133  1.2  mycroft   /^	b[a-eg-z][a-z]*\.w	/{s/\.w//;p;d;}
    134  1.2  mycroft   /^	b[a-eg-z][a-z]*\.l	/{s/\.l/l/;p;d;}
    135  1.2  mycroft   /^	db[a-z][a-z]*\.w	/{s/\.w//;p;d;}
    136  1.2  mycroft   /^	fb[a-eg-z][a-z]*\.w	/{s/\.w//;p;d;}
    137  1.2  mycroft   /^	fb[a-eg-z][a-z]*\.l	/{s/\.l/l/;p;d;}
    138  1.1  mycroft ' | sed -e '
    139  1.2  mycroft   # operand conversion
    140  1.2  mycroft 
    141  1.6       is   s/\([^_a-zA-Z0-9]\)FPIAR\([^_a-zA-Z0-9]\)/\1%FPI\2/g
    142  1.6       is   s/\([^_a-zA-Z0-9]\)FPIAR$/\1%FPI/g
    143  1.6       is   s/\([^_a-zA-Z0-9]\)fpiar\([^_a-zA-Z0-9]\)/\1%fpi\2/g
    144  1.6       is   s/\([^_a-zA-Z0-9]\)fpiar$/\1%fpi/g
    145  1.6       is   s/\([^_a-zA-Z0-9]\)FPCR\([^_a-zA-Z0-9]\)/\1%FPCR\2/g
    146  1.6       is   s/\([^_a-zA-Z0-9]\)FPCR$/\1%FPCR/g
    147  1.6       is   s/\([^_a-zA-Z0-9]\)fpcr\([^_a-zA-Z0-9]\)/\1%fpcr\2/g
    148  1.6       is   s/\([^_a-zA-Z0-9]\)fpcr$/\1%fpcr/g
    149  1.6       is   s/\([^_a-zA-Z0-9]\)FPSR\([^_a-zA-Z0-9]\)/\1%FPSR\2/g
    150  1.6       is   s/\([^_a-zA-Z0-9]\)FPSR$/\1%FPSR/g
    151  1.6       is   s/\([^_a-zA-Z0-9]\)fpsr\([^_a-zA-Z0-9]\)/\1%fpsr\2/g
    152  1.6       is   s/\([^_a-zA-Z0-9]\)fpsr$/\1%fpsr/g
    153  1.2  mycroft 
    154  1.2  mycroft   s/\$/0x/g
    155  1.2  mycroft   s/#:/#:0x/g
    156  1.2  mycroft 
    157  1.6       is   s/\([^[:alnum:]_]\)\([dDaA][0-7]\)\([^[:alnum:]_]\)/\1%\2\3/g
    158  1.6       is   s/\([^[:alnum:]_]\)\([fF][pP][0-7]\)\([^[:alnum:]_]\)/\1%\2\3/g
    159  1.6       is   s/\([^[:alnum:]_]\)\(sp\)\([^[:alnum:]_]\)/\1%\2\3/g
    160  1.6       is   s/\([^[:alnum:]_]\)\(pc\)\([^[:alnum:]_]\)/\1%\2\3/g
    161  1.6       is 
    162  1.6       is   s/\([^[:alnum:]_]\)\([dDaA][0-7]\)$/\1%\2/g
    163  1.6       is   s/\([^[:alnum:]_]\)\([fF][pP][0-7]\)$/\1%\2/g
    164  1.6       is   s/\([^[:alnum:]_]\)\(sp\)$/\1%\2/g
    165  1.6       is 
    166  1.6       is   s/\(,\)\([dDaA][0-7]\)/\1%\2/g
    167  1.6       is   s/\(,\)\([fF][pP][0-7]\)/\1%\2/g
    168  1.6       is 
    169  1.6       is   s/-(\(%[sSpPaA][pPcC0-7]\))/\1@-/g
    170  1.6       is   s/(\(%[sSpPaA][pPcC0-7]\))+/\1@+/g
    171  1.6       is   s/\([-+A-Za-z0-9_]*\)(\(%[sSpPaA][pPcC0-7]\)\([),]\)/\2@(\1\3/g
    172  1.1  mycroft 
    173  1.1  mycroft   s/\.\([bBwWlL])\)/:\1/g
    174  1.1  mycroft   s/\.\([bBwWlL]\)\*\([0-9][0-9]*)\)/:\1:\2/g
    175  1.1  mycroft   s/\*\([0-9][0-9]*\))/:l:\1)/g
    176  1.1  mycroft   s/{\([0-9][0-9]*\):\([0-9][0-9]*\)}/{#\1:#\2}/g
    177  1.6       is   s/{\(%[dD][0-7]\):\([0-9][0-9]*\)}/{\1:#\2}/g
    178  1.6       is   s/{\([dD][0-7]\):\([0-9][0-9]*\)}/{%\1:#\2}/g
    179  1.6       is   s/{\([dD][0-7]\):\(%[dD][0-9]*\)}/{%\1:\2}/g
    180  1.6       is 
    181  1.6       is   s/\(-\)\([dDaA][0-7]\)\([^_a-zA-Z0-9]\)/\1%\2\3/g
    182  1.6       is   s/\(-\)\([fF][pP][0-7]\)\([^_a-zA-Z0-9]\)/\1%\2\3/g
    183  1.6       is 
    184  1.6       is   s/\(\/\)\([dDaA][0-7]\)\([^_a-zA-Z0-9]\)/\1%\2\3/g
    185  1.6       is   s/\(\/\)\([fF][pP][0-7]\)\([^_a-zA-Z0-9]\)/\1%\2\3/g
    186  1.1  mycroft 
    187  1.2  mycroft   s/@(0*)/@/g
    188  1.1  mycroft   s/(,/(/g;s/:)/)/g
    189  1.1  mycroft 
    190  1.1  mycroft   # make up for a gas bug
    191  1.1  mycroft   /^	fmovemx	/{
    192  1.6       is 	s/	\(%[fF][pP][0-7]\),/	\1-\1,/
    193  1.6       is 	s/,\(%[fF][pP][0-7]\)	/,\1-\1	/
    194  1.6       is 	s/,\(%[fF][pP][0-7]\)$/,\1-\1/
    195  1.1  mycroft   }
    196  1.6       is ' | sed -e '
    197  1.6       is   # Floating point literal conversion
    198  1.6       is 
    199  1.6       is   s/:0x41dfffffffc00000/0r2147483647.0/g
    200  1.6       is   s/:0xc1e0000000000000/0r-2147483648.0/g
    201  1.6       is   s/:0x41dfffffffe00000/0r2147483647.5/g
    202  1.6       is   s/:0xc1e0000000100000/0r-2147483648.5/g
    203  1.6       is   s/:0x46fffe00/0r32767.0/g
    204  1.6       is   s/:0xc7000000/0r-32768.0/g
    205  1.6       is   s/:0x46ffff00/0r32767.5/g
    206  1.6       is   s/:0xc7000080/0r-32768.5/g
    207  1.6       is   s/:0x42fe0000/0r127.0/g
    208  1.6       is   s/:0xc3000000/0r-128.0/g
    209  1.6       is   s/:0x42ff0000/0r127.5/g
    210  1.6       is   s/:0xc3008000/0r-128.5/g
    211  1.6       is   s/:0x3F800000/0r1.0/g
    212  1.6       is   s/:0x00000000/0r0.0/g
    213  1.6       is   s/:0xBF800000/0r-1.0/g
    214  1.6       is   s/:0x3F000000/0r0.5/g
    215  1.6       is   s/:0x3E800000/0r0.25/g
    216  1.6       is   s/:0x42B8AA3B/0r92.332481384277343750/g
    217  1.6       is   s/:0xBC317218/0r-0.0108304247260093688964843750/g
    218  1.6       is   s/:0x3AB60B70/0r0.001388890668749809265136718750/g
    219  1.6       is   s/:0x3C088895/0r0.0083333449438214302062988281250/g
    220  1.6       is   s/:0x42B8AA3B/0r92.332481384277343750/g
    221  1.6       is   s/:0x3950097B/0r0.0001983995753107592463493347167968750/g
    222  1.6       is   s/:0x3AB60B6A/0r0.001388889970257878303527832031250/g
    223  1.6       is   s/:0x2F30CAA8/0r1.60791047143504783889511600136756896972656250e-10/g
    224  1.6       is   s/:0x310F8290/0r2.0883454965314740547910332679748535156250e-09/g
    225  1.6       is   s/:0x32D73220/0r2.5052088403754169121384620666503906250e-08/g
    226  1.6       is   s/:0x3493F281/0r2.755732850800995947793126106262207031250e-07/g
    227  1.6       is   s/:0x40000000/0r2.0/g
    228  1.6       is   s/:0x42800000/0r6.40e+01/g
    229  1.6       is   s/:0x3C800000/0r1.56250e-02/g
    230  1.6       is   s/fadds	#:0x00800000,%[fF][pP]0/	.long	0xf23c4422,0x00800000/
    231  1.6       is   s/fsubs	#:0x00800000,%[fF][pP]0/	.long	0xf23c4428,0x00800000/
    232  1.6       is   s/fsubs	#:0x00800000,%[fF][pP]1/	.long	0xf23c44a8,0x00800000/
    233  1.6       is   s/fmoves	#:0x80000000,%[fF][pP]0/	.long	0xf23c4400,0x80000000/
    234  1.6       is   s/fmoves		#:0x00000000,%[fF][pP]0/	.long	0xf23c4400,0x00000000/
    235  1.6       is 
    236  1.1  mycroft '
    237