Commit b0e1c5f8 authored by Ahmad Sharif's avatar Ahmad Sharif
Browse files

ads2gas.pl: various enhancements to work with flash.

TEST=Ran it on different asm files.

Change-Id: Ief2a009366787954d0eb5c356c64acaef350cf84
Showing with 34 additions and 4 deletions
...@@ -26,12 +26,22 @@ print "\t.equ DO1STROUNDING, 0\n"; ...@@ -26,12 +26,22 @@ print "\t.equ DO1STROUNDING, 0\n";
while (<STDIN>) while (<STDIN>)
{ {
undef $comment;
undef $line;
$comment_char = ";";
$comment_sub = "@";
# Handle comments.
if (/$comment_char/)
{
$comment = "";
($line, $comment) = /(.*?)$comment_char(.*)/;
$_ = $line;
}
# Load and store alignment # Load and store alignment
s/@/,:/g; s/@/,:/g;
# Comment character
s/;/@/g;
# Hexadecimal constants prefaced by 0x # Hexadecimal constants prefaced by 0x
s/#&/#0x/g; s/#&/#0x/g;
...@@ -62,6 +72,17 @@ while (<STDIN>) ...@@ -62,6 +72,17 @@ while (<STDIN>)
# Convert LTORG to .ltorg # Convert LTORG to .ltorg
s/LTORG/.ltorg/g; s/LTORG/.ltorg/g;
# Convert endfunc to nothing.
s/endfunc//ig;
# Convert FUNCTION to nothing.
s/FUNCTION//g;
s/function//g;
s/ENTRY//g;
s/MSARMASM/0/g;
s/^\s+end\s+$//g;
# Convert IF :DEF:to .if # Convert IF :DEF:to .if
# gcc doesn't have the ability to do a conditional # gcc doesn't have the ability to do a conditional
# if defined variable that is set by IF :DEF: on # if defined variable that is set by IF :DEF: on
...@@ -106,6 +127,7 @@ while (<STDIN>) ...@@ -106,6 +127,7 @@ while (<STDIN>)
if (s/RN\s+([Rr]\d+|lr)/.req $1/) if (s/RN\s+([Rr]\d+|lr)/.req $1/)
{ {
print; print;
print "$comment_sub$comment\n" if defined $comment;
next; next;
} }
...@@ -114,6 +136,9 @@ while (<STDIN>) ...@@ -114,6 +136,9 @@ while (<STDIN>)
s/EXPORT\s+\|([\$\w]*)\|/.global $1 \n\t.type $1, function/; s/EXPORT\s+\|([\$\w]*)\|/.global $1 \n\t.type $1, function/;
s/IMPORT\s+\|([\$\w]*)\|/.global $1/; s/IMPORT\s+\|([\$\w]*)\|/.global $1/;
s/EXPORT\s+([\$\w]*)/.global $1/;
s/export\s+([\$\w]*)/.global $1/;
# No vertical bars required; make additional symbol with prepended # No vertical bars required; make additional symbol with prepended
# underscore # underscore
s/^\|(\$?\w+)\|/_$1\n\t$1:/g; s/^\|(\$?\w+)\|/_$1\n\t$1:/g;
...@@ -129,6 +154,10 @@ while (<STDIN>) ...@@ -129,6 +154,10 @@ while (<STDIN>)
# ARM code # ARM code
s/\sARM/.arm/g; s/\sARM/.arm/g;
# NEON code
s/(vld1.\d+\s+)(q\d+)/$1\{$2\}/g;
s/(vtbl.\d+\s+[^,]+),([^,]+)/$1,\{$2\}/g;
# eabi_attributes numerical equivalents can be found in the # eabi_attributes numerical equivalents can be found in the
# "ARM IHI 0045C" document. # "ARM IHI 0045C" document.
...@@ -157,7 +186,7 @@ while (<STDIN>) ...@@ -157,7 +186,7 @@ while (<STDIN>)
} }
# EQU directive # EQU directive
s/(.*)EQU(.*)/.equ $1, $2/; s/(\S+\s+)EQU(\s+\S+)/.equ $1, $2/;
# Begin macro definition # Begin macro definition
if (/MACRO/) { if (/MACRO/) {
...@@ -172,6 +201,7 @@ while (<STDIN>) ...@@ -172,6 +201,7 @@ while (<STDIN>)
s/MEND/.endm/; # No need to tell it where to stop assembling s/MEND/.endm/; # No need to tell it where to stop assembling
next if /^\s*END\s*$/; next if /^\s*END\s*$/;
print; print;
print "$comment_sub$comment\n" if defined $comment;
} }
# Mark that this object doesn't need an executable stack. # Mark that this object doesn't need an executable stack.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment