I looked at this a few month ago and the conclusion is that it will take a
lot of work to succed. The ARMASM and GNUASM differs a lot, both in
functioncall and parameters. However, is it a small file you shall convert
then it will probably go with a macro since you manually can check the
resulting code afterwards but in my case i wanted to convert a whole bunch
of file at the same time and that was a disaster. But as a start there are
some difference in the language that are easy to write in a macro and those
are:
';' -> '@'
IMPORT -> .globl
EXPORT -> .globl
Labels skall ha semicolon efter sig
:AND: -> &
:NOT: -> ~
:OR: -> |
:SHL: -> <<
LABEL EQU 1 -> #define LABEL 1
INCLUDE file.inc -> #include "file.inc"
END -> .end
Regards, Daniel
Joy Kull <jo...@pv.com> wrote in message
news:11431ee2.01102...@posting.google.com...
---8<---8<---8<---
# ads2gas.pl
# Author: Eric Fung (efung (at) acm.org)
#
# Convert ARM Developer Suite 1.0.1 syntax assembly source to GNU as format
#
# Usage: cat inputfile | perl ads2gas.pl > outputfile
#
while (<STDIN>) {
# Comment character
s/;/@/g;
# Hexadecimal constants prefaced by 0x
s/#&/#0x/g;
# Code directive (ARM vs Thumb)
s/CODE([0-9][0-9])/.code $1/;
# No AREA required
s/^\s*AREA.*$/.text/;
# Make function visible to linker, and make additional symbol with
# prepended underscore
s/EXPORT\s+\|(\w*)\|/.global _$1\n.global $1/;
# No vertical bars required; make additional symbol with prepended
# underscore
s/^\|(\w+)\|/_$1\n$1:/g;
# Labels need trailing colon
s/^(\w+)/$1:/ if !/EQU/;
# EQU directive
s/(.*)EQU(.*)/.equ $1, $2/;
# Begin macro definition
if (/MACRO/) {
$_ = <STDIN>;
s/^/.macro/;
s/\$//g; # remove formal param reference
s/;/@/g; # change comment characters
}
# For macros, use \ to reference formal params
s/\$/\\/g;
# End macro definition
s/MEND/.endm/;
# No need to tell it where to stop assembling
next if /^\s*END\s*$/;
print;
}
---8<---8<---8<---
In article <11431ee2.01102...@posting.google.com>,
--
..
Eric
Thanks for your help. We ended up using a Perl script (much like
Eric's) to do the conversion.
Regards,
Joy