From 8a4346fccea08b7bb28a5adb570505a6b5dae015 Mon Sep 17 00:00:00 2001 From: de4dot Date: Thu, 25 Oct 2018 22:26:18 +0200 Subject: [PATCH] Update symbol result to include the address of the symbol --- .../FormatterTests/Gas/GasFormatterFactory.cs | 4 +- .../Gas/GasSymbolResolverTests.cs | 148 +++++------ .../Intel/IntelFormatterFactory.cs | 4 +- .../Intel/IntelSymbolResolverTests.cs | 146 +++++------ .../Masm/MasmFormatterFactory.cs | 4 +- .../Masm/MasmSymbolResolverTests.cs | 152 ++++++------ .../Nasm/NasmFormatterFactory.cs | 4 +- .../Nasm/NasmSymbolResolverTests.cs | 130 +++++----- .../FormatterTests/SymbolResolverTestInfos.cs | 234 +++++++++--------- .../FormatterTests/SymbolResolverTests.cs | 39 ++- .../FormatterTests/TestSymbolResolver.cs | 10 +- Iced/Intel/FormatterOutput.cs | 29 ++- Iced/Intel/GasFormatter.cs | 16 +- Iced/Intel/ISymbolResolver.cs | 25 +- Iced/Intel/IntelFormatter.cs | 16 +- Iced/Intel/MasmFormatter.cs | 16 +- Iced/Intel/NasmFormatter.cs | 16 +- 17 files changed, 516 insertions(+), 477 deletions(-) diff --git a/Iced.UnitTests/Intel/FormatterTests/Gas/GasFormatterFactory.cs b/Iced.UnitTests/Intel/FormatterTests/Gas/GasFormatterFactory.cs index dd634bbfd..9fd301a31 100644 --- a/Iced.UnitTests/Intel/FormatterTests/Gas/GasFormatterFactory.cs +++ b/Iced.UnitTests/Intel/FormatterTests/Gas/GasFormatterFactory.cs @@ -62,13 +62,13 @@ namespace Iced.UnitTests.Intel.FormatterTests.Gas { return new GasFormatter(options); } - public static GasFormatter Create_Resolver(ISymbolResolver symbolResolver) { + public static (Formatter formatter, ISymbolResolver symbolResolver) Create_Resolver(T symbolResolver) where T : ISymbolResolver { var options = CreateOptions(); options.ShowMnemonicSizeSuffix = false; options.NakedRegisters = false; options.ShowBranchSize = false; options.RipRelativeAddresses = true; - return new GasFormatter(options, symbolResolver); + return (new GasFormatter(options, symbolResolver), symbolResolver); } } } diff --git a/Iced.UnitTests/Intel/FormatterTests/Gas/GasSymbolResolverTests.cs b/Iced.UnitTests/Intel/FormatterTests/Gas/GasSymbolResolverTests.cs index 8709efdf1..d09396579 100644 --- a/Iced.UnitTests/Intel/FormatterTests/Gas/GasSymbolResolverTests.cs +++ b/Iced.UnitTests/Intel/FormatterTests/Gas/GasSymbolResolverTests.cs @@ -25,122 +25,122 @@ namespace Iced.UnitTests.Intel.FormatterTests.Gas { public sealed class GasSymbolResolverTests : SymbolResolverTests { [Theory] [MemberData(nameof(Format_Data))] - void Format(int index, SymbolInstructionInfo info, string formattedString) => FormatBase(index, info, formattedString, GasFormatterFactory.Create_Resolver(info.SymbolResolver)); + void Format(int index, int resultDispl, SymbolInstructionInfo info, string formattedString) => FormatBase(index, resultDispl, info, formattedString, GasFormatterFactory.Create_Resolver(info.SymbolResolver.Clone())); public static IEnumerable Format_Data => GetFormatData(infos, formattedStrings); static readonly SymbolInstructionInfo[] infos = SymbolResolverTestInfos.AllInfos; static readonly string[] formattedStrings = new string[SymbolResolverTestInfos.AllInfos_Length] { "jo symbol", + "jo -symnext-0x123", + "jo symbol-0x123", + "jo symbol", + "jo symbol+0x123", + "jo -symnext+0x123", + "jo symbol", + "jo symbol+0x123", + "jo symbol-0x123", "jo -symnext", - "jo symbol", - "jo symbol", - "jo symbol", - "jo -symnext", - "jo symbol", - "jo symbol", - "jo symbol", - "jo -symnext", - "jo symbol", - "jo symbol", + "jo symbol+0x123", + "jo symbol-0x123", "lcall $-selsym,$symbol", - "lcall $selsymextra,$-symbolmore", + "lcall $selsymextra+0x123,$-symbolmore-0x123", + "lcall $0xa55a,$symbol-0x123", "lcall $0xa55a,$symbol", + "lcall $-selsym-0x123,$symbol+0x123", + "lcall $selsymextra-0x123,$-symbolmore+0x123", "lcall $0xa55a,$symbol", - "lcall $-selsym,$symbol", - "lcall $selsymextra,$-symbolmore", - "lcall $0xa55a,$symbol", - "lcall $0xa55a,$symbol", - "mov $symbol,%cl", - "mov $-symnext,%cl", - "mov $symbol,%cl", + "lcall $0xa55a,$symbol+0x123", + "mov $symbol-0x123,%cl", "mov $-symnext,%cl", + "mov $symbol+0x123,%cl", + "mov $-symnext+0x123,%cl", "enter $0xa55a,$symbol", + "enter $0xa55a,$-symnext-0x123", + "enter $0xa55a,$symbol-0x123", "enter $0xa55a,$-symnext", - "enter $0xa55a,$symbol", - "enter $0xa55a,$-symnext", + "mov $symbol+0x123,%cx", + "mov $-symnext+0x123,%cx", "mov $symbol,%cx", - "mov $-symnext,%cx", - "mov $symbol,%cx", - "mov $-symnext,%cx", - "mov $symbol,%ecx", - "mov $-symnext,%ecx", - "mov $symbol,%ecx", + "mov $-symnext-0x123,%cx", + "mov $symbol-0x123,%ecx", "mov $-symnext,%ecx", + "mov $symbol+0x123,%ecx", + "mov $-symnext+0x123,%ecx", "movabs $symbol,%rcx", - "movabs $-symnext,%rcx", - "movabs $symbol,%rcx", + "movabs $-symnext-0x123,%rcx", + "movabs $symbol-0x123,%rcx", "movabs $-symnext,%rcx", "int3", "int3", "int3", "int3", - "or $symbol,%cx", - "or $-symnext,%cx", - "or $symbol,%cx", + "or $symbol-0x123,%cx", "or $-symnext,%cx", + "or $symbol+0x123,%cx", + "or $-symnext+0x123,%cx", "or $symbol,%ecx", + "or $-symnext-0x123,%ecx", + "or $symbol-0x123,%ecx", "or $-symnext,%ecx", - "or $symbol,%ecx", - "or $-symnext,%ecx", + "or $symbol+0x123,%rcx", + "or $-symnext+0x123,%rcx", "or $symbol,%rcx", - "or $-symnext,%rcx", - "or $symbol,%rcx", - "or $-symnext,%rcx", - "movsb %fs:symbol(%si),%es:symbol(%di)", - "movsb %fs:-symnext(%si),%es:-symnext(%di)", - "movsb %fs:symbol(%si),%es:symbol(%di)", + "or $-symnext-0x123,%rcx", + "movsb %fs:symbol-0x123(%si),%es:symbol-0x123(%di)", "movsb %fs:-symnext(%si),%es:-symnext(%di)", + "movsb %fs:symbol+0x123(%si),%es:symbol+0x123(%di)", + "movsb %fs:-symnext+0x123(%si),%es:-symnext+0x123(%di)", "movsb %fs:symbol(%esi),%es:symbol(%edi)", + "movsb %fs:-symnext-0x123(%esi),%es:-symnext-0x123(%edi)", + "movsb %fs:symbol-0x123(%esi),%es:symbol-0x123(%edi)", "movsb %fs:-symnext(%esi),%es:-symnext(%edi)", - "movsb %fs:symbol(%esi),%es:symbol(%edi)", - "movsb %fs:-symnext(%esi),%es:-symnext(%edi)", + "movsb %fs:symbol+0x123(%rsi),%es:symbol+0x123(%rdi)", + "movsb %fs:-symnext+0x123(%rsi),%es:-symnext+0x123(%rdi)", "movsb %fs:symbol(%rsi),%es:symbol(%rdi)", - "movsb %fs:-symnext(%rsi),%es:-symnext(%rdi)", - "movsb %fs:symbol(%rsi),%es:symbol(%rdi)", - "movsb %fs:-symnext(%rsi),%es:-symnext(%rdi)", - "movabs symbol,%al", - "movabs -symnext,%al", - "movabs symbol,%al", + "movsb %fs:-symnext-0x123(%rsi),%es:-symnext-0x123(%rdi)", + "movabs symbol-0x123,%al", "movabs -symnext,%al", + "movabs symbol+0x123,%al", + "movabs -symnext+0x123,%al", "mov symbol,%cl", - "mov -symnext,%cl", - "mov symbol(%rip),%cl", + "mov -symnext-0x123,%cl", + "mov symbol-0x123(%rip),%cl", "mov -symnext(%eip),%cl", + "mov symbol+0x123,%al", + "mov -symnext+0x123,%al", "mov symbol,%al", + "mov -symnext-0x123,%al", + "mov symbol-0x123,%al", "mov -symnext,%al", + "mov symbol+0x123,%al", + "mov -symnext+0x123,%al", "mov symbol,%al", + "mov -symnext-0x123,%al", + "mov symbol-0x123,%al", "mov -symnext,%al", - "mov symbol,%al", - "mov -symnext,%al", - "mov symbol,%al", - "mov -symnext,%al", - "mov symbol,%al", - "mov -symnext,%al", - "mov symbol,%al", - "mov -symnext,%al", - "mov symbol(%rax),%al", - "mov -symnext(%rax),%al", - "mov symbol(%rax),%al", - "mov -symnext(%rax),%al", - "mov symbol(%rax),%al", - "mov -symnext(%rax),%al", - "mov symbol(%rax),%al", - "mov -symnext(%rax),%al", + "mov symbol+0x123(%rax),%al", + "mov -symnext+0x123(%rax),%al", "mov symbol(%rax),%al", + "mov -symnext-0x123(%rax),%al", + "mov symbol-0x123(%rax),%al", "mov -symnext(%rax),%al", + "mov symbol+0x123(%rax),%al", + "mov -symnext+0x123(%rax),%al", "mov symbol(%rax),%al", + "mov -symnext-0x123(%rax),%al", + "mov symbol-0x123(%rax),%al", "mov -symnext(%rax),%al", + "mov symbol+0x123(%bx,%si),%al", + "mov -symnext+0x123(%bx,%si),%al", "mov symbol(%bx,%si),%al", - "mov -symnext(%bx,%si),%al", - "mov symbol(%bx,%si),%al", - "mov -symnext(%bx,%si),%al", - "mov symbol(%eax),%al", - "mov -symnext(%eax),%al", - "mov symbol(%eax),%al", + "mov -symnext-0x123(%bx,%si),%al", + "mov symbol-0x123(%eax),%al", "mov -symnext(%eax),%al", + "mov symbol+0x123(%eax),%al", + "mov -symnext+0x123(%eax),%al", "mov symbol(%rax),%al", - "mov -symnext(%rax),%al", - "mov symbol(%rax),%al", + "mov -symnext-0x123(%rax),%al", + "mov symbol-0x123(%rax),%al", "mov -symnext(%rax),%al", "mov -0x5b(%rax),%al", }; diff --git a/Iced.UnitTests/Intel/FormatterTests/Intel/IntelFormatterFactory.cs b/Iced.UnitTests/Intel/FormatterTests/Intel/IntelFormatterFactory.cs index ee72a8c65..9c88d9709 100644 --- a/Iced.UnitTests/Intel/FormatterTests/Intel/IntelFormatterFactory.cs +++ b/Iced.UnitTests/Intel/FormatterTests/Intel/IntelFormatterFactory.cs @@ -68,13 +68,13 @@ namespace Iced.UnitTests.Intel.FormatterTests.Intel { return new IntelFormatter(options); } - public static IntelFormatter Create_Resolver(ISymbolResolver symbolResolver) { + public static (Formatter formatter, ISymbolResolver symbolResolver) Create_Resolver(T symbolResolver) where T : ISymbolResolver { var options = CreateOptions(); options.MemorySizeOptions = MemorySizeOptions.Default; options.ShowBranchSize = false; options.RipRelativeAddresses = true; options.SpaceAfterOperandSeparator = false; - return new IntelFormatter(options, symbolResolver); + return (new IntelFormatter(options, symbolResolver), symbolResolver); } } } diff --git a/Iced.UnitTests/Intel/FormatterTests/Intel/IntelSymbolResolverTests.cs b/Iced.UnitTests/Intel/FormatterTests/Intel/IntelSymbolResolverTests.cs index 9b30d2073..14b90c377 100644 --- a/Iced.UnitTests/Intel/FormatterTests/Intel/IntelSymbolResolverTests.cs +++ b/Iced.UnitTests/Intel/FormatterTests/Intel/IntelSymbolResolverTests.cs @@ -25,122 +25,122 @@ namespace Iced.UnitTests.Intel.FormatterTests.Intel { public sealed class IntelSymbolResolverTests : SymbolResolverTests { [Theory] [MemberData(nameof(Format_Data))] - void Format(int index, SymbolInstructionInfo info, string formattedString) => FormatBase(index, info, formattedString, IntelFormatterFactory.Create_Resolver(info.SymbolResolver)); + void Format(int index, int resultDispl, SymbolInstructionInfo info, string formattedString) => FormatBase(index, resultDispl, info, formattedString, IntelFormatterFactory.Create_Resolver(info.SymbolResolver.Clone())); public static IEnumerable Format_Data => GetFormatData(infos, formattedStrings); static readonly SymbolInstructionInfo[] infos = SymbolResolverTestInfos.AllInfos; static readonly string[] formattedStrings = new string[SymbolResolverTestInfos.AllInfos_Length] { "jo symbol", - "jo -symnext", + "jo -symnext-0x123", + "jo short symbol-0x123", + "jo symbol", + "jo symbol+0x123", + "jo -symnext+0x123", "jo short symbol", - "jo symbol", - "jo symbol", + "jo symbol+0x123", + "jo symbol-0x123", "jo -symnext", - "jo short symbol", - "jo symbol", - "jo symbol", - "jo -symnext", - "jo short symbol", - "jo symbol", + "jo short symbol+0x123", + "jo symbol-0x123", "call far symbol,-selsym", - "call far -symbolmore,selsymextra", + "call far -symbolmore-0x123,selsymextra+0x123", + "call far symbol-0x123,0xa55a", "call far symbol,0xa55a", + "call far symbol+0x123,-selsym-0x123", + "call far -symbolmore+0x123,selsymextra-0x123", "call far symbol,0xa55a", - "call far symbol,-selsym", - "call far -symbolmore,selsymextra", - "call far symbol,0xa55a", - "call far symbol,0xa55a", - "mov cl,symbol", - "mov cl,-symnext", - "mov cl,symbol", + "call far symbol+0x123,0xa55a", + "mov cl,symbol-0x123", "mov cl,-symnext", + "mov cl,symbol+0x123", + "mov cl,-symnext+0x123", "enter 0xa55a,symbol", + "enter 0xa55a,-symnext-0x123", + "enter 0xa55a,symbol-0x123", "enter 0xa55a,-symnext", - "enter 0xa55a,symbol", - "enter 0xa55a,-symnext", + "mov cx,symbol+0x123", + "mov cx,-symnext+0x123", "mov cx,symbol", - "mov cx,-symnext", - "mov cx,symbol", - "mov cx,-symnext", - "mov ecx,symbol", - "mov ecx,-symnext", - "mov ecx,symbol", + "mov cx,-symnext-0x123", + "mov ecx,symbol-0x123", "mov ecx,-symnext", + "mov ecx,symbol+0x123", + "mov ecx,-symnext+0x123", "mov rcx,symbol", - "mov rcx,-symnext", - "mov rcx,symbol", + "mov rcx,-symnext-0x123", + "mov rcx,symbol-0x123", "mov rcx,-symnext", "int3", "int3", "int3", "int3", - "or cx,symbol", - "or cx,-symnext", - "or cx,symbol", + "or cx,symbol-0x123", "or cx,-symnext", + "or cx,symbol+0x123", + "or cx,-symnext+0x123", "or ecx,symbol", + "or ecx,-symnext-0x123", + "or ecx,symbol-0x123", "or ecx,-symnext", - "or ecx,symbol", - "or ecx,-symnext", + "or rcx,symbol+0x123", + "or rcx,-symnext+0x123", "or rcx,symbol", - "or rcx,-symnext", - "or rcx,symbol", - "or rcx,-symnext", - "movsb es:[di+symbol],fs:[si+symbol]", - "movsb es:[di-symnext],fs:[si-symnext]", - "movsb es:[di+symbol],fs:[si+symbol]", + "or rcx,-symnext-0x123", + "movsb es:[di+symbol-0x123],fs:[si+symbol-0x123]", "movsb es:[di-symnext],fs:[si-symnext]", + "movsb es:[di+symbol+0x123],fs:[si+symbol+0x123]", + "movsb es:[di-symnext+0x123],fs:[si-symnext+0x123]", "movsb es:[edi+symbol],fs:[esi+symbol]", + "movsb es:[edi-symnext-0x123],fs:[esi-symnext-0x123]", + "movsb es:[edi+symbol-0x123],fs:[esi+symbol-0x123]", "movsb es:[edi-symnext],fs:[esi-symnext]", - "movsb es:[edi+symbol],fs:[esi+symbol]", - "movsb es:[edi-symnext],fs:[esi-symnext]", + "movsb es:[rdi+symbol+0x123],fs:[rsi+symbol+0x123]", + "movsb es:[rdi-symnext+0x123],fs:[rsi-symnext+0x123]", "movsb es:[rdi+symbol],fs:[rsi+symbol]", - "movsb es:[rdi-symnext],fs:[rsi-symnext]", - "movsb es:[rdi+symbol],fs:[rsi+symbol]", - "movsb es:[rdi-symnext],fs:[rsi-symnext]", - "mov al,[symbol]", - "mov al,[-symnext]", - "mov al,[symbol]", + "movsb es:[rdi-symnext-0x123],fs:[rsi-symnext-0x123]", + "mov al,[symbol-0x123]", "mov al,[-symnext]", + "mov al,[symbol+0x123]", + "mov al,[-symnext+0x123]", "mov cl,[symbol]", - "mov cl,[-symnext]", - "mov cl,[rip+symbol]", + "mov cl,[-symnext-0x123]", + "mov cl,[rip+symbol-0x123]", "mov cl,[eip-symnext]", + "mov al,[symbol+0x123]", + "mov al,[-symnext+0x123]", "mov al,[symbol]", + "mov al,[-symnext-0x123]", + "mov al,[symbol-0x123]", "mov al,[-symnext]", + "mov al,[symbol+0x123]", + "mov al,[-symnext+0x123]", "mov al,[symbol]", + "mov al,[-symnext-0x123]", + "mov al,[symbol-0x123]", "mov al,[-symnext]", - "mov al,[symbol]", - "mov al,[-symnext]", - "mov al,[symbol]", - "mov al,[-symnext]", - "mov al,[symbol]", - "mov al,[-symnext]", - "mov al,[symbol]", - "mov al,[-symnext]", - "mov al,[rax+symbol]", - "mov al,[rax-symnext]", - "mov al,[rax+symbol]", - "mov al,[rax-symnext]", - "mov al,[rax+symbol]", - "mov al,[rax-symnext]", + "mov al,[rax+symbol+0x123]", + "mov al,[rax-symnext+0x123]", "mov al,[rax+symbol]", + "mov al,[rax-symnext-0x123]", + "mov al,[rax+symbol-0x123]", "mov al,[rax-symnext]", + "mov al,[rax+symbol+0x123]", + "mov al,[rax-symnext+0x123]", "mov al,[rax + symbol]", - "mov al,[rax - symnext]", - "mov al,[rax+symbol]", + "mov al,[rax - symnext - 0x123]", + "mov al,[rax+symbol-0x123]", "mov al,[rax-symnext]", + "mov al,[bx+si+symbol+0x123]", + "mov al,[bx+si-symnext+0x123]", "mov al,[bx+si+symbol]", - "mov al,[bx+si-symnext]", - "mov al,[bx+si+symbol]", - "mov al,[bx+si-symnext]", - "mov al,[eax+symbol]", - "mov al,[eax-symnext]", - "mov al,[eax+symbol]", + "mov al,[bx+si-symnext-0x123]", + "mov al,[eax+symbol-0x123]", "mov al,[eax-symnext]", + "mov al,[eax+symbol+0x123]", + "mov al,[eax-symnext+0x123]", "mov al,[rax+symbol]", - "mov al,[rax-symnext]", - "mov al,[rax+symbol]", + "mov al,[rax-symnext-0x123]", + "mov al,[rax+symbol-0x123]", "mov al,[rax-symnext]", "mov al,[rax-0x5b]", }; diff --git a/Iced.UnitTests/Intel/FormatterTests/Masm/MasmFormatterFactory.cs b/Iced.UnitTests/Intel/FormatterTests/Masm/MasmFormatterFactory.cs index b8b60db29..44701179c 100644 --- a/Iced.UnitTests/Intel/FormatterTests/Masm/MasmFormatterFactory.cs +++ b/Iced.UnitTests/Intel/FormatterTests/Masm/MasmFormatterFactory.cs @@ -58,12 +58,12 @@ namespace Iced.UnitTests.Intel.FormatterTests.Masm { return new MasmFormatter(options); } - public static MasmFormatter Create_Resolver(ISymbolResolver symbolResolver) { + public static (Formatter formatter, ISymbolResolver symbolResolver) Create_Resolver(T symbolResolver) where T : ISymbolResolver { var options = CreateOptions(); options.MemorySizeOptions = MemorySizeOptions.Default; options.ShowBranchSize = false; options.RipRelativeAddresses = true; - return new MasmFormatter(options, symbolResolver); + return (new MasmFormatter(options, symbolResolver), symbolResolver); } } } diff --git a/Iced.UnitTests/Intel/FormatterTests/Masm/MasmSymbolResolverTests.cs b/Iced.UnitTests/Intel/FormatterTests/Masm/MasmSymbolResolverTests.cs index 447a1e1cc..0b9ec2856 100644 --- a/Iced.UnitTests/Intel/FormatterTests/Masm/MasmSymbolResolverTests.cs +++ b/Iced.UnitTests/Intel/FormatterTests/Masm/MasmSymbolResolverTests.cs @@ -25,122 +25,122 @@ namespace Iced.UnitTests.Intel.FormatterTests.Masm { public sealed class MasmSymbolResolverTests : SymbolResolverTests { [Theory] [MemberData(nameof(Format_Data))] - void Format(int index, SymbolInstructionInfo info, string formattedString) => FormatBase(index, info, formattedString, MasmFormatterFactory.Create_Resolver(info.SymbolResolver)); + void Format(int index, int resultDispl, SymbolInstructionInfo info, string formattedString) => FormatBase(index, resultDispl, info, formattedString, MasmFormatterFactory.Create_Resolver(info.SymbolResolver.Clone())); public static IEnumerable Format_Data => GetFormatData(infos, formattedStrings); static readonly SymbolInstructionInfo[] infos = SymbolResolverTestInfos.AllInfos; static readonly string[] formattedStrings = new string[SymbolResolverTestInfos.AllInfos_Length] { "jo symbol", - "jo -symnext", + "jo -symnext-123h", + "jo short symbol-123h", + "jo symbol", + "jo symbol+123h", + "jo -symnext+123h", "jo short symbol", - "jo symbol", - "jo symbol", + "jo symbol+123h", + "jo symbol-123h", "jo -symnext", - "jo short symbol", - "jo symbol", - "jo symbol", - "jo -symnext", - "jo short symbol", - "jo symbol", + "jo short symbol+123h", + "jo symbol-123h", "call -selsym:symbol", - "call selsymextra:-symbolmore", - "call far ptr 0A55Ah:symbol", + "call selsymextra+123h:-symbolmore-123h", + "call far ptr 0A55Ah:symbol-123h", "call 0A55Ah:symbol", - "call -selsym:symbol", - "call selsymextra:-symbolmore", + "call -selsym-123h:symbol+123h", + "call selsymextra-123h:-symbolmore+123h", "call far ptr 0A55Ah:symbol", - "call 0A55Ah:symbol", - "mov cl,symbol", + "call 0A55Ah:symbol+123h", + "mov cl,symbol-123h", "mov cl,-symnext", - "mov cl,offset symbol", - "mov cl,offset -symnext", + "mov cl,offset symbol+123h", + "mov cl,offset -symnext+123h", "enter 0A55Ah,symbol", - "enter 0A55Ah,-symnext", - "enter 0A55Ah,offset symbol", + "enter 0A55Ah,-symnext-123h", + "enter 0A55Ah,offset symbol-123h", "enter 0A55Ah,offset -symnext", - "mov cx,symbol", - "mov cx,-symnext", + "mov cx,symbol+123h", + "mov cx,-symnext+123h", "mov cx,offset symbol", - "mov cx,offset -symnext", - "mov ecx,symbol", + "mov cx,offset -symnext-123h", + "mov ecx,symbol-123h", "mov ecx,-symnext", - "mov ecx,offset symbol", - "mov ecx,offset -symnext", + "mov ecx,offset symbol+123h", + "mov ecx,offset -symnext+123h", "mov rcx,symbol", - "mov rcx,-symnext", - "mov rcx,offset symbol", + "mov rcx,-symnext-123h", + "mov rcx,offset symbol-123h", "mov rcx,offset -symnext", - "int symbol", - "int -symnext", + "int symbol+123h", + "int -symnext+123h", "int offset symbol", - "int offset -symnext", - "or cx,symbol", + "int offset -symnext-123h", + "or cx,symbol-123h", "or cx,-symnext", - "or cx,offset symbol", - "or cx,offset -symnext", + "or cx,offset symbol+123h", + "or cx,offset -symnext+123h", "or ecx,symbol", - "or ecx,-symnext", - "or ecx,offset symbol", + "or ecx,-symnext-123h", + "or ecx,offset symbol-123h", "or ecx,offset -symnext", - "or rcx,symbol", - "or rcx,-symnext", + "or rcx,symbol+123h", + "or rcx,-symnext+123h", "or rcx,offset symbol", - "or rcx,offset -symnext", - "movs byte ptr es:[di+symbol],byte ptr fs:[si+symbol]", - "movs byte ptr es:[di-symnext],byte ptr fs:[si-symnext]", - "movs byte ptr es:[di+symbol],byte ptr fs:[si+symbol]", + "or rcx,offset -symnext-123h", + "movs byte ptr es:[di+symbol-123h],byte ptr fs:[si+symbol-123h]", "movs byte ptr es:[di-symnext],byte ptr fs:[si-symnext]", + "movs byte ptr es:[di+symbol+123h],byte ptr fs:[si+symbol+123h]", + "movs byte ptr es:[di-symnext+123h],byte ptr fs:[si-symnext+123h]", "movs byte ptr es:[edi+symbol],byte ptr fs:[esi+symbol]", + "movs byte ptr es:[edi-symnext-123h],byte ptr fs:[esi-symnext-123h]", + "movs byte ptr es:[edi+symbol-123h],byte ptr fs:[esi+symbol-123h]", "movs byte ptr es:[edi-symnext],byte ptr fs:[esi-symnext]", - "movs byte ptr es:[edi+symbol],byte ptr fs:[esi+symbol]", - "movs byte ptr es:[edi-symnext],byte ptr fs:[esi-symnext]", + "movs byte ptr es:[rdi+symbol+123h],byte ptr fs:[rsi+symbol+123h]", + "movs byte ptr es:[rdi-symnext+123h],byte ptr fs:[rsi-symnext+123h]", "movs byte ptr es:[rdi+symbol],byte ptr fs:[rsi+symbol]", - "movs byte ptr es:[rdi-symnext],byte ptr fs:[rsi-symnext]", - "movs byte ptr es:[rdi+symbol],byte ptr fs:[rsi+symbol]", - "movs byte ptr es:[rdi-symnext],byte ptr fs:[rsi-symnext]", - "mov al,[symbol]", - "mov al,[-symnext]", - "mov al,[symbol]", + "movs byte ptr es:[rdi-symnext-123h],byte ptr fs:[rsi-symnext-123h]", + "mov al,[symbol-123h]", "mov al,[-symnext]", + "mov al,[symbol+123h]", + "mov al,[-symnext+123h]", "mov cl,[symbol]", - "mov cl,[-symnext]", - "mov cl,[rip+symbol]", + "mov cl,[-symnext-123h]", + "mov cl,[rip+symbol-123h]", "mov cl,[eip-symnext]", + "mov al,[symbol+123h]", + "mov al,[-symnext+123h]", "mov al,[symbol]", + "mov al,[-symnext-123h]", + "mov al,[symbol-123h]", "mov al,[-symnext]", + "mov al,[symbol+123h]", + "mov al,[-symnext+123h]", "mov al,[symbol]", + "mov al,[-symnext-123h]", + "mov al,[symbol-123h]", "mov al,[-symnext]", - "mov al,[symbol]", - "mov al,[-symnext]", - "mov al,[symbol]", - "mov al,[-symnext]", - "mov al,[symbol]", - "mov al,[-symnext]", - "mov al,[symbol]", - "mov al,[-symnext]", - "mov al,[rax+symbol]", - "mov al,[rax-symnext]", - "mov al,[rax+symbol]", - "mov al,[rax-symnext]", - "mov al,[rax+symbol]", - "mov al,[rax-symnext]", + "mov al,[rax+symbol+123h]", + "mov al,[rax-symnext+123h]", "mov al,[rax+symbol]", + "mov al,[rax-symnext-123h]", + "mov al,[rax+symbol-123h]", "mov al,[rax-symnext]", + "mov al,[rax+symbol+123h]", + "mov al,[rax-symnext+123h]", "mov al,[rax + symbol]", - "mov al,[rax - symnext]", - "mov al,[rax+symbol]", + "mov al,[rax - symnext - 123h]", + "mov al,[rax+symbol-123h]", "mov al,[rax-symnext]", + "mov al,[bx+si+symbol+123h]", + "mov al,[bx+si-symnext+123h]", "mov al,[bx+si+symbol]", - "mov al,[bx+si-symnext]", - "mov al,[bx+si+symbol]", - "mov al,[bx+si-symnext]", - "mov al,[eax+symbol]", - "mov al,[eax-symnext]", - "mov al,[eax+symbol]", + "mov al,[bx+si-symnext-123h]", + "mov al,[eax+symbol-123h]", "mov al,[eax-symnext]", + "mov al,[eax+symbol+123h]", + "mov al,[eax-symnext+123h]", "mov al,[rax+symbol]", - "mov al,[rax-symnext]", - "mov al,[rax+symbol]", + "mov al,[rax-symnext-123h]", + "mov al,[rax+symbol-123h]", "mov al,[rax-symnext]", "mov al,[rax-5Bh]", }; diff --git a/Iced.UnitTests/Intel/FormatterTests/Nasm/NasmFormatterFactory.cs b/Iced.UnitTests/Intel/FormatterTests/Nasm/NasmFormatterFactory.cs index 5631151a9..f40a9b7be 100644 --- a/Iced.UnitTests/Intel/FormatterTests/Nasm/NasmFormatterFactory.cs +++ b/Iced.UnitTests/Intel/FormatterTests/Nasm/NasmFormatterFactory.cs @@ -70,13 +70,13 @@ namespace Iced.UnitTests.Intel.FormatterTests.Nasm { return new NasmFormatter(options); } - public static NasmFormatter Create_Resolver(ISymbolResolver symbolResolver) { + public static (Formatter formatter, ISymbolResolver symbolResolver) Create_Resolver(T symbolResolver) where T : ISymbolResolver { var options = CreateOptions(); options.MemorySizeOptions = MemorySizeOptions.Default; options.ShowSignExtendedImmediateSize = false; options.ShowBranchSize = false; options.RipRelativeAddresses = true; - return new NasmFormatter(options, symbolResolver); + return (new NasmFormatter(options, symbolResolver), symbolResolver); } } } diff --git a/Iced.UnitTests/Intel/FormatterTests/Nasm/NasmSymbolResolverTests.cs b/Iced.UnitTests/Intel/FormatterTests/Nasm/NasmSymbolResolverTests.cs index 3fa2dfc4f..ad21e7619 100644 --- a/Iced.UnitTests/Intel/FormatterTests/Nasm/NasmSymbolResolverTests.cs +++ b/Iced.UnitTests/Intel/FormatterTests/Nasm/NasmSymbolResolverTests.cs @@ -25,67 +25,67 @@ namespace Iced.UnitTests.Intel.FormatterTests.Nasm { public sealed class NasmSymbolResolverTests : SymbolResolverTests { [Theory] [MemberData(nameof(Format_Data))] - void Format(int index, SymbolInstructionInfo info, string formattedString) => FormatBase(index, info, formattedString, NasmFormatterFactory.Create_Resolver(info.SymbolResolver)); + void Format(int index, int resultDispl, SymbolInstructionInfo info, string formattedString) => FormatBase(index, resultDispl, info, formattedString, NasmFormatterFactory.Create_Resolver(info.SymbolResolver.Clone())); public static IEnumerable Format_Data => GetFormatData(infos, formattedStrings); static readonly SymbolInstructionInfo[] infos = SymbolResolverTestInfos.AllInfos; static readonly string[] formattedStrings = new string[SymbolResolverTestInfos.AllInfos_Length] { "jo symbol", - "jo -symnext", + "jo -symnext-0x123", + "jo short symbol-0x123", + "jo symbol", + "jo symbol+0x123", + "jo -symnext+0x123", "jo short symbol", - "jo symbol", - "jo symbol", + "jo symbol+0x123", + "jo symbol-0x123", "jo -symnext", - "jo short symbol", - "jo symbol", - "jo symbol", - "jo -symnext", - "jo short symbol", - "jo symbol", + "jo short symbol+0x123", + "jo symbol-0x123", "call -selsym:symbol", - "call selsymextra:-symbolmore", + "call selsymextra+0x123:-symbolmore-0x123", + "call 0xa55a:symbol-0x123", "call 0xa55a:symbol", + "call -selsym-0x123:symbol+0x123", + "call selsymextra-0x123:-symbolmore+0x123", "call 0xa55a:symbol", - "call -selsym:symbol", - "call selsymextra:-symbolmore", - "call 0xa55a:symbol", - "call 0xa55a:symbol", - "mov cl,symbol", - "mov cl,-symnext", - "mov cl,symbol", + "call 0xa55a:symbol+0x123", + "mov cl,symbol-0x123", "mov cl,-symnext", + "mov cl,symbol+0x123", + "mov cl,-symnext+0x123", "enter 0xa55a,symbol", + "enter 0xa55a,-symnext-0x123", + "enter 0xa55a,symbol-0x123", "enter 0xa55a,-symnext", - "enter 0xa55a,symbol", - "enter 0xa55a,-symnext", + "mov cx,symbol+0x123", + "mov cx,-symnext+0x123", "mov cx,symbol", - "mov cx,-symnext", - "mov cx,symbol", - "mov cx,-symnext", - "mov ecx,symbol", - "mov ecx,-symnext", - "mov ecx,symbol", + "mov cx,-symnext-0x123", + "mov ecx,symbol-0x123", "mov ecx,-symnext", + "mov ecx,symbol+0x123", + "mov ecx,-symnext+0x123", "mov rcx,symbol", - "mov rcx,-symnext", - "mov rcx,symbol", + "mov rcx,-symnext-0x123", + "mov rcx,symbol-0x123", "mov rcx,-symnext", "int3", "int3", "int3", "int3", - "or cx,symbol", - "or cx,-symnext", - "or cx,symbol", + "or cx,symbol-0x123", "or cx,-symnext", + "or cx,symbol+0x123", + "or cx,-symnext+0x123", "or ecx,symbol", + "or ecx,-symnext-0x123", + "or ecx,symbol-0x123", "or ecx,-symnext", - "or ecx,symbol", - "or ecx,-symnext", + "or rcx,symbol+0x123", + "or rcx,-symnext+0x123", "or rcx,symbol", - "or rcx,-symnext", - "or rcx,symbol", - "or rcx,-symnext", + "or rcx,-symnext-0x123", "fs movsb", "fs movsb", "fs movsb", @@ -98,49 +98,49 @@ namespace Iced.UnitTests.Intel.FormatterTests.Nasm { "fs movsb", "fs movsb", "fs movsb", - "mov al,[qword symbol]", - "mov al,[qword -symnext]", - "mov al,[qword symbol]", + "mov al,[qword symbol-0x123]", "mov al,[qword -symnext]", + "mov al,[qword symbol+0x123]", + "mov al,[qword -symnext+0x123]", "mov cl,[rel symbol]", - "mov cl,[dword rel -symnext]", - "mov cl,[rip+symbol]", + "mov cl,[dword rel -symnext-0x123]", + "mov cl,[rip+symbol-0x123]", "mov cl,[eip-symnext]", + "mov al,[symbol+0x123]", + "mov al,[-symnext+0x123]", "mov al,[symbol]", + "mov al,[-symnext-0x123]", + "mov al,[symbol-0x123]", "mov al,[-symnext]", + "mov al,[symbol+0x123]", + "mov al,[-symnext+0x123]", "mov al,[symbol]", + "mov al,[-symnext-0x123]", + "mov al,[symbol-0x123]", "mov al,[-symnext]", - "mov al,[symbol]", - "mov al,[-symnext]", - "mov al,[symbol]", - "mov al,[-symnext]", - "mov al,[symbol]", - "mov al,[-symnext]", - "mov al,[symbol]", - "mov al,[-symnext]", - "mov al,[rax+symbol]", - "mov al,[rax-symnext]", - "mov al,[rax+symbol]", - "mov al,[rax-symnext]", - "mov al,[rax+symbol]", - "mov al,[rax-symnext]", + "mov al,[rax+symbol+0x123]", + "mov al,[rax-symnext+0x123]", "mov al,[rax+symbol]", + "mov al,[rax-symnext-0x123]", + "mov al,[rax+symbol-0x123]", "mov al,[rax-symnext]", + "mov al,[rax+symbol+0x123]", + "mov al,[rax-symnext+0x123]", "mov al,[rax + symbol]", - "mov al,[rax - symnext]", - "mov al,[rax+symbol]", + "mov al,[rax - symnext - 0x123]", + "mov al,[rax+symbol-0x123]", "mov al,[rax-symnext]", + "mov al,[bx+si+symbol+0x123]", + "mov al,[bx+si-symnext+0x123]", "mov al,[bx+si+symbol]", - "mov al,[bx+si-symnext]", - "mov al,[bx+si+symbol]", - "mov al,[bx+si-symnext]", - "mov al,[eax+symbol]", - "mov al,[eax-symnext]", - "mov al,[eax+symbol]", + "mov al,[bx+si-symnext-0x123]", + "mov al,[eax+symbol-0x123]", "mov al,[eax-symnext]", + "mov al,[eax+symbol+0x123]", + "mov al,[eax-symnext+0x123]", "mov al,[rax+symbol]", - "mov al,[rax-symnext]", - "mov al,[rax+symbol]", + "mov al,[rax-symnext-0x123]", + "mov al,[rax+symbol-0x123]", "mov al,[rax-symnext]", "mov al,[rax-0x5b]", }; diff --git a/Iced.UnitTests/Intel/FormatterTests/SymbolResolverTestInfos.cs b/Iced.UnitTests/Intel/FormatterTests/SymbolResolverTestInfos.cs index 0f589fb24..a538346a5 100644 --- a/Iced.UnitTests/Intel/FormatterTests/SymbolResolverTestInfos.cs +++ b/Iced.UnitTests/Intel/FormatterTests/SymbolResolverTestInfos.cs @@ -29,7 +29,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(2, addressSize); Assert.Equal(DecoderConstants.DEFAULT_IP16 + 2, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text)); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text)); return true; }, }), @@ -37,7 +37,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(2, addressSize); Assert.Equal(DecoderConstants.DEFAULT_IP16 + 2, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); return true; }, }), @@ -45,7 +45,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(2, addressSize); Assert.Equal(DecoderConstants.DEFAULT_IP16 + 2, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text)); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text)); return true; }, }), @@ -53,7 +53,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(2, addressSize); Assert.Equal(DecoderConstants.DEFAULT_IP16 + 2, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text)); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text)); return true; }, }), @@ -61,7 +61,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(4, addressSize); Assert.Equal(DecoderConstants.DEFAULT_IP32 + 2, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text)); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text)); return true; }, }), @@ -69,7 +69,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(4, addressSize); Assert.Equal(DecoderConstants.DEFAULT_IP32 + 2, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); return true; }, }), @@ -77,7 +77,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(4, addressSize); Assert.Equal(DecoderConstants.DEFAULT_IP32 + 2, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text)); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text)); return true; }, }), @@ -85,7 +85,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(4, addressSize); Assert.Equal(DecoderConstants.DEFAULT_IP32 + 2, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text)); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text)); return true; }, }), @@ -93,7 +93,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(DecoderConstants.DEFAULT_IP64 + 2, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text)); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text)); return true; }, }), @@ -101,7 +101,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(DecoderConstants.DEFAULT_IP64 + 2, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); return true; }, }), @@ -109,7 +109,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(DecoderConstants.DEFAULT_IP64 + 2, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text)); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text)); return true; }, }), @@ -117,7 +117,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(DecoderConstants.DEFAULT_IP64 + 2, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text)); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text)); return true; }, }), @@ -126,12 +126,12 @@ namespace Iced.UnitTests.Intel.FormatterTests { Assert.Equal(2, addressSize); if (operand == 0) { Assert.Equal(0xFEDCU, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text)); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text)); } else { Assert.Equal(1, operand); Assert.Equal(0xA55AU, address); - symbol = new SymbolResult(new TextInfo("selsym", FormatterOutputTextKind.Text), SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo("selsym", FormatterOutputTextKind.Text), SymbolFlags.Signed); } return true; }, @@ -141,12 +141,12 @@ namespace Iced.UnitTests.Intel.FormatterTests { Assert.Equal(2, addressSize); if (operand == 0) { Assert.Equal(0xFEDCU, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("symbol", FormatterOutputTextKind.Text), new TextPart("more", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("symbol", FormatterOutputTextKind.Text), new TextPart("more", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); } else { Assert.Equal(1, operand); Assert.Equal(0xA55AU, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("selsym", FormatterOutputTextKind.Text), new TextPart("extra", FormatterOutputTextKind.Text) })); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("selsym", FormatterOutputTextKind.Text), new TextPart("extra", FormatterOutputTextKind.Text) })); } return true; }, @@ -156,7 +156,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { Assert.Equal(2, addressSize); if (operand == 0) { Assert.Equal(0xFEDCU, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text)); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text)); return true; } else { @@ -172,7 +172,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { Assert.Equal(2, addressSize); if (operand == 0) { Assert.Equal(0xFEDCU, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text)); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text)); return true; } else { @@ -188,13 +188,13 @@ namespace Iced.UnitTests.Intel.FormatterTests { if (operand == 0) { Assert.Equal(0xFEDCBA98, address); Assert.Equal(4, addressSize); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text)); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text)); } else { Assert.Equal(1, operand); Assert.Equal(2, addressSize); Assert.Equal(0xA55AU, address); - symbol = new SymbolResult(new TextInfo("selsym", FormatterOutputTextKind.Text), SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo("selsym", FormatterOutputTextKind.Text), SymbolFlags.Signed); } return true; }, @@ -204,13 +204,13 @@ namespace Iced.UnitTests.Intel.FormatterTests { if (operand == 0) { Assert.Equal(0xFEDCBA98, address); Assert.Equal(4, addressSize); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("symbol", FormatterOutputTextKind.Text), new TextPart("more", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("symbol", FormatterOutputTextKind.Text), new TextPart("more", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); } else { Assert.Equal(1, operand); Assert.Equal(2, addressSize); Assert.Equal(0xA55AU, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("selsym", FormatterOutputTextKind.Text), new TextPart("extra", FormatterOutputTextKind.Text) })); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("selsym", FormatterOutputTextKind.Text), new TextPart("extra", FormatterOutputTextKind.Text) })); } return true; }, @@ -220,7 +220,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { if (operand == 0) { Assert.Equal(0xFEDCBA98, address); Assert.Equal(4, addressSize); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text)); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text)); return true; } else { @@ -237,7 +237,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { if (operand == 0) { Assert.Equal(0xFEDCBA98, address); Assert.Equal(4, addressSize); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text)); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text)); return true; } else { @@ -253,7 +253,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(1, addressSize); Assert.Equal(0xA5UL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text)); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text)); return true; }, }), @@ -261,7 +261,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(1, addressSize); Assert.Equal(0xA5UL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); return true; }, }), @@ -269,7 +269,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(1, addressSize); Assert.Equal(0xA5UL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); return true; }, }), @@ -277,7 +277,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(1, addressSize); Assert.Equal(0xA5UL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); return true; }, }), @@ -291,7 +291,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { else { Assert.Equal(1, addressSize); Assert.Equal(0xA5UL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text)); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text)); return true; } }, @@ -306,7 +306,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { else { Assert.Equal(1, addressSize); Assert.Equal(0xA5UL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); return true; } }, @@ -321,7 +321,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { else { Assert.Equal(1, addressSize); Assert.Equal(0xA5UL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); return true; } }, @@ -336,7 +336,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { else { Assert.Equal(1, addressSize); Assert.Equal(0xA5UL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); return true; } }, @@ -345,7 +345,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(2, addressSize); Assert.Equal(0xA55AUL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text)); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text)); return true; }, }), @@ -353,7 +353,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(2, addressSize); Assert.Equal(0xA55AUL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); return true; }, }), @@ -361,7 +361,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(2, addressSize); Assert.Equal(0xA55AUL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); return true; }, }), @@ -369,7 +369,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(2, addressSize); Assert.Equal(0xA55AUL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); return true; }, }), @@ -377,7 +377,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(4, addressSize); Assert.Equal(0xFEDCBA98, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text)); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text)); return true; }, }), @@ -385,7 +385,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(4, addressSize); Assert.Equal(0xFEDCBA98, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); return true; }, }), @@ -393,7 +393,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(4, addressSize); Assert.Equal(0xFEDCBA98, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); return true; }, }), @@ -401,7 +401,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(4, addressSize); Assert.Equal(0xFEDCBA98, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); return true; }, }), @@ -409,7 +409,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0xFEDCBA983412A55A, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text)); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text)); return true; }, }), @@ -417,7 +417,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0xFEDCBA983412A55A, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); return true; }, }), @@ -425,7 +425,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0xFEDCBA983412A55A, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); return true; }, }), @@ -433,7 +433,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0xFEDCBA983412A55A, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); return true; }, }), @@ -441,7 +441,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(1, addressSize); Assert.Equal(3UL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text)); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text)); return true; }, }), @@ -449,7 +449,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(1, addressSize); Assert.Equal(3UL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); return true; }, }), @@ -457,7 +457,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(1, addressSize); Assert.Equal(3UL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); return true; }, }), @@ -465,7 +465,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(1, addressSize); Assert.Equal(3UL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); return true; }, }), @@ -473,7 +473,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(2, addressSize); Assert.Equal(0xFFFFUL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text)); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text)); return true; }, }), @@ -481,7 +481,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(2, addressSize); Assert.Equal(0xFFFFUL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); return true; }, }), @@ -489,7 +489,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(2, addressSize); Assert.Equal(0xFFFFUL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); return true; }, }), @@ -497,7 +497,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(2, addressSize); Assert.Equal(0xFFFFUL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); return true; }, }), @@ -505,7 +505,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(4, addressSize); Assert.Equal(0xFFFFFFFFUL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text)); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text)); return true; }, }), @@ -513,7 +513,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(4, addressSize); Assert.Equal(0xFFFFFFFFUL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); return true; }, }), @@ -521,7 +521,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(4, addressSize); Assert.Equal(0xFFFFFFFFUL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); return true; }, }), @@ -529,7 +529,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(4, addressSize); Assert.Equal(0xFFFFFFFFUL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); return true; }, }), @@ -537,7 +537,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0xFFFFFFFFFFFFFFFFUL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text)); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text)); return true; }, }), @@ -545,7 +545,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0xFFFFFFFFFFFFFFFFUL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); return true; }, }), @@ -553,7 +553,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0xFFFFFFFFFFFFFFFFUL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); return true; }, }), @@ -561,7 +561,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0xFFFFFFFFFFFFFFFFUL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); return true; }, }), @@ -569,7 +569,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(2, addressSize); Assert.Equal(0UL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text)); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text)); return true; }, }), @@ -577,7 +577,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(2, addressSize); Assert.Equal(0UL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); return true; }, }), @@ -585,7 +585,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(2, addressSize); Assert.Equal(0UL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); return true; }, }), @@ -593,7 +593,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(2, addressSize); Assert.Equal(0UL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); return true; }, }), @@ -601,7 +601,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(4, addressSize); Assert.Equal(0UL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text)); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text)); return true; }, }), @@ -609,7 +609,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(4, addressSize); Assert.Equal(0UL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); return true; }, }), @@ -617,7 +617,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(4, addressSize); Assert.Equal(0UL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); return true; }, }), @@ -625,7 +625,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(4, addressSize); Assert.Equal(0UL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); return true; }, }), @@ -633,7 +633,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0UL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text)); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text)); return true; }, }), @@ -641,7 +641,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0UL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); return true; }, }), @@ -649,7 +649,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0UL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); return true; }, }), @@ -657,7 +657,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0UL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); return true; }, }), @@ -665,7 +665,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0xF0DEBC9A78563412UL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text)); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text)); return true; }, }), @@ -673,7 +673,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0xF0DEBC9A78563412UL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); return true; }, }), @@ -681,7 +681,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0xF0DEBC9A78563412UL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); return true; }, }), @@ -689,7 +689,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0xF0DEBC9A78563412UL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); return true; }, }), @@ -697,7 +697,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(DecoderConstants.DEFAULT_IP64 + 6 + 0x12345678, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.None); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.None); return true; }, }), @@ -705,7 +705,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(4, addressSize); Assert.Equal((DecoderConstants.DEFAULT_IP64 + 7 + 0x12345678) & 0xFFFFFFFFUL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); return true; }, }), @@ -713,7 +713,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(DecoderConstants.DEFAULT_IP64 + 6 + 0x12345678, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); return true; }, }), @@ -721,7 +721,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(4, addressSize); Assert.Equal((DecoderConstants.DEFAULT_IP64 + 7 + 0x12345678) & 0xFFFFFFFFUL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); return true; }, }), @@ -729,7 +729,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(2, addressSize); Assert.Equal(0xFFFFUL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.None); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.None); return true; }, }), @@ -737,7 +737,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(2, addressSize); Assert.Equal(0xFFFFUL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); return true; }, }), @@ -745,7 +745,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(2, addressSize); Assert.Equal(0xFFFFUL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); return true; }, }), @@ -753,7 +753,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(2, addressSize); Assert.Equal(0xFFFFUL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); return true; }, }), @@ -761,7 +761,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(4, addressSize); Assert.Equal(0xFFFFFFFFUL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.None); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.None); return true; }, }), @@ -769,7 +769,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(4, addressSize); Assert.Equal(0xFFFFFFFFUL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); return true; }, }), @@ -777,7 +777,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(4, addressSize); Assert.Equal(0xFFFFFFFFUL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); return true; }, }), @@ -785,7 +785,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(4, addressSize); Assert.Equal(0xFFFFFFFFUL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); return true; }, }), @@ -793,7 +793,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0xFFFFFFFFFFFFFFFFUL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.None); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.None); return true; }, }), @@ -801,7 +801,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0xFFFFFFFFFFFFFFFFUL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); return true; }, }), @@ -809,7 +809,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0xFFFFFFFFFFFFFFFFUL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); return true; }, }), @@ -817,7 +817,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0xFFFFFFFFFFFFFFFFUL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); return true; }, }), @@ -825,7 +825,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0UL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.None); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.None); return true; }, }), @@ -833,7 +833,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0UL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); return true; }, }), @@ -841,7 +841,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0UL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); return true; }, }), @@ -849,7 +849,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0UL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); return true; }, }), @@ -857,7 +857,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0xFFFFFFFFFFFFFFA5UL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.None); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.None); return true; }, }), @@ -865,7 +865,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0xFFFFFFFFFFFFFFA5UL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); return true; }, }), @@ -873,7 +873,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0xFFFFFFFFFFFFFFA5UL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.Address); return true; }, }), @@ -881,7 +881,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0xFFFFFFFFFFFFFFA5UL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Address | SymbolFlags.Signed); return true; }, }), @@ -889,7 +889,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0xFFFFFFFFFFFFFFA5UL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.None); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.None); return true; }, }), @@ -897,7 +897,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0xFFFFFFFFFFFFFFA5UL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); return true; }, }), @@ -905,7 +905,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0xFFFFFFFFFFFFFFA5UL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.None); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.None); return true; }, }), @@ -913,7 +913,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0xFFFFFFFFFFFFFFA5UL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); return true; }, }), @@ -921,7 +921,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(2, addressSize); Assert.Equal(0xA55AUL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.None); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.None); return true; }, }), @@ -929,7 +929,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(2, addressSize); Assert.Equal(0xA55AUL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); return true; }, }), @@ -937,7 +937,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(2, addressSize); Assert.Equal(0xA55AUL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.None); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.None); return true; }, }), @@ -945,7 +945,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(2, addressSize); Assert.Equal(0xA55AUL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); return true; }, }), @@ -953,7 +953,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(4, addressSize); Assert.Equal(0xEDCBA988UL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.None); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.None); return true; }, }), @@ -961,7 +961,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(4, addressSize); Assert.Equal(0xEDCBA988UL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); return true; }, }), @@ -969,7 +969,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(4, addressSize); Assert.Equal(0xEDCBA988UL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.None); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.None); return true; }, }), @@ -977,7 +977,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(4, addressSize); Assert.Equal(0xEDCBA988UL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); return true; }, }), @@ -985,7 +985,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0xFFFFFFFFEDCBA988UL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.None); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.None); return true; }, }), @@ -993,7 +993,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0xFFFFFFFFEDCBA988UL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); return true; }, }), @@ -1001,7 +1001,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0xFFFFFFFFEDCBA988UL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.None); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.None); return true; }, }), @@ -1009,7 +1009,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0xFFFFFFFFEDCBA988UL, address); - symbol = new SymbolResult(new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); + symbol = new SymbolResult(address, new TextInfo(new TextPart[] { new TextPart("sym", FormatterOutputTextKind.Text), new TextPart("next", FormatterOutputTextKind.Text) }), SymbolFlags.Signed); return true; }, }), @@ -1017,7 +1017,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { tryGetSymbol = (int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) => { Assert.Equal(8, addressSize); Assert.Equal(0xFFFFFFFFFFFFFFA5UL, address); - symbol = new SymbolResult(new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.None); + symbol = new SymbolResult(address, new TextInfo("symbol", FormatterOutputTextKind.Text), SymbolFlags.None); return false; }, }), diff --git a/Iced.UnitTests/Intel/FormatterTests/SymbolResolverTests.cs b/Iced.UnitTests/Intel/FormatterTests/SymbolResolverTests.cs index c2f5d0ac2..6f5ad529d 100644 --- a/Iced.UnitTests/Intel/FormatterTests/SymbolResolverTests.cs +++ b/Iced.UnitTests/Intel/FormatterTests/SymbolResolverTests.cs @@ -29,8 +29,8 @@ namespace Iced.UnitTests.Intel.FormatterTests { public readonly Code Code; public readonly Action InitOptions; public readonly Action InitDecoder; - public readonly ISymbolResolver SymbolResolver; - public SymbolInstructionInfo(int codeSize, string hexBytes, Code code, ISymbolResolver symbolResolver) { + internal readonly TestSymbolResolver SymbolResolver; + internal SymbolInstructionInfo(int codeSize, string hexBytes, Code code, TestSymbolResolver symbolResolver) { CodeSize = codeSize; HexBytes = hexBytes; Code = code; @@ -38,7 +38,7 @@ namespace Iced.UnitTests.Intel.FormatterTests { InitDecoder = initDecoderDefault; SymbolResolver = symbolResolver; } - public SymbolInstructionInfo(int codeSize, string hexBytes, Code code, Action enableOption, ISymbolResolver symbolResolver) { + internal SymbolInstructionInfo(int codeSize, string hexBytes, Code code, Action enableOption, TestSymbolResolver symbolResolver) { CodeSize = codeSize; HexBytes = hexBytes; Code = code; @@ -46,22 +46,6 @@ namespace Iced.UnitTests.Intel.FormatterTests { InitDecoder = initDecoderDefault; SymbolResolver = symbolResolver; } - public SymbolInstructionInfo(int codeSize, string hexBytes, Code code, Action enableOption) { - CodeSize = codeSize; - HexBytes = hexBytes; - Code = code; - InitOptions = enableOption; - InitDecoder = initDecoderDefault; - SymbolResolver = null; - } - public SymbolInstructionInfo(int codeSize, string hexBytes, Code code, Action enableOption, Action initDecoder) { - CodeSize = codeSize; - HexBytes = hexBytes; - Code = code; - InitOptions = enableOption; - InitDecoder = initDecoder; - SymbolResolver = null; - } static readonly Action initOptionsDefault = a => { }; static readonly Action initDecoderDefault = a => { }; } @@ -72,11 +56,24 @@ namespace Iced.UnitTests.Intel.FormatterTests { throw new ArgumentException($"(infos.Length) {infos.Length} != (formattedStrings.Length) {formattedStrings.Length} . infos[0].HexBytes = {(infos.Length == 0 ? "" : infos[0].HexBytes)} & formattedStrings[0] = {(formattedStrings.Length == 0 ? "" : formattedStrings[0])}"); var res = new object[infos.Length][]; for (int i = 0; i < infos.Length; i++) - res[i] = new object[3] { i, infos[i], formattedStrings[i] }; + res[i] = new object[4] { i, GetSymDispl(i), infos[i], formattedStrings[i] }; return res; } - protected void FormatBase(int index, SymbolInstructionInfo info, string formattedString, Formatter formatter) { + static int GetSymDispl(int i) { + const int DISPL = 0x123; + switch (i % 3) { + case 0: return 0; + case 1: return -DISPL; + case 2: return DISPL; + default: throw new InvalidOperationException(); + } + } + + protected void FormatBase(int index, int resultDispl, in SymbolInstructionInfo info, string formattedString, (Formatter formatter, ISymbolResolver symbolResolver) formatterInfo) { + var symbolResolver = (TestSymbolResolver)formatterInfo.symbolResolver; + var formatter = formatterInfo.formatter; + symbolResolver.resultDispl = resultDispl; info.InitOptions(formatter.Options); FormatterTestUtils.SimpleFormatTest(info.CodeSize, info.HexBytes, info.Code, DecoderOptions.None, formattedString, formatter, info.InitDecoder); } diff --git a/Iced.UnitTests/Intel/FormatterTests/TestSymbolResolver.cs b/Iced.UnitTests/Intel/FormatterTests/TestSymbolResolver.cs index 756568241..e6fd9dcbd 100644 --- a/Iced.UnitTests/Intel/FormatterTests/TestSymbolResolver.cs +++ b/Iced.UnitTests/Intel/FormatterTests/TestSymbolResolver.cs @@ -22,11 +22,17 @@ using Iced.Intel; namespace Iced.UnitTests.Intel.FormatterTests { sealed class TestSymbolResolver : ISymbolResolver { + public TestSymbolResolver Clone() => new TestSymbolResolver() { tryGetSymbol = tryGetSymbol }; public delegate bool TryGetSymbolDelegate(int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol); public TryGetSymbolDelegate tryGetSymbol; + public int resultDispl; public bool TryGetSymbol(int operand, int instructionOperand, ref Instruction instruction, ulong address, int addressSize, out SymbolResult symbol) { - if (tryGetSymbol != null) - return tryGetSymbol(operand, instructionOperand, ref instruction, address, addressSize, out symbol); + if (tryGetSymbol != null) { + if (!tryGetSymbol(operand, instructionOperand, ref instruction, address, addressSize, out symbol)) + return false; + symbol = new SymbolResult(address + (ulong)resultDispl, symbol.Text, symbol.Flags); + return true; + } symbol = default; return false; } diff --git a/Iced/Intel/FormatterOutput.cs b/Iced/Intel/FormatterOutput.cs index 669f2efb4..36f1819dd 100644 --- a/Iced/Intel/FormatterOutput.cs +++ b/Iced/Intel/FormatterOutput.cs @@ -38,10 +38,31 @@ namespace Iced.Intel { /// true if we're about to format the operand, false if we've formatted it public virtual void OnOperand(int operand, bool begin) { } - internal void Write(in SymbolResult text) { - if ((text.Flags & SymbolFlags.Signed) != 0) - Write("-", FormatterOutputTextKind.Operator); - Write(text.Text); + internal void Write(in NumberFormatter numberFormatter, ref NumberFormattingOptions numberOptions, ulong address, in SymbolResult symbol) => + Write(numberFormatter, ref numberOptions, address, symbol, true, false); + + internal void Write(in NumberFormatter numberFormatter, ref NumberFormattingOptions numberOptions, ulong address, in SymbolResult symbol, bool writeMinusIfSigned, bool spacesBetweenOp) { + long displ = (long)(address - symbol.Address); + if ((symbol.Flags & SymbolFlags.Signed) != 0) { + if (writeMinusIfSigned) + Write("-", FormatterOutputTextKind.Operator); + displ = -displ; + } + Write(symbol.Text); + if (displ != 0) { + if (spacesBetweenOp) + Write(" ", FormatterOutputTextKind.Text); + if (displ < 0) { + Write("-", FormatterOutputTextKind.Operator); + displ = -displ; + } + else + Write("+", FormatterOutputTextKind.Operator); + if (spacesBetweenOp) + Write(" ", FormatterOutputTextKind.Text); + var s = numberFormatter.FormatUInt64(ref numberOptions, (ulong)displ, shortNumbers: true); + Write(s, FormatterOutputTextKind.Number); + } } internal void Write(in TextInfo text) { diff --git a/Iced/Intel/GasFormatter.cs b/Iced/Intel/GasFormatter.cs index 80a7094bd..5d7304c30 100644 --- a/Iced/Intel/GasFormatter.cs +++ b/Iced/Intel/GasFormatter.cs @@ -382,7 +382,7 @@ namespace Iced.Intel { operandOptions = FormatterOperandOptions.None; optionsProvider?.GetOperandOptions(operand, instructionOperand, ref instruction, ref operandOptions, ref numberOptions); if ((symbolResolver = this.symbolResolver) != null && symbolResolver.TryGetSymbol(operand, instructionOperand, ref instruction, imm64, immSize, out symbol)) - output.Write(symbol); + output.Write(numberFormatter, ref numberOptions, imm64, symbol); else { flowControl = FormatterUtils.GetFlowControl(ref instruction); if (opKind == InstrOpKind.NearBranch32) @@ -416,12 +416,12 @@ namespace Iced.Intel { output.Write(s, FormatterOutputTextKind.SelectorValue); } else - output.Write(selectorSymbol); + output.Write(numberFormatter, ref numberOptions, instruction.FarBranchSelector, selectorSymbol); output.Write(",", FormatterOutputTextKind.Punctuation); if (options.SpaceAfterOperandSeparator) output.Write(" ", FormatterOutputTextKind.Text); output.Write(ImmediateValuePrefix, FormatterOutputTextKind.Operator); - output.Write(symbol); + output.Write(numberFormatter, ref numberOptions, imm64, symbol); } else { flowControl = FormatterUtils.GetFlowControl(ref instruction); @@ -451,7 +451,7 @@ namespace Iced.Intel { operandOptions = FormatterOperandOptions.None; optionsProvider?.GetOperandOptions(operand, instructionOperand, ref instruction, ref operandOptions, ref numberOptions); if ((symbolResolver = this.symbolResolver) != null && symbolResolver.TryGetSymbol(operand, instructionOperand, ref instruction, imm8, 1, out symbol)) - output.Write(symbol); + output.Write(numberFormatter, ref numberOptions, imm8, symbol); else { if (numberOptions.SignedNumber && (sbyte)imm8 < 0) { output.Write("-", FormatterOutputTextKind.Operator); @@ -473,7 +473,7 @@ namespace Iced.Intel { operandOptions = FormatterOperandOptions.None; optionsProvider?.GetOperandOptions(operand, instructionOperand, ref instruction, ref operandOptions, ref numberOptions); if ((symbolResolver = this.symbolResolver) != null && symbolResolver.TryGetSymbol(operand, instructionOperand, ref instruction, imm16, 2, out symbol)) - output.Write(symbol); + output.Write(numberFormatter, ref numberOptions, imm16, symbol); else { if (numberOptions.SignedNumber && (short)imm16 < 0) { output.Write("-", FormatterOutputTextKind.Operator); @@ -495,7 +495,7 @@ namespace Iced.Intel { operandOptions = FormatterOperandOptions.None; optionsProvider?.GetOperandOptions(operand, instructionOperand, ref instruction, ref operandOptions, ref numberOptions); if ((symbolResolver = this.symbolResolver) != null && symbolResolver.TryGetSymbol(operand, instructionOperand, ref instruction, imm32, 4, out symbol)) - output.Write(symbol); + output.Write(numberFormatter, ref numberOptions, imm32, symbol); else { if (numberOptions.SignedNumber && (int)imm32 < 0) { output.Write("-", FormatterOutputTextKind.Operator); @@ -520,7 +520,7 @@ namespace Iced.Intel { operandOptions = FormatterOperandOptions.None; optionsProvider?.GetOperandOptions(operand, instructionOperand, ref instruction, ref operandOptions, ref numberOptions); if ((symbolResolver = this.symbolResolver) != null && symbolResolver.TryGetSymbol(operand, instructionOperand, ref instruction, imm64, 8, out symbol)) - output.Write(symbol); + output.Write(numberFormatter, ref numberOptions, imm64, symbol); else { if (numberOptions.SignedNumber && (long)imm64 < 0) { output.Write("-", FormatterOutputTextKind.Operator); @@ -706,7 +706,7 @@ namespace Iced.Intel { } if (useSymbol) - output.Write(symbol); + output.Write(numberFormatter, ref numberOptions, absAddr, symbol); else if (!hasBaseOrIndexReg || (displSize != 0 && (options.ShowZeroDisplacements || displ != 0))) { if (hasBaseOrIndexReg) { if (addrSize == 4) { diff --git a/Iced/Intel/ISymbolResolver.cs b/Iced/Intel/ISymbolResolver.cs index a9b93b963..7d2579b24 100644 --- a/Iced/Intel/ISymbolResolver.cs +++ b/Iced/Intel/ISymbolResolver.cs @@ -63,6 +63,11 @@ namespace Iced.Intel { /// The result of resolving a symbol /// public readonly struct SymbolResult { + /// + /// The address of the symbol + /// + public readonly ulong Address; + /// /// Contains the symbol /// @@ -76,8 +81,10 @@ namespace Iced.Intel { /// /// Constructor /// + /// The address of the symbol /// Symbol - public SymbolResult(string text) { + public SymbolResult(ulong address, string text) { + Address = address; Text = new TextInfo(text, FormatterOutputTextKind.Label); Flags = 0; } @@ -85,9 +92,11 @@ namespace Iced.Intel { /// /// Constructor /// + /// The address of the symbol /// Symbol /// Color - public SymbolResult(string text, FormatterOutputTextKind color) { + public SymbolResult(ulong address, string text, FormatterOutputTextKind color) { + Address = address; Text = new TextInfo(text, color); Flags = 0; } @@ -95,10 +104,12 @@ namespace Iced.Intel { /// /// Constructor /// + /// The address of the symbol /// Symbol /// Color /// Symbol flags - public SymbolResult(string text, FormatterOutputTextKind color, SymbolFlags flags) { + public SymbolResult(ulong address, string text, FormatterOutputTextKind color, SymbolFlags flags) { + Address = address; Text = new TextInfo(text, color); Flags = flags; } @@ -106,8 +117,10 @@ namespace Iced.Intel { /// /// Constructor /// + /// The address of the symbol /// Symbol - public SymbolResult(TextInfo text) { + public SymbolResult(ulong address, TextInfo text) { + Address = address; Text = text; Flags = 0; } @@ -115,9 +128,11 @@ namespace Iced.Intel { /// /// Constructor /// + /// The address of the symbol /// Symbol /// Symbol flags - public SymbolResult(TextInfo text, SymbolFlags flags) { + public SymbolResult(ulong address, TextInfo text, SymbolFlags flags) { + Address = address; Text = text; Flags = flags; } diff --git a/Iced/Intel/IntelFormatter.cs b/Iced/Intel/IntelFormatter.cs index a8d216c93..c9fa9f9ca 100644 --- a/Iced/Intel/IntelFormatter.cs +++ b/Iced/Intel/IntelFormatter.cs @@ -324,7 +324,7 @@ namespace Iced.Intel { optionsProvider?.GetOperandOptions(operand, instructionOperand, ref instruction, ref operandOptions, ref numberOptions); if ((symbolResolver = this.symbolResolver) != null && symbolResolver.TryGetSymbol(operand, instructionOperand, ref instruction, imm64, immSize, out symbol)) { FormatFlowControl(output, opInfo.Flags, operandOptions); - output.Write(symbol); + output.Write(numberFormatter, ref numberOptions, imm64, symbol); } else { flowControl = FormatterUtils.GetFlowControl(ref instruction); @@ -354,7 +354,7 @@ namespace Iced.Intel { optionsProvider?.GetOperandOptions(operand, instructionOperand, ref instruction, ref operandOptions, ref numberOptions); if ((symbolResolver = this.symbolResolver) != null && symbolResolver.TryGetSymbol(operand, instructionOperand, ref instruction, (uint)imm64, immSize, out symbol)) { FormatFlowControl(output, opInfo.Flags, operandOptions); - output.Write(symbol); + output.Write(numberFormatter, ref numberOptions, imm64, symbol); output.Write(",", FormatterOutputTextKind.Punctuation); if (options.SpaceAfterOperandSeparator) output.Write(" ", FormatterOutputTextKind.Text); @@ -364,7 +364,7 @@ namespace Iced.Intel { output.Write(s, FormatterOutputTextKind.SelectorValue); } else - output.Write(selectorSymbol); + output.Write(numberFormatter, ref numberOptions, instruction.FarBranchSelector, selectorSymbol); } else { flowControl = FormatterUtils.GetFlowControl(ref instruction); @@ -392,7 +392,7 @@ namespace Iced.Intel { operandOptions = FormatterOperandOptions.None; optionsProvider?.GetOperandOptions(operand, instructionOperand, ref instruction, ref operandOptions, ref numberOptions); if ((symbolResolver = this.symbolResolver) != null && symbolResolver.TryGetSymbol(operand, instructionOperand, ref instruction, imm8, 1, out symbol)) - output.Write(symbol); + output.Write(numberFormatter, ref numberOptions, imm8, symbol); else { if (numberOptions.SignedNumber && (sbyte)imm8 < 0) { output.Write("-", FormatterOutputTextKind.Operator); @@ -413,7 +413,7 @@ namespace Iced.Intel { operandOptions = FormatterOperandOptions.None; optionsProvider?.GetOperandOptions(operand, instructionOperand, ref instruction, ref operandOptions, ref numberOptions); if ((symbolResolver = this.symbolResolver) != null && symbolResolver.TryGetSymbol(operand, instructionOperand, ref instruction, imm16, 2, out symbol)) - output.Write(symbol); + output.Write(numberFormatter, ref numberOptions, imm16, symbol); else { if (numberOptions.SignedNumber && (short)imm16 < 0) { output.Write("-", FormatterOutputTextKind.Operator); @@ -434,7 +434,7 @@ namespace Iced.Intel { operandOptions = FormatterOperandOptions.None; optionsProvider?.GetOperandOptions(operand, instructionOperand, ref instruction, ref operandOptions, ref numberOptions); if ((symbolResolver = this.symbolResolver) != null && symbolResolver.TryGetSymbol(operand, instructionOperand, ref instruction, imm32, 4, out symbol)) - output.Write(symbol); + output.Write(numberFormatter, ref numberOptions, imm32, symbol); else { if (numberOptions.SignedNumber && (int)imm32 < 0) { output.Write("-", FormatterOutputTextKind.Operator); @@ -458,7 +458,7 @@ namespace Iced.Intel { operandOptions = FormatterOperandOptions.None; optionsProvider?.GetOperandOptions(operand, instructionOperand, ref instruction, ref operandOptions, ref numberOptions); if ((symbolResolver = this.symbolResolver) != null && symbolResolver.TryGetSymbol(operand, instructionOperand, ref instruction, imm64, 8, out symbol)) - output.Write(symbol); + output.Write(numberFormatter, ref numberOptions, imm64, symbol); else { if (numberOptions.SignedNumber && (long)imm64 < 0) { output.Write("-", FormatterOutputTextKind.Operator); @@ -719,7 +719,7 @@ namespace Iced.Intel { else if ((symbol.Flags & SymbolFlags.Signed) != 0) output.Write("-", FormatterOutputTextKind.Operator); - output.Write(symbol.Text); + output.Write(numberFormatter, ref numberOptions, absAddr, symbol, false, Options.SpaceBetweenMemoryAddOperators); } else if (!needPlus || (displSize != 0 && (options.ShowZeroDisplacements || displ != 0))) { if (needPlus) { diff --git a/Iced/Intel/MasmFormatter.cs b/Iced/Intel/MasmFormatter.cs index 3aac6779d..d190189fb 100644 --- a/Iced/Intel/MasmFormatter.cs +++ b/Iced/Intel/MasmFormatter.cs @@ -307,7 +307,7 @@ namespace Iced.Intel { optionsProvider?.GetOperandOptions(operand, instructionOperand, ref instruction, ref operandOptions, ref numberOptions); if ((symbolResolver = this.symbolResolver) != null && symbolResolver.TryGetSymbol(operand, instructionOperand, ref instruction, imm64, immSize, out symbol)) { FormatFlowControl(output, FormatterUtils.GetFlowControl(ref instruction), operandOptions); - output.Write(symbol); + output.Write(numberFormatter, ref numberOptions, imm64, symbol); } else { flowControl = FormatterUtils.GetFlowControl(ref instruction); @@ -343,9 +343,9 @@ namespace Iced.Intel { output.Write(s, FormatterOutputTextKind.SelectorValue); } else - output.Write(selectorSymbol); + output.Write(numberFormatter, ref numberOptions, instruction.FarBranchSelector, selectorSymbol); output.Write(":", FormatterOutputTextKind.Punctuation); - output.Write(symbol); + output.Write(numberFormatter, ref numberOptions, imm64, symbol); } else { flowControl = FormatterUtils.GetFlowControl(ref instruction); @@ -378,7 +378,7 @@ namespace Iced.Intel { FormatKeyword(output, offsetKeyword); output.Write(" ", FormatterOutputTextKind.Text); } - output.Write(symbol); + output.Write(numberFormatter, ref numberOptions, imm8, symbol); } else { if (numberOptions.SignedNumber && (sbyte)imm8 < 0) { @@ -404,7 +404,7 @@ namespace Iced.Intel { FormatKeyword(output, offsetKeyword); output.Write(" ", FormatterOutputTextKind.Text); } - output.Write(symbol); + output.Write(numberFormatter, ref numberOptions, imm16, symbol); } else { if (numberOptions.SignedNumber && (short)imm16 < 0) { @@ -430,7 +430,7 @@ namespace Iced.Intel { FormatKeyword(output, offsetKeyword); output.Write(" ", FormatterOutputTextKind.Text); } - output.Write(symbol); + output.Write(numberFormatter, ref numberOptions, imm32, symbol); } else { if (numberOptions.SignedNumber && (int)imm32 < 0) { @@ -459,7 +459,7 @@ namespace Iced.Intel { FormatKeyword(output, offsetKeyword); output.Write(" ", FormatterOutputTextKind.Text); } - output.Write(symbol); + output.Write(numberFormatter, ref numberOptions, imm64, symbol); } else { if (numberOptions.SignedNumber && (long)imm64 < 0) { @@ -711,7 +711,7 @@ namespace Iced.Intel { else if ((symbol.Flags & SymbolFlags.Signed) != 0) output.Write("-", FormatterOutputTextKind.Operator); - output.Write(symbol.Text); + output.Write(numberFormatter, ref numberOptions, absAddr, symbol, false, Options.SpaceBetweenMemoryAddOperators); } else if (!needPlus || (displSize != 0 && (options.ShowZeroDisplacements || displ != 0))) { if (needPlus) { diff --git a/Iced/Intel/NasmFormatter.cs b/Iced/Intel/NasmFormatter.cs index bb92f1ce9..c9cc35f3e 100644 --- a/Iced/Intel/NasmFormatter.cs +++ b/Iced/Intel/NasmFormatter.cs @@ -325,7 +325,7 @@ namespace Iced.Intel { optionsProvider?.GetOperandOptions(operand, instructionOperand, ref instruction, ref operandOptions, ref numberOptions); if ((symbolResolver = this.symbolResolver) != null && symbolResolver.TryGetSymbol(operand, instructionOperand, ref instruction, imm64, immSize, out symbol)) { FormatFlowControl(output, opInfo.Flags, operandOptions); - output.Write(symbol); + output.Write(numberFormatter, ref numberOptions, imm64, symbol); } else { operandOptions = options.ShowBranchSize ? FormatterOperandOptions.None : FormatterOperandOptions.NoBranchSize; @@ -363,9 +363,9 @@ namespace Iced.Intel { output.Write(s, FormatterOutputTextKind.SelectorValue); } else - output.Write(selectorSymbol); + output.Write(numberFormatter, ref numberOptions, instruction.FarBranchSelector, selectorSymbol); output.Write(":", FormatterOutputTextKind.Punctuation); - output.Write(symbol); + output.Write(numberFormatter, ref numberOptions, imm64, symbol); } else { flowControl = FormatterUtils.GetFlowControl(ref instruction); @@ -391,7 +391,7 @@ namespace Iced.Intel { operandOptions = FormatterOperandOptions.None; optionsProvider?.GetOperandOptions(operand, instructionOperand, ref instruction, ref operandOptions, ref numberOptions); if ((symbolResolver = this.symbolResolver) != null && symbolResolver.TryGetSymbol(operand, instructionOperand, ref instruction, imm8, 1, out symbol)) - output.Write(symbol); + output.Write(numberFormatter, ref numberOptions, imm8, symbol); else { if (numberOptions.SignedNumber && (sbyte)imm8 < 0) { output.Write("-", FormatterOutputTextKind.Operator); @@ -413,7 +413,7 @@ namespace Iced.Intel { operandOptions = FormatterOperandOptions.None; optionsProvider?.GetOperandOptions(operand, instructionOperand, ref instruction, ref operandOptions, ref numberOptions); if ((symbolResolver = this.symbolResolver) != null && symbolResolver.TryGetSymbol(operand, instructionOperand, ref instruction, imm16, 2, out symbol)) - output.Write(symbol); + output.Write(numberFormatter, ref numberOptions, imm16, symbol); else { if (numberOptions.SignedNumber && (short)imm16 < 0) { output.Write("-", FormatterOutputTextKind.Operator); @@ -435,7 +435,7 @@ namespace Iced.Intel { operandOptions = FormatterOperandOptions.None; optionsProvider?.GetOperandOptions(operand, instructionOperand, ref instruction, ref operandOptions, ref numberOptions); if ((symbolResolver = this.symbolResolver) != null && symbolResolver.TryGetSymbol(operand, instructionOperand, ref instruction, imm32, 4, out symbol)) - output.Write(symbol); + output.Write(numberFormatter, ref numberOptions, imm32, symbol); else { if (numberOptions.SignedNumber && (int)imm32 < 0) { output.Write("-", FormatterOutputTextKind.Operator); @@ -460,7 +460,7 @@ namespace Iced.Intel { operandOptions = FormatterOperandOptions.None; optionsProvider?.GetOperandOptions(operand, instructionOperand, ref instruction, ref operandOptions, ref numberOptions); if ((symbolResolver = this.symbolResolver) != null && symbolResolver.TryGetSymbol(operand, instructionOperand, ref instruction, imm64, 8, out symbol)) - output.Write(symbol); + output.Write(numberFormatter, ref numberOptions, imm64, symbol); else { if (numberOptions.SignedNumber && (long)imm64 < 0) { output.Write("-", FormatterOutputTextKind.Operator); @@ -788,7 +788,7 @@ namespace Iced.Intel { else if ((symbol.Flags & SymbolFlags.Signed) != 0) output.Write("-", FormatterOutputTextKind.Operator); - output.Write(symbol.Text); + output.Write(numberFormatter, ref numberOptions, absAddr, symbol, false, Options.SpaceBetweenMemoryAddOperators); } else if (!needPlus || (displSize != 0 && (options.ShowZeroDisplacements || displ != 0))) { if (needPlus) {