Add label dump

This commit is contained in:
jeffman 2018-12-17 20:06:02 -05:00
parent 42bf108c76
commit 69292b100f
2 changed files with 36 additions and 1 deletions

1
.gitignore vendored
View File

@ -14,6 +14,7 @@ armtest/
saves/
working/*.asm
working/*.bin
working/m12-labels.txt
armips.exe
*.sym
m2-compiled.asm

View File

@ -458,6 +458,15 @@ namespace ScriptTool
}
IncludeFile.WriteLine(".include \"m12-main-strings.asm\"");
// Dump labels
using (var labelFile = File.CreateText(Path.Combine(options.WorkingDirectory, "m12-labels.txt")))
{
foreach (var kv in m12Compiler.AddressMap.OrderBy(kv => kv.Key, new LabelComparer()))
{
labelFile.WriteLine(String.Format("{0,-30}: 0x{1:X8}", kv.Key, kv.Value | 0x8000000));
}
}
}
static void CompileM12Misc()
@ -680,4 +689,29 @@ namespace ScriptTool
IncludeFile.WriteLine(".include \"" + name + ".asm\"");
}
}
class LabelComparer : IComparer<string>
{
public int Compare(string x, string y)
{
if (x == null)
return (y == null) ? 0 : -1;
if (y == null)
return 1;
if (x.Length == 0 || y.Length == 0)
return x.CompareTo(y);
if (x[0] == 'L' && y[0] == 'L')
{
if (int.TryParse(x.Substring(1), out int xInt) && int.TryParse(y.Substring(1), out int yInt))
{
return xInt.CompareTo(yInt);
}
}
return x.CompareTo(y);
}
}
}