From 440eec2396a712695bd3895dd1a25ce3337c7bbf Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Fri, 5 Oct 2018 17:25:41 -0700 Subject: [PATCH] Use two .ORGs for first-word-is-load-addr First is always at zero, second is at the address. This puts an ORG directive right at the start of the code, and avoids potentially assembler-specific wrap-around behavior when the desired load address is $0000 or $0001. (issue #23) --- SourceGen/DisasmProject.cs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/SourceGen/DisasmProject.cs b/SourceGen/DisasmProject.cs index 2f463e8..67db917 100644 --- a/SourceGen/DisasmProject.cs +++ b/SourceGen/DisasmProject.cs @@ -253,21 +253,18 @@ namespace SourceGen { ProjectProps.EntryFlags = Setup.SystemDefaults.GetEntryFlags(sysDef); // Configure the load address. - int loadAddr; if (Setup.SystemDefaults.GetFirstWordIsLoadAddr(sysDef) && mFileData.Length > 2) { - loadAddr = RawData.GetWord(mFileData, 0, 2, false); - loadAddr -= 2; - if (loadAddr < 0) { - loadAddr += 65536; - } + int loadAddr = RawData.GetWord(mFileData, 0, 2, false); + mAddrMap.Set(0, 0); + mAddrMap.Set(2, loadAddr); OperandFormats[0] = FormatDescriptor.Create(2, FormatDescriptor.Type.NumericLE, FormatDescriptor.SubType.None); TypeHints[0] = CodeAnalysis.TypeHint.NoHint; TypeHints[2] = CodeAnalysis.TypeHint.Code; } else { - loadAddr = Setup.SystemDefaults.GetLoadAddress(sysDef); + int loadAddr = Setup.SystemDefaults.GetLoadAddress(sysDef); + mAddrMap.Set(0, loadAddr); } - mAddrMap.Set(0, loadAddr); foreach (string str in sysDef.SymbolFiles) { ProjectProps.PlatformSymbolFileIdentifiers.Add(str);