1
0
mirror of https://github.com/fadden/6502bench.git synced 2025-04-06 08:47:20 +00:00

Add regression test for data analysis bug

The uncategorized data scanner isn't supposed to create strings or
".fill" directives that straddle labels, long comments, notes,
visualizations, or ORG directives.  The test for crossing an ORG
directive is incomplete, and doesn't correctly handle no-op ORGs
(where the new address is the same as the old address).

The code generator doesn't output ORGs that are hidden inside other
things, so we're not generating bad code, but it looks funny on
screen and may cause problems later on.  The 2004-numeric-types test
has the basic .align/.fill/.bulk directive tests, and now has an
extended set of tests for uncategorized data region splitting.
This commit is contained in:
Andy McFadden 2019-12-30 14:09:18 -08:00
parent 676ab2554d
commit f157fbbfd3
9 changed files with 310 additions and 45 deletions

View File

@ -0,0 +1,58 @@
/*
* Copyright 2019 faddenSoft
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Collections.ObjectModel;
using PluginCommon;
namespace RuntimeData.Test2004 {
public class VisTest2004 : MarshalByRefObject, IPlugin, IPlugin_Visualizer {
// IPlugin
public string Identifier {
get { return "Test2004 Dummy Visualizer"; }
}
// Visualization identifiers; DO NOT change or projects that use them will break.
private const string VIS_DUMMY = "dummy";
// Visualization descriptors.
private VisDescr[] mDescriptors = new VisDescr[] {
new VisDescr(VIS_DUMMY, "Dummy", VisDescr.VisType.Bitmap,
new VisParamDescr[] { })
};
// IPlugin
public void Prepare(IApplication appRef, byte[] fileData, AddressTranslate addrTrans) { }
// IPlugin
public void Unprepare() { }
// IPlugin_Visualizer
public VisDescr[] GetVisGenDescrs() {
return mDescriptors;
}
// IPlugin_Visualizer
public IVisualization2d Generate2d(VisDescr descr,
ReadOnlyDictionary<string, object> parms) {
VisBitmap8 vb = new VisBitmap8(1, 1);
vb.AddColor(0, 0, 0, 0);
vb.SetPixelIndex(0, 0, 0);
return vb;
}
}
}

View File

@ -1,61 +1,70 @@
### 6502bench SourceGen dis65 v1.0 ###
{
"_ContentVersion":2,"FileDataLength":1024,"FileDataCrc32":-1387500320,"ProjectProps":{
"CpuName":"6502","IncludeUndocumentedInstr":false,"TwoByteBrk":false,"EntryFlags":13566159,"AutoLabelStyle":"Simple","AnalysisParams":{
"AnalyzeUncategorizedData":true,"DefaultTextScanMode":"LowHighAscii","MinCharsForString":4,"SeekNearbyTargets":false,"SmartPlpHandling":true},
"PlatformSymbolFileIdentifiers":[],"ExtensionScriptFileIdentifiers":[],"ProjectSyms":{
"_ContentVersion":3,"FileDataLength":1200,"FileDataCrc32":1114187983,"ProjectProps":{
"CpuName":"6502","IncludeUndocumentedInstr":false,"TwoByteBrk":false,"EntryFlags":32702671,"AutoLabelStyle":"Simple","AnalysisParams":{
"AnalyzeUncategorizedData":true,"DefaultTextScanMode":"LowHighAscii","MinCharsForString":4,"SeekNearbyTargets":true,"SmartPlpHandling":true},
"PlatformSymbolFileIdentifiers":[],"ExtensionScriptFileIdentifiers":["PROJ:2004-numeric-types.cs"],"ProjectSyms":{
}},
"AddressMap":[{
"Offset":0,"Addr":4096}],"TypeHints":[{
"Offset":0,"Addr":4096},
{
"Offset":1032,"Addr":5128},
{
"Offset":1048,"Addr":5160}],"TypeHints":[{
"Low":0,"High":0,"Hint":"Code"}],"StatusFlagOverrides":{
},
"Comments":{
"566":"comment","882":"incorrect alignment"},
"588":"comment on bulk","882":"incorrect alignment","1128":"end-of-line comment"},
"LongComments":{
"-2147483647":{
"Text":"Project file was edited to get all big-endian data types, and to have an incorrect .junk alignment directive.","BoxMode":false,"MaxWidth":80,"BackgroundColor":0}},
"Text":"Project file was edited to get all big-endian data types, and to have an incorrect .junk alignment directive.","BoxMode":false,"MaxWidth":80,"BackgroundColor":0},
"1112":{
"Text":"long comment\r\n","BoxMode":false,"MaxWidth":80,"BackgroundColor":0}},
"Notes":{
},
"1144":{
"Text":":ETON","BoxMode":false,"MaxWidth":80,"BackgroundColor":0}},
"UserLabels":{
"566":{
"Label":"LABEL","Value":4662,"Source":"User","Type":"LocalOrGlobalAddr"}},
"588":{
"Label":"LABEL","Value":4684,"Source":"User","Type":"GlobalAddr","LabelAnno":"None"},
"1064":{
"Label":"UserLabel","Value":5176,"Source":"User","Type":"GlobalAddr","LabelAnno":"None"}},
"OperandFormats":{
"1":{
"23":{
"Length":1,"Format":"NumericLE","SubFormat":"Hex","SymbolRef":null},
"2":{
"Length":2,"Format":"NumericLE","SubFormat":"Hex","SymbolRef":null},
"4":{
"Length":3,"Format":"NumericLE","SubFormat":"Hex","SymbolRef":null},
"7":{
"Length":4,"Format":"NumericLE","SubFormat":"Hex","SymbolRef":null},
"11":{
"Length":1,"Format":"NumericBE","SubFormat":"Hex","SymbolRef":null},
"12":{
"Length":2,"Format":"NumericBE","SubFormat":"Hex","SymbolRef":null},
"14":{
"Length":3,"Format":"NumericBE","SubFormat":"Hex","SymbolRef":null},
"17":{
"Length":4,"Format":"NumericBE","SubFormat":"Hex","SymbolRef":null},
"21":{
"Length":2,"Format":"Fill","SubFormat":"None","SymbolRef":null},
"24":{
"Length":3,"Format":"Fill","SubFormat":"None","SymbolRef":null},
"28":{
"Length":4,"Format":"Fill","SubFormat":"None","SymbolRef":null},
"Length":2,"Format":"NumericLE","SubFormat":"Hex","SymbolRef":null},
"26":{
"Length":3,"Format":"NumericLE","SubFormat":"Hex","SymbolRef":null},
"29":{
"Length":4,"Format":"NumericLE","SubFormat":"Hex","SymbolRef":null},
"33":{
"Length":5,"Format":"Fill","SubFormat":"None","SymbolRef":null},
"Length":1,"Format":"NumericBE","SubFormat":"Hex","SymbolRef":null},
"34":{
"Length":2,"Format":"NumericBE","SubFormat":"Hex","SymbolRef":null},
"36":{
"Length":3,"Format":"NumericBE","SubFormat":"Hex","SymbolRef":null},
"39":{
"Length":4,"Format":"NumericBE","SubFormat":"Hex","SymbolRef":null},
"43":{
"Length":2,"Format":"Fill","SubFormat":"None","SymbolRef":null},
"46":{
"Length":3,"Format":"Fill","SubFormat":"None","SymbolRef":null},
"50":{
"Length":4,"Format":"Fill","SubFormat":"None","SymbolRef":null},
"55":{
"Length":5,"Format":"Fill","SubFormat":"None","SymbolRef":null},
"61":{
"Length":256,"Format":"Fill","SubFormat":"None","SymbolRef":null},
"296":{
"318":{
"Length":257,"Format":"Fill","SubFormat":"None","SymbolRef":null},
"553":{
"575":{
"Length":1,"Format":"Dense","SubFormat":"None","SymbolRef":null},
"555":{
"577":{
"Length":10,"Format":"Dense","SubFormat":"None","SymbolRef":null},
"566":{
"588":{
"Length":64,"Format":"Dense","SubFormat":"None","SymbolRef":null},
"631":{
"Length":137,"Format":"Junk","SubFormat":"Align256","SymbolRef":null},
"653":{
"Length":115,"Format":"Junk","SubFormat":"Align256","SymbolRef":null},
"769":{
"Length":63,"Format":"Junk","SubFormat":"Align64","SymbolRef":null},
"833":{
@ -67,6 +76,14 @@
"882":{
"Length":2,"Format":"Junk","SubFormat":"Align128","SymbolRef":null},
"884":{
"Length":140,"Format":"Junk","SubFormat":"Align256","SymbolRef":null}},
"Length":140,"Format":"Junk","SubFormat":"Align256","SymbolRef":null},
"1192":{
"Length":1,"Format":"NumericLE","SubFormat":"Binary","SymbolRef":null}},
"LvTables":{
}}
"1096":{
"Variables":[],"ClearPrevious":true}},
"Visualizations":[{
"Tag":"vis000488","VisGenIdent":"dummy","VisGenParams":{
}}],"VisualizationAnimations":[],"VisualizationSets":{
"1160":{
"Tags":["vis000488"]}}}

View File

@ -1,7 +1,27 @@
;Project file was edited to get all big-endian data types, and to have an
;incorrect .junk alignment directive.
.cpu "6502"
.enc sg_hiascii
.cdef $20,$7e,$a0
* = $1000
bit L1448
jsr L14A8
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
rts
.byte $11
@ -27,7 +47,7 @@
.byte $80
.byte $11,$22,$33,$44,$55,$66,$77,$88,$99,$00
.byte $80
LABEL .byte $00,$11,$22,$33,$44,$55,$66,$77,$88,$99,$aa,$bb,$cc,$dd,$ee,$ff ;comment
LABEL .byte $00,$11,$22,$33,$44,$55,$66,$77,$88,$99,$aa,$bb,$cc,$dd,$ee,$ff ;comment on bulk
.byte $00,$11,$22,$33,$44,$55,$66,$77,$88,$99,$aa,$bb,$cc,$dd,$ee,$ff
.byte $00,$11,$22,$33,$44,$55,$66,$77,$88,$99,$aa,$bb,$cc,$dd,$ee,$ff
.byte $ff,$ee,$dd,$cc,$bb,$aa,$99,$88,$77,$66,$55,$44,$33,$22,$11,$00
@ -43,3 +63,26 @@ LABEL .byte $00,$11,$22,$33,$44,$55,$66,$77,$88,$99,$aa,$bb,$cc,$dd,$ee,$ff
.byte $81
.fill 2,$dd ;incorrect alignment
.align 256,$00
.fill 16,$82
.fill 8,$83
.logical $1428
.fill 8,$83
.fill 8,$84
UserLabel .fill 8,$84
.fill 8,$85
L1448 .fill 8,$85
.fill 16,$86
.text $87,$87,$87,$87,$87,$87,$87,$87
;long comment
.text $87,$87,$87,$87,$87,$87,$87,$87
.fill 16,$88
.fill 8,$89
.fill 8,$89
.text $8a,$8a,$8a,$8a,$8a,$8a,$8a,$8a
.text $8a,$8a,$8a,$8a,$8a,$8a,$8a,$8a
.fill 8,$8b
L14A8 .fill 8,$8b
.fill 8,$8c
.byte %10001100
.fill 7,$8c
.here

View File

@ -1,6 +1,24 @@
;Project file was edited to get all big-endian data types, and to have an
;incorrect .junk alignment directive.
org $1000
bit L1448
jsr L14A8
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
rts
dfb $11
@ -26,7 +44,7 @@
dfb $80
hex 11223344556677889900
dfb $80
LABEL hex 00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff ;comment
LABEL hex 00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff ;comment on bulk
hex 00112233445566778899aabbccddeeffffeeddccbbaa99887766554433221100
dfb $80
ds \,$aa
@ -40,3 +58,25 @@ LABEL hex 00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff
dfb $81
ds 2,$dd ;incorrect alignment
ds \,$00
ds 16,$82
ds 8,$83
org $1428
ds 8,$83
ds 8,$84
UserLabel ds 8,$84
ds 8,$85
L1448 ds 8,$85
ds 16,$86
asc 8787878787878787
;long comment
asc 8787878787878787
ds 16,$88
ds 8,$89
ds 8,$89
asc 8a8a8a8a8a8a8a8a
asc 8a8a8a8a8a8a8a8a
ds 8,$8b
L14A8 ds 8,$8b
ds 8,$8c
dfb %10001100
ds 7,$8c

View File

@ -2,6 +2,24 @@
;incorrect .junk alignment directive.
!cpu 6502
* = $1000
bit L1448
jsr L14A8
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
rts
!byte $11
@ -27,7 +45,7 @@
!byte $80
!hex 11223344556677889900
!byte $80
LABEL !hex 00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff ;comment
LABEL !hex 00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff ;comment on bulk
!hex 00112233445566778899aabbccddeeffffeeddccbbaa99887766554433221100
!byte $80
!align 255,0,$aa
@ -41,3 +59,26 @@ LABEL !hex 00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff
!byte $81
!fill 2,$dd ;incorrect alignment
!align 255,0,$00
!fill 16,$82
!fill 8,$83
!pseudopc $1428 {
!fill 8,$83
!fill 8,$84
UserLabel !fill 8,$84
!fill 8,$85
L1448 !fill 8,$85
!fill 16,$86
!fill 8,$87
;long comment
!fill 8,$87
!fill 16,$88
!fill 8,$89
!fill 8,$89
!fill 8,$8a
!fill 8,$8a
!fill 8,$8b
L14A8 !fill 8,$8b
!fill 8,$8c
!byte %10001100
!fill 7,$8c
} ;!pseudopc

View File

@ -3,6 +3,24 @@
.setcpu "6502"
; .segment "SEG000"
.org $1000
bit L1448
jsr L14A8
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
rts
.byte $11
@ -28,12 +46,12 @@
.byte $80
.byte $11,$22,$33,$44,$55,$66,$77,$88,$99,$00
.byte $80
LABEL: .byte $00,$11,$22,$33,$44,$55,$66,$77,$88,$99,$aa,$bb,$cc,$dd,$ee,$ff ;comment
LABEL: .byte $00,$11,$22,$33,$44,$55,$66,$77,$88,$99,$aa,$bb,$cc,$dd,$ee,$ff ;comment on bulk
.byte $00,$11,$22,$33,$44,$55,$66,$77,$88,$99,$aa,$bb,$cc,$dd,$ee,$ff
.byte $00,$11,$22,$33,$44,$55,$66,$77,$88,$99,$aa,$bb,$cc,$dd,$ee,$ff
.byte $ff,$ee,$dd,$cc,$bb,$aa,$99,$88,$77,$66,$55,$44,$33,$22,$11,$00
.byte $80
.res 137,$aa
.res 115,$aa
.byte $81
.res 63,$00
.byte $81
@ -44,3 +62,26 @@ LABEL: .byte $00,$11,$22,$33,$44,$55,$66,$77,$88,$99,$aa,$bb,$cc,$dd,$ee,$ff
.byte $81
.res 2,$dd ;incorrect alignment
.res 140,$00
.res 16,$82
.res 8,$83
; .segment "SEG002"
.org $1428
.res 8,$83
.res 8,$84
UserLabel: .res 8,$84
.res 8,$85
L1448: .res 8,$85
.res 16,$86
.res 8,$87
;long comment
.res 8,$87
.res 16,$88
.res 8,$89
.res 8,$89
.res 8,$8a
.res 8,$8a
.res 8,$8b
L14A8: .res 8,$8b
.res 8,$8c
.byte %10001100
.res 7,$8c

View File

@ -1,11 +1,15 @@
# 6502bench SourceGen generated linker script for 2004-numeric-types
MEMORY {
MAIN: file=%O, start=%S, size=65536;
# MEM000: file=%O, start=$1000, size=1024;
# MEM000: file=%O, start=$1000, size=1032;
# MEM001: file=%O, start=$1408, size=16;
# MEM002: file=%O, start=$1428, size=152;
}
SEGMENTS {
CODE: load=MAIN, type=rw;
# SEG000: load=MEM000, type=rw;
# SEG001: load=MEM001, type=rw;
# SEG002: load=MEM002, type=rw;
}
FEATURES {}
SYMBOLS {}

View File

@ -3,6 +3,11 @@
;
; Assembler: Merlin 32
ORG $1000
bit dref+8
jsr cref+8
ds 16,$ea ;bunch of NOPs
rts
dfb $11 ;.dd1
@ -50,3 +55,19 @@
dfb $81
hex dddd ;EDIT FILE: give this a bogus alignment
ds \,$00 ;.junk, align 256
; Check to see what splits a .fill block. Each 16-byte chunk has some sort
; of item added at +8. DO NOT format these; the goal is to check the behavior
; of the data analyzer.
ds 16,$82 ;EDIT: add no-op .ORG
ds 16,$83 ;EDIT: add .ORG that adjusts +16
ORG *+16
ds 16,$84 ;EDIT: add user label
dref ds 16,$85 ;has a data reference
ds 16,$86 ;EDIT: add a local variable table (may not split)
ds 16,$87 ;EDIT: add full-line comment
ds 16,$88 ;EDIT: add end-of-line comment (should not split)
ds 16,$89 ;EDIT: add note
ds 16,$8a ;EDIT: add visualization
cref ds 16,$8b ;has a code reference
ds 16,$8c ;EDIT: format byte as binary