ARM assembler to GNU assembler

Peter Naulls peter at chocky.org
Sat Oct 4 06:01:55 PDT 2003



Below is a script I'm using for conversion.  It's a series of evil
regexps (customarily uncommented), which do most of the required
conversions.  One thing I don't have any sensisble replacment for is
:LEN:

My regexps are functional, but not great.  Any improvements suggested.


#!/bin/bash


sed    -e '/\tAREA/d' \
       -e '/\tIMPORT/d' \
       -e '/\tASSERT/d' \
       -e 's/EXPORT/\.global/' \
       -e s#\|\\\(.*\\\)\|#\\1:# \
       -e s#\\\(\.global.*\\\):#\\1# \
       -e '/[^M]END$/d' | \
sed -r -e s#\([_A-Za-z0-9]+\):*["\t "]+"EQU"["\t "]+\(.+\)#".equ\t"\\1", "\\2# \
       -e s#^"\t\["#"\t.if"# \
       -e s#^"\t\|"#"\t.else"# \
       -e s#^"\t\]"#"\t.endif"# \
       -e s#\.if\(["\t _A-Za-z0-9"]+\)=#.if\\1==# \
       -e s#^\;#\@# \
       -e s#\(["\t "]+\)\;#\\1\@# \
       -e s#\(["\t "]+\)GET\(["\t "]+\)\([_A-Za-z0-9\.\/]+\)#\\1.include\\2\"\\3\"# \
       -e '/["\t "]+RN["\t "]+/d' \
       -e '/["\t "]+FN["\t "]+/d' \
       -e s#\&\([0-9A-Fa-f]\)#0x\\1#g \
       -e s#2_\([01]\)#0b\\1#g \
       -e s#DCD#.word# \
       -e s#DCB#.ascii# \
       -e s#ALIGN#.align# \
       -e '/MACRO/N;s/MACRO/\.macro/;s/\n/ /' \
       -e s#MEND#.endm# \
       -e s#:AND:#"\&"#g \
       -e s#:OR:#"\|"#g \



-- 
Peter Naulls - peter at chocky.org        | http://www.chocky.org/
----------------------------------------------------------------------------
Free RISC OS Hosting                   | http://www.prowl.org/




More information about the gcc mailing list