mirror of
https://github.com/fadden/6502bench.git
synced 2025-01-11 02:30:12 +00:00
Exercise address-to-offset function in plugin
Also exercise various formatting options. Also, fix a bug where the code that applies project/platform symbols to numeric references was ignoring inline data items.
This commit is contained in:
parent
245e0bd9f3
commit
dc8e49e4d8
@ -39,7 +39,19 @@ namespace PluginCommon {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compute a standard CRC-32 (polynomial 0xedb88320) on a buffer of data.
|
||||
/// Determines whether the provided offset and length are valid for the array.
|
||||
/// </summary>
|
||||
/// <param name="data">Data array that to check against.</param>
|
||||
/// <param name="startOff">Start offset.</param>
|
||||
/// <param name="len">Number of bytes.</param>
|
||||
/// <returns>True if the specified range falls within the array bounds.</returns>
|
||||
public static bool IsInBounds(byte[] data, int startOff, int len) {
|
||||
return !(startOff < 0 || len < 0 || startOff >= data.Length || len > data.Length ||
|
||||
startOff + len > data.Length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Computes a standard CRC-32 (polynomial 0xedb88320) on a buffer of data.
|
||||
/// </summary>
|
||||
/// <param name="data">Buffer to process.</param>
|
||||
/// <returns>CRC value.</returns>
|
||||
|
@ -1188,8 +1188,8 @@ namespace SourceGen {
|
||||
// the correct thing to do.
|
||||
address = attr.OperandAddress;
|
||||
sym = SymbolTable.FindNonVariableByAddress(address);
|
||||
} else if (attr.IsDataStart && attr.DataDescriptor != null &&
|
||||
attr.DataDescriptor.IsNumeric &&
|
||||
} else if ((attr.IsDataStart || attr.IsInlineDataStart) &&
|
||||
attr.DataDescriptor != null && attr.DataDescriptor.IsNumeric &&
|
||||
attr.DataDescriptor.FormatSubType == FormatDescriptor.SubType.Address) {
|
||||
// Found a Numeric/Address item that matches. Data items don't have
|
||||
// OperandAddress or OperandOffset set, so we need to check manually to
|
||||
|
Binary file not shown.
@ -7,7 +7,7 @@ using System.Collections.Generic;
|
||||
using PluginCommon;
|
||||
|
||||
namespace RuntimeData.Test2022 {
|
||||
public class Test2022 : MarshalByRefObject, IPlugin, IPlugin_InlineJsr, IPlugin_InlineJsl {
|
||||
public class Test2022A : MarshalByRefObject, IPlugin, IPlugin_InlineJsr, IPlugin_InlineJsl {
|
||||
private IApplication mAppRef;
|
||||
private byte[] mFileData;
|
||||
|
||||
@ -20,7 +20,7 @@ namespace RuntimeData.Test2022 {
|
||||
|
||||
public string Identifier {
|
||||
get {
|
||||
return "Test 2022-extension-scripts";
|
||||
return "Test 2022-extension-scripts A";
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ namespace RuntimeData.Test2022 {
|
||||
mAppRef = appRef;
|
||||
mFileData = fileData;
|
||||
|
||||
mAppRef.DebugLog("Test2022(id=" + AppDomain.CurrentDomain.Id + "): prepare()");
|
||||
mAppRef.DebugLog("Test2022-A(id=" + AppDomain.CurrentDomain.Id + "): prepare()");
|
||||
|
||||
foreach (PlSymbol sym in plSyms) {
|
||||
switch (sym.Label) {
|
99
SourceGen/SGTestData/2022-extension-scripts-b.cs
Normal file
99
SourceGen/SGTestData/2022-extension-scripts-b.cs
Normal file
@ -0,0 +1,99 @@
|
||||
// Copyright 2019 faddenSoft. All Rights Reserved.
|
||||
// See the LICENSE.txt file for distribution terms (Apache 2.0).
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using PluginCommon;
|
||||
|
||||
namespace RuntimeData.Test2022 {
|
||||
public class Test2022B : MarshalByRefObject, IPlugin, IPlugin_InlineBrk {
|
||||
private IApplication mAppRef;
|
||||
private byte[] mFileData;
|
||||
private AddressTranslate mAddrTrans;
|
||||
|
||||
public string Identifier {
|
||||
get {
|
||||
return "Test 2022-extension-scripts B";
|
||||
}
|
||||
}
|
||||
|
||||
public void Prepare(IApplication appRef, byte[] fileData, AddressTranslate addrTrans,
|
||||
List<PlSymbol> plSyms) {
|
||||
mAppRef = appRef;
|
||||
mFileData = fileData;
|
||||
mAddrTrans = addrTrans;
|
||||
|
||||
mAppRef.DebugLog("Test2022-B(id=" + AppDomain.CurrentDomain.Id + "): prepare()");
|
||||
}
|
||||
|
||||
public void CheckBrk(int offset, out bool noContinue) {
|
||||
noContinue = true;
|
||||
|
||||
// need BRK, function byte, and two-byte address
|
||||
if (!Util.IsInBounds(mFileData, offset, 4)) {
|
||||
return;
|
||||
}
|
||||
byte func = mFileData[offset + 1];
|
||||
if (func < 0x01 || func > 0x02) {
|
||||
return;
|
||||
}
|
||||
|
||||
mAppRef.SetInlineDataFormat(offset + 1, 1, DataType.NumericLE,
|
||||
DataSubType.Hex, null);
|
||||
mAppRef.SetInlineDataFormat(offset + 2, 2, DataType.NumericLE,
|
||||
DataSubType.Address, null);
|
||||
noContinue = false;
|
||||
|
||||
int structAddr = Util.GetWord(mFileData, offset + 2, 2, false);
|
||||
int structOff = mAddrTrans.AddressToOffset(offset, structAddr);
|
||||
if (structOff < 0) {
|
||||
mAppRef.DebugLog("Unable to get offset for address $" + structAddr.ToString("x6"));
|
||||
return;
|
||||
}
|
||||
|
||||
switch (func) {
|
||||
case 0x01:
|
||||
if (!Util.IsInBounds(mFileData, structOff, 27)) {
|
||||
mAppRef.DebugLog("Struct doesn't fit in file");
|
||||
return;
|
||||
}
|
||||
mAppRef.SetInlineDataFormat(structOff + 0, 2, DataType.NumericLE,
|
||||
DataSubType.Decimal, null);
|
||||
mAppRef.SetInlineDataFormat(structOff + 2, 2, DataType.NumericBE,
|
||||
DataSubType.Hex, null);
|
||||
mAppRef.SetInlineDataFormat(structOff + 4, 4, DataType.NumericLE,
|
||||
DataSubType.Hex, null);
|
||||
mAppRef.SetInlineDataFormat(structOff + 8, 4, DataType.NumericBE,
|
||||
DataSubType.Hex, null);
|
||||
mAppRef.SetInlineDataFormat(structOff + 12, 1, DataType.NumericLE,
|
||||
DataSubType.Ascii, null);
|
||||
mAppRef.SetInlineDataFormat(structOff + 13, 1, DataType.NumericLE,
|
||||
DataSubType.HighAscii, null);
|
||||
mAppRef.SetInlineDataFormat(structOff + 14, 8, DataType.StringDci,
|
||||
DataSubType.Ascii, null);
|
||||
mAppRef.SetInlineDataFormat(structOff + 22, 3, DataType.NumericLE,
|
||||
DataSubType.Address, null);
|
||||
mAppRef.SetInlineDataFormat(structOff + 25, 2, DataType.NumericLE,
|
||||
DataSubType.Symbol, "data02");
|
||||
break;
|
||||
case 0x02:
|
||||
if (!Util.IsInBounds(mFileData, structOff, 2)) {
|
||||
mAppRef.DebugLog("Struct doesn't fit in file");
|
||||
return;
|
||||
}
|
||||
mAppRef.SetInlineDataFormat(structOff, 2, DataType.NumericLE,
|
||||
DataSubType.Address, null);
|
||||
int nextAddr = Util.GetWord(mFileData, structOff + 2, 2, false);
|
||||
int nextOff = mAddrTrans.AddressToOffset(structOff, nextAddr);
|
||||
if (!Util.IsInBounds(mFileData, nextOff, 1)) {
|
||||
mAppRef.DebugLog("Struct doesn't fit in file");
|
||||
return;
|
||||
}
|
||||
mAppRef.SetInlineDataFormat(nextOff, 8, DataType.StringGeneric,
|
||||
DataSubType.HighAscii, null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
### 6502bench SourceGen dis65 v1.0 ###
|
||||
{
|
||||
"_ContentVersion":2,"FileDataLength":156,"FileDataCrc32":-741040917,"ProjectProps":{
|
||||
"_ContentVersion":2,"FileDataLength":203,"FileDataCrc32":-1621468157,"ProjectProps":{
|
||||
"CpuName":"65816","IncludeUndocumentedInstr":false,"EntryFlags":32702671,"AutoLabelStyle":"Simple","AnalysisParams":{
|
||||
"AnalyzeUncategorizedData":true,"DefaultTextScanMode":"LowHighAscii","MinCharsForString":4,"SeekNearbyTargets":true,"SmartPlpHandling":true},
|
||||
"PlatformSymbolFileIdentifiers":["PROJ:2022-extension-scripts.sym65"],"ExtensionScriptFileIdentifiers":["PROJ:2022-extension-scripts.cs"],"ProjectSyms":{
|
||||
"PlatformSymbolFileIdentifiers":["PROJ:2022-extension-scripts.sym65"],"ExtensionScriptFileIdentifiers":["PROJ:2022-extension-scripts-a.cs","PROJ:2022-extension-scripts-b.cs"],"ProjectSyms":{
|
||||
"PrintInlineDciString":{
|
||||
"DataDescriptor":{
|
||||
"Length":1,"Format":"NumericLE","SubFormat":"Hex","SymbolRef":null},
|
||||
@ -11,7 +11,7 @@
|
||||
"AddressMap":[{
|
||||
"Offset":0,"Addr":4096},
|
||||
{
|
||||
"Offset":135,"Addr":4352}],"TypeHints":[{
|
||||
"Offset":182,"Addr":4352}],"TypeHints":[{
|
||||
"Low":0,"High":0,"Hint":"Code"}],"StatusFlagOverrides":{
|
||||
},
|
||||
"Comments":{
|
||||
@ -21,12 +21,18 @@
|
||||
"Notes":{
|
||||
},
|
||||
"UserLabels":{
|
||||
"121":{
|
||||
"Label":"PrintInline8String","Value":4217,"Source":"User","Type":"LocalOrGlobalAddr"},
|
||||
"122":{
|
||||
"Label":"PrintInlineRev8String","Value":4218,"Source":"User","Type":"LocalOrGlobalAddr"},
|
||||
"123":{
|
||||
"Label":"PrintInlineNullString","Value":4219,"Source":"User","Type":"LocalOrGlobalAddr"}},
|
||||
"129":{
|
||||
"Label":"PrintInline8String","Value":4225,"Source":"User","Type":"LocalOrGlobalAddr"},
|
||||
"130":{
|
||||
"Label":"PrintInlineRev8String","Value":4226,"Source":"User","Type":"LocalOrGlobalAddr"},
|
||||
"131":{
|
||||
"Label":"PrintInlineNullString","Value":4227,"Source":"User","Type":"LocalOrGlobalAddr"},
|
||||
"160":{
|
||||
"Label":"data02","Value":4256,"Source":"User","Type":"LocalOrGlobalAddr"},
|
||||
"163":{
|
||||
"Label":"data03","Value":4259,"Source":"User","Type":"LocalOrGlobalAddr"},
|
||||
"132":{
|
||||
"Label":"data01","Value":4228,"Source":"User","Type":"LocalOrGlobalAddr"}},
|
||||
"OperandFormats":{
|
||||
},
|
||||
"LvTables":{
|
||||
|
@ -1,4 +1,6 @@
|
||||
.cpu "65816"
|
||||
.enc sg_hiascii
|
||||
.cdef $20,$7e,$a0
|
||||
.enc sg_ascii
|
||||
.cdef $20,$7e,$20
|
||||
PrintInlineL1String = $011000
|
||||
@ -23,9 +25,15 @@ PrintInlineDciString = $013000
|
||||
.text $14,$00,"string with length/2"
|
||||
jsl PrintInlineDciString
|
||||
.shift "DCI string"
|
||||
jsr L107C
|
||||
jsr L10AB
|
||||
jsr L110F
|
||||
jsr L1108
|
||||
brk
|
||||
.byte $01
|
||||
.word data01
|
||||
brk
|
||||
.byte $02
|
||||
.word data02
|
||||
rts
|
||||
|
||||
PrintInline8String rts
|
||||
@ -34,8 +42,30 @@ PrintInlineRev8String rts
|
||||
|
||||
PrintInlineNullString rts
|
||||
|
||||
L107C jsr PrintInlineNullString
|
||||
per $7ff4
|
||||
data01 .word 4386
|
||||
.byte $33,$44
|
||||
.dword $88776655
|
||||
.byte $99,$88,$77,$66
|
||||
.byte 'f'
|
||||
.byte 'F' | $80
|
||||
.byte $40
|
||||
.byte $c1
|
||||
.byte $42
|
||||
.byte $c3
|
||||
.byte $44
|
||||
.byte $c5
|
||||
.byte $46
|
||||
.byte $c7
|
||||
.long PrintInlineL2String
|
||||
.word data02
|
||||
.byte $80
|
||||
data02 .word data03
|
||||
.byte $80
|
||||
.enc sg_hiascii
|
||||
data03 .text "AllEight"
|
||||
|
||||
L10AB jsr PrintInlineNullString
|
||||
per $8023
|
||||
rtl
|
||||
|
||||
.byte $65
|
||||
@ -43,6 +73,7 @@ L107C jsr PrintInlineNullString
|
||||
.byte $20
|
||||
.byte $01
|
||||
.logical $1100
|
||||
.enc sg_ascii
|
||||
.text "string"
|
||||
.byte $00
|
||||
.byte $60
|
||||
|
@ -18,9 +18,15 @@ PrintInlineDciString equ $013000
|
||||
strl 'string with length/2'
|
||||
jsl PrintInlineDciString
|
||||
dci 'DCI string'
|
||||
jsr L107C
|
||||
jsr L10AB
|
||||
jsr L110F
|
||||
jsr L1108
|
||||
brk
|
||||
dfb $01
|
||||
dw data01
|
||||
brk
|
||||
dfb $02
|
||||
dw data02
|
||||
rts
|
||||
|
||||
PrintInline8String rts
|
||||
@ -29,8 +35,29 @@ PrintInlineRev8String rts
|
||||
|
||||
PrintInlineNullString rts
|
||||
|
||||
L107C jsr PrintInlineNullString
|
||||
per $7ff4
|
||||
data01 dw 4386
|
||||
ddb $3344
|
||||
adrl $88776655
|
||||
dfb $99,$88,$77,$66
|
||||
dfb 'f'
|
||||
dfb "F"
|
||||
dfb $40
|
||||
dfb $c1
|
||||
dfb $42
|
||||
dfb $c3
|
||||
dfb $44
|
||||
dfb $c5
|
||||
dfb $46
|
||||
dfb $c7
|
||||
adr PrintInlineL2String
|
||||
dw data02
|
||||
dfb $80
|
||||
data02 dw data03
|
||||
dfb $80
|
||||
data03 asc "AllEight"
|
||||
|
||||
L10AB jsr PrintInlineNullString
|
||||
per $8023
|
||||
rtl
|
||||
|
||||
dfb $65
|
||||
|
@ -21,9 +21,15 @@ PrintInlineDciString = $013000
|
||||
!text $14,$00,"string with length/2"
|
||||
jsl PrintInlineDciString
|
||||
!text "DCI strin",$e7
|
||||
jsr L107C
|
||||
jsr L10AB
|
||||
jsr L110F
|
||||
jsr L1108
|
||||
brk
|
||||
!byte $01
|
||||
!word data01
|
||||
brk
|
||||
!byte $02
|
||||
!word data02
|
||||
rts
|
||||
|
||||
PrintInline8String rts
|
||||
@ -32,8 +38,31 @@ PrintInlineRev8String rts
|
||||
|
||||
PrintInlineNullString rts
|
||||
|
||||
L107C jsr PrintInlineNullString
|
||||
per $7ff4
|
||||
data01 !word 4386
|
||||
!byte $33,$44
|
||||
!32 $88776655
|
||||
!byte $99,$88,$77,$66
|
||||
!byte 'f'
|
||||
!byte 'F' | $80
|
||||
!byte $40
|
||||
!byte $c1
|
||||
!byte $42
|
||||
!byte $c3
|
||||
!byte $44
|
||||
!byte $c5
|
||||
!byte $46
|
||||
!byte $c7
|
||||
!24 PrintInlineL2String
|
||||
!word data02
|
||||
!byte $80
|
||||
data02 !word data03
|
||||
!byte $80
|
||||
!xor $80 {
|
||||
data03 !text "AllEight"
|
||||
}
|
||||
|
||||
L10AB jsr PrintInlineNullString
|
||||
per $8023
|
||||
rtl
|
||||
|
||||
!byte $65
|
||||
|
@ -22,9 +22,15 @@ PrintInlineDciString = $013000
|
||||
.byte $14,$00,"string with length/2"
|
||||
jsl PrintInlineDciString
|
||||
.byte "DCI strin",$e7
|
||||
jsr L107C
|
||||
jsr L10AB
|
||||
jsr L110F
|
||||
jsr L1108
|
||||
brk
|
||||
.byte $01
|
||||
.word data01
|
||||
brk
|
||||
.byte $02
|
||||
.word data02
|
||||
rts
|
||||
|
||||
PrintInline8String: rts
|
||||
@ -33,8 +39,34 @@ PrintInlineRev8String: rts
|
||||
|
||||
PrintInlineNullString: rts
|
||||
|
||||
L107C: jsr PrintInlineNullString
|
||||
per $7ff4
|
||||
data01: .word 4386
|
||||
.dbyt $3344
|
||||
.dword $88776655
|
||||
.byte $99,$88,$77,$66
|
||||
.byte 'f'
|
||||
.byte 'F' | $80
|
||||
.byte $40
|
||||
.byte $c1
|
||||
.byte $42
|
||||
.byte $c3
|
||||
.byte $44
|
||||
.byte $c5
|
||||
.byte $46
|
||||
.byte $c7
|
||||
.faraddr PrintInlineL2String
|
||||
.word data02
|
||||
.byte $80
|
||||
data02: .word data03
|
||||
.byte $80
|
||||
.macro HiAscii Arg
|
||||
.repeat .strlen(Arg), I
|
||||
.byte .strat(Arg, I) | $80
|
||||
.endrep
|
||||
.endmacro
|
||||
data03: HiAscii "AllEight"
|
||||
|
||||
L10AB: jsr PrintInlineNullString
|
||||
per $8023
|
||||
rtl
|
||||
|
||||
.byte $65
|
||||
|
@ -1,7 +1,7 @@
|
||||
# 6502bench SourceGen generated linker script for 2022-extension-scripts
|
||||
MEMORY {
|
||||
MAIN: file=%O, start=%S, size=65536;
|
||||
# MEM000: file=%O, start=$1000, size=135;
|
||||
# MEM000: file=%O, start=$1000, size=182;
|
||||
# MEM001: file=%O, start=$1100, size=21;
|
||||
}
|
||||
SEGMENTS {
|
||||
|
@ -17,9 +17,9 @@ PrintInlineDciString equ $013000 ;EDIT: add to project symbols
|
||||
mx %11
|
||||
|
||||
; check basics
|
||||
jsr Print8String
|
||||
jsr PrintInline8String
|
||||
asc '01234567'
|
||||
jsr PrintRev8String
|
||||
jsr PrintInlineRev8String
|
||||
asc '76543210'
|
||||
jsr PrintInlineNullString
|
||||
asc 'null-term string',00
|
||||
@ -36,12 +36,39 @@ PrintInlineDciString equ $013000 ;EDIT: add to project symbols
|
||||
jsr off_end
|
||||
jsr too_long
|
||||
|
||||
; check block formatting
|
||||
brk $01
|
||||
dw data01
|
||||
|
||||
brk $02
|
||||
dw data02
|
||||
|
||||
rts
|
||||
|
||||
PrintInline8String rts ;EDIT: set label
|
||||
PrintInlineRev8String rts ;EDIT: set label
|
||||
PrintInlineNullString rts ;EDIT: set label
|
||||
|
||||
data01 ;EDIT: set label
|
||||
dw $1122 ;should be little-endian
|
||||
dw $4433 ;should be big-endian
|
||||
hex 55667788 ;32-bit
|
||||
hex 99887766 ;32-bit big-endian
|
||||
dfb 'f' ;ASCII
|
||||
dfb "F" ;high ASCII
|
||||
hex 40C142C344C546C7 ;bad DCI string
|
||||
hex 002001 ;24-bit addr
|
||||
dw data02 ;by symbol
|
||||
|
||||
dfb $80
|
||||
|
||||
data02 ;EDIT: set label, must be "data02"
|
||||
dw data03
|
||||
dfb $80
|
||||
|
||||
data03 ;EDIT: set label
|
||||
asc "AllEight"
|
||||
|
||||
|
||||
; check address split across string
|
||||
broken jsr PrintInlineNullString
|
||||
|
Loading…
x
Reference in New Issue
Block a user