1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-05-31 22:41:37 +00:00
Commit Graph

110 Commits

Author SHA1 Message Date
Andy McFadden
3b20566b10 Minor tweaks
Note that address region isolation doesn't prevent explicit label
references from working (add update the test to prove it).

Added a note about pre-label xrefs.
2024-05-22 14:02:53 -07:00
Andy McFadden
7a7ff44d3a Address region isolation, part 3 (of 3)
If an address resolves to a user label in an isolated region, we
don't want to use it.  However, we still want to try to match it
to a project/platform symbol.

For example, suppose the isolated code wants to reference address
$1C00, which is a memory-mapped I/O location in one area, but a
regular bunch of code in the other.  We don't want it to map to
the regular code, but we do want it to resolve to our table of
platform I/O addresses.

We now handle this correctly.  The regression test has been updated
to check this.  The current implementation does a linear scan through
the symbol table, but I'm hoping this is not a common situation.

The reference manual has been updated to describe the new feature.
2024-05-21 14:14:32 -07:00
Andy McFadden
e137db2b5c Address region isolation, part 2
Added an address-to-offset test in the GeneratePlatformSymbolRefs()
method, which sets the operand symbols for anything that lands outside
the scope of the file.  Because the region isolation code prevented
symbols from being associated with the operands in the initial code
scan, those operands were being examined here.  Without the additional
test, the inappropriate label associations were getting a second chance.

Added "[!in]" and "[!out]" to the comment field of .addrs lines.  This
is only for the on-screen display and text exports, not asm gen.

Bumped the project file CONTENT_VERSION.

Added a regression test (20290-region-isolation).

The test turned up an existing problem: pre-labels are emitted by the
asm generators on their own line, but the code that puts excessively
long labels on a separate line wasn't taking that into account.  This
has been fixed.  No changes to existing regression tests, which didn't
happen to use long labels.
2024-05-21 10:32:18 -07:00
Andy McFadden
d9fe0b5471 Fix crash in OMF converter tool
The OMF converter calls some of the project update routines at a
point where the data file hasn't been fully formed, making it a bit
fragile.
2022-04-06 14:20:11 -07:00
Andy McFadden
6e9ff395d2 Add offset to PlSymbol
It's useful for extension scripts to be able to get the file offset
of symbols in non-addressable regions.  One example of this is CHR
ROM data for an NES cartridge.  However, we were getting the offset
by doing an address-to-offset mapping on the plugin side, which by
definition doesn't work for non-addressable memory.

So we now add the offset to PlSymbol objects for user labels and
address region pre-labels.  The NES visualizer has been updated to
use the new field.

Also, fixed a bogus complaint about bank overruns for non-addressable
regions.
2021-10-23 21:35:30 -07:00
Andy McFadden
0fb0b4cca8 Fix some address region issues
Fixed a crash when the listing is refreshed while a .adrend line is
the only thing selected.

Fixed .adrend lines being spammed if the last thing before it is a
multi-byte item, and you edit a comment / note / label on that line.
Harmless, but weird.

Also, added keyboard shortcuts in DefSymbol editor, so you can change
from address to constant with Alt+C.
2021-10-17 18:02:29 -07:00
Andy McFadden
cb114be0f6 Add "uninitialized data" format type
This allows regions that hold variable storage to be marked as data
that is initialized by the program before it is used.  Previously
the choices were to treat it as bulk data (initialized) or junk
(totally unused), neither of which are correct.

This is functionally equivalent to "junk" as far as source code
generation is concerned (though it doesn't have to be).

For the code/data/junk counter, uninitialized data is counted as
junk, because it technically does not need to be part of the binary.
2021-10-13 15:05:07 -07:00
Andy McFadden
6df29e562f Various tweaks
Changed the code that generates cross-references for pre-labels to
ignore labels in regions with non-addressable parents.  Also, changed
the code that complains about references to labels in non-addressable
areas to ignore pre-labels, because it was complaining about references
to pre-labels on region starts that were followed by a non-addressable
region start.

In the address region edit dialog, split up the descriptive text for
the "resize" option to make it easier to see the new end offset and
length.  It doesn't look quite right because it's not using the mono
font like the text near the top, but it'll do.

When multiple lines are selected, the Info window now shows the first
line/offset, last line/offset, and bytes spanned by the selection.
This is helpful if you're trying to figure out how big something is.
2021-10-11 14:44:44 -07:00
Andy McFadden
d2326c389f ORG rework, part 8
Implemented address region pre-labels.  These are useful if the code is
relocating a block from address A to address B, because the code that
does the copying refers to both the "before" address and the "after"
address.  Previously you'd give the block the "after" address and the
"before" would just appears as hex, because it's effectively an
external address.

Pre-labels are shown on screen with their address, but no other fields.
Showing the address makes it easy to see the label's value, which isn't
always obvious right before a .arstart.  The labels are suppressed if the
address value evaluates to non-addressable.

This defines a new type of symbol, which is external and always global
in scope.  Pre-labels affect label localization and must go through
the usual remapping to handle clashes with opcode mnemonics and the
use of leading underscores.  Cross-references are computed, but are
associated with the file offset rather than the label line itself.

Added a new filter to the Symbols window ("PreL").

Implemented label input and checking in the address editor.  Generally
added highlighting of relevant error labels.
2021-10-04 20:41:19 -07:00
Andy McFadden
e6c5c7f8df ORG rework, part 6
Added support for non-addressable regions, which are useful for things
like file headers stripped out by the system loader, or chunks that
get loaded into non-addressable graphics RAM.  Regions are specified
with the "NA" address value.  The code list displays the address field
greyed out, starting from zero (which is kind of handy if you want to
know the relative offset within the region).

Putting labels in non-addressable regions doesn't make sense, but
symbol resolution is complicated enough that we really only have two
options: ignore the labels entirely, or allow them but warn of their
presence.  The problem isn't so much the label, which you could
legitimately want to access from an extension script, but rather the
references to them from code or data.  So we keep the label and add a
warning to the Messages list when we see a reference.

Moved NON_ADDR constants to Address class.  AddressMap now has a copy.
This is awkward because Asm65 and CommonUtil don't share.

Updated the asm code generators to understand NON_ADDR, and reworked
the API so that Merlin and cc65 output is correct for nested regions.

Address region changes are now noted in the anattribs array, which
makes certain operations faster than checking the address map.  It
also fixes a failure to recognize mid-instruction region changes in
the code analyzer.

Tweaked handling of synthetic regions, which are non-addressable areas
generated by the linear address map traversal to fill in any "holes".
The address region editor now treats attempts to edit them as
creation of a new region.
2021-09-30 21:11:26 -07:00
Andy McFadden
3a2c4fa6d2 ORG rework, part 4
Reimplemented "set address" dialog as the Address Region Editor.  The
new dialog configures itself differently depending on whether the user
appears to be trying to create, edit, or resize a region.  Each mode
has two options, to allow the user to choose between floating and fixed
end points.

The old dialog would allow you to delete an address override by erasing
the address field.  Now there's an explicit "delete region" button.

Changed the SetAddress undoable change function to use AddressMapEntry
objects.

We now show detailed information on .arstart/.arend in the Info window
when the lines are selected.

PRG files are now created without specifying a region for the first
two bytes, so the load address exists in a NON_ADDR hole.  Fixed a
couple of issues to make that look right.
2021-09-26 17:17:54 -07:00
Andy McFadden
5f472b60cf ORG rework, part 3
Split ".org" into ".arstart" and ".arend" (address range start/end).
Address range ends are now shown in the code list view, and the
pseudo-op can be edited in app settings.  Address range starts are
now shown after notes and long comments, rather than before, which
brings the on-screen display in sync with generated code.

Reworked the address range editor UI to include the new features.
The implementation is fully broken.

More changes to the AddressMap API, putting the resolved region length
into a separate ActualLength field.  Added FindRegion().  Renamed
some things.

Code generation changed slightly: the blank line before a region-end
line now comes after it, and ACME's "} ;!pseudopc" is now just "}".
This required minor updates to some of the regression test results.
2021-09-22 15:28:11 -07:00
Andy McFadden
d4c481839e ORG rework, part 2
AddressMap API reshuffle.  Added "pre-label" to class and API.  Split
AddressMapEntry into two parts to make it clear when FLOATING_LEN
has been resolved.

Updated display line list generator to use in-line linear map
traversal.  Previous approach was to walk through the list of regions
in a second pass, inserting .ORG directives, but that was awkward
and is no longer needed.
2021-09-20 15:17:17 -07:00
Andy McFadden
39b7b20144 ORG rework, part 1
This is the first step toward changing the address region map from a
linear list to a hierarchy.  See issue #107 for the plan.

The AddressMap class has been rewritten to support the new approach.
The rest of the project has been updated to conform to the new API,
but feature-wise is unchanged.  While the map class supports
nested regions with explicit lengths, the rest of the application
still assumes a series of non-overlapping regions with "floating"
lengths.

The Set Address dialog is currently non-functional.

All of the output for cc65 changed because generation of segment
comments has been removed.  Some of the output for ACME changed as
well, because we no longer follow "* = addr" with a redundant
pseudopc statement.  ACME and 65tass have similar approaches to
placing things in memory, and so now have similar implementations.
2021-09-16 17:02:19 -07:00
Andy McFadden
ec2ad529c8 Remove a couple of faulty assertions
One asserted unnecessarily, one should have been an if/then.  Both
were concerned with instruction operands being formatted with
type "address".
2021-08-11 16:25:24 -07:00
Andy McFadden
49603ba417 Refine handling of C64 PRG header
A few tweaks:
- Test now requires an ORG on offset +000002, not just a correct
  address.
- Suppress on-screen display of the initial ORG directive when
  a PRG file is detected.  Subtle, but helpful.
- In new project setup, fix initial address for PRG projects that
  load at $0000.
- In new project setup, add a "load address" comment to the first line.

Also, fix some out-of-date documentation.

(issue #90)
2020-10-18 13:22:24 -07:00
Andy McFadden
49f4017410 Rename "hints" to "analyzer tags"
Variables, types, and comments have been updated to reflect the new
naming scheme.

The project file serialization code is untouched, because the data
is output as serialized enumerated values.  Adding a string conversion
layer didn't seem worthwhile.

No changes in behavior.

(issue #89)
2020-10-15 16:55:29 -07:00
Andy McFadden
3f154406d4 Fix multi-byte local var xrefs
The cross-references for multi-byte local variable table entries were
not showing adjustment values.
2020-09-05 18:18:55 -07:00
Andy McFadden
f30780a9de Fix Message update when broken symbolic ref is fixed
Renaming a user label doesn't cause a re-analysis, just a display
update, because nothing structural is changing.  However, that's not
quite true when you have a reference to a non-existent label (e.g.
"LDA hoser"), and you rename a label to match (e.g. change "blah"
to "hoser").  The most obvious consequence was that the Message list,
which enumerates the broken symbolic references, was not being
updated.

We now identify broken references during the refactoring rename, and
change the reanalysis mode accordingly.

There is a deeper problem, where undoing the label rename does the
wrong thing with the previously-broken symbolic references (in the
earlier example, it "undoes" them to "blah" rather than back to
"hoser").  I added some notes about that, but it's harder to fix.

Also, clean up some code that was still treating ReanalysisScope as
if it were bit flags.
2020-09-04 15:21:47 -07:00
Andy McFadden
bd5b556a7f Show "ptr" for pointer use in cross-reference list
Consider:
 LDA $00 loads a value from address $00
 LDA $00,X might load from $00, or might not
 LDA ($00),Y dereferences $00 as a 16-bit pointer
 LDA ($00,X) dereferences a pointer, not necessarily from $00

When perusing the cross-reference list, it's useful to be able to
tell whether an instruction is accessing the location, using it as a
base address, or deferencing it as a pointer.  We now show "ptr" in
the list for pointer dereferences.  (We already showed "idx" for
indexed accesses.)
2020-09-04 13:26:41 -07:00
Andy McFadden
a3c7cd0cf9 Add File > Reload External Files
The new menu item reloads platform symbol files and extension scripts,
which is very handy when making edits to project files.
2020-07-19 16:59:41 -07:00
Andy McFadden
195c93a94a Reboot sandbox when required
Another chapter in the never-ending AppDomain security saga.

If a computer goes to sleep while SourceGen is running with a project
open, life gets confusing when the system wakes up.  The keep-alive
timer fires and a ping is sent to the remote AppDomain, successfully.
At the same time, the lease expires on the remote side, and the objects
are discarded (apparently without bothering to query the ILease object).
This failure mode is 100% repeatable.

Since we can't prevent sandbox objects from disappearing, we have to
detect and recover from the problem.  Fortunately we don't keep any
necessary state on the plugin side, so we can just tear the whole
thing down and recreate it.

The various methods in ScriptManager now do a "health check" before
making calls into the plugin AppDomain.  If the ping attempt fails,
the AppDomain is "rebooted" by destroying it and creating a new one,
reloading all plugins that were in there before.  The plugin binaries
*should* still be in the PluginDllCache directory since the ping failure
was due to objects being discarded, not AppDomain shutdown, and Windows
doesn't let you mess with files that hold executable code.

A new "reboot security sandbox" option has been added to the DEBUG
menu to facilitate testing.

The PluginManager's Ping() method gets called more often, but not to
the extent that performance will be affected.

This change also adds a finalizer to DisasmProject, since we're relying
on it to shut down the ScriptManager, and it's relying on callers to
invoke its cleanup function.  The finalizer throws an assertion if the
cleanup function doesn't get called.

(Issue #82)
2020-07-19 13:20:18 -07:00
Andy McFadden
ee58d9e803 Data Bank Register management, part 3
Added a "fake" assembler pseudo-op for DBR changes.  Display entries
in line list.

Added entry to double-click handler so that you can double-click on
a PLB instruction operand to open the data bank editor.
2020-07-09 16:52:23 -07:00
Andy McFadden
973d162edb Data Bank Register management, part 2
Changed basic data item from an "extended enum" to a class, so we can
keep track of where things come from (useful for the display list).

Finished edit dialog.  Added serialization to project file.
2020-07-09 11:14:55 -07:00
Andy McFadden
18e6951f17 Add Data Bank Register management, part 1
On the 65816, 16-bit data access instructions (e.g. LDA abs) are
expanded to 24 bits by merging in the Data Bank Register (B).  The
value of the register is difficult to determine via static analysis,
so we need a way to annotate the disassembly with the correct value.
Without this, the mapping of address to file offset will sometimes
be incorrect.

This change adds the basic data structures and "fixup" function, a
functional but incomplete editor, and source for a new test case.
2020-07-08 17:56:27 -07:00
Andy McFadden
d58b747571 Use relocation data to format instruction operands
This was a relatively lightweight change to confirm the usefulness
of relocation data.  The results were very positive.

The relatively superficial integration of the data into the data
analysis process causes some problems, e.g. the cross-reference table
entries show an offset because the code analyzer's computed operand
offset doesn't match the value of the label.  The feature should be
considered experimental

The feature can be enabled or disabled with a project property.  The
results were sufficiently useful and non-annoying to make the setting
enabled by default.
2020-07-03 17:58:41 -07:00
Andy McFadden
327ad4fbbc Store reduced OMF relocation data in project file
A "cooked" form of the relocation data is added to the project, for
use during data analysis.

Also, changed the data grids in the segment viewer to allow multi-
select, so users can copy & paste the contents.
2020-07-02 17:10:05 -07:00
Andy McFadden
bb7998d1f0 Progress toward OMF file handling
Added generation of data and project files.  We're applying the
relocation dictionary, but not using the information to inform the
formatting.
2020-06-30 08:20:12 -07:00
Andy McFadden
47c773dcdf Show "idx" for indexed accesses in References window
Sometimes it's useful to know whether an address referenced by a
function is a direct access, or is being used as a base address.
(I'm somewhat undecided on this one, since it clutters up the list
a bit.  Giving it a try.)
2020-05-02 14:09:53 -07:00
Andy McFadden
3820bfee8b Set initial focus to appropriate field for project properties
If you double-click a project symbol declaration, the symbol editor
opens.  I found that I was double-clicking on the comment field and
typing with the expectation that the comment would be updated, but
it was actually setting the initial focus to the label field.

With this change the symbol editor will focus the label, value, or
comment field based on which column was double-clicked.

The behavior for Actions > Edit Project Symbol and other paths to the
symbol editor are unchanged.

Also, disabled a wayward assert.
2020-04-23 11:01:07 -07:00
Andy McFadden
a42584834b Fix address cross-reference code
The code was wrong, but due to aggressive auto-label generation, it
rarely had an opportunity to express itself.  The problem appeared
when you formatted a 16-bit value as an address, but the address
was outside the file and not associated with a project/platform
symbol.  This fixes the glitch and adds some logging.
2020-04-10 11:00:27 -07:00
Andy McFadden
5010fbae37 Various minor changes
- Freeze Note brushes, so HTML export doesn't blow up when it tries
  to access them.
- Add Ctrl+Shift+E as keyboard shortcut for File > Export.
- For code/data percentage, count inline data as data.
- Tweak code/data percentage text.
- Document Merlin32 '{' bug.
- Tweak tutorial text.
2020-03-30 16:50:52 -07:00
Andy McFadden
1e56490b6b Another update to project/platform cross-references
Don't show adjustments for operands that aren't full addresses.  For
example, "LDA BLAH" shows an adjustment, but "LDA #>BLAH" does not.
This matches the behavior for internal addresses.
2020-03-23 15:16:30 -07:00
Andy McFadden
5d852e3ea6 Don't show adjustment in constant cross-references
The change to properly display adjustments to project/platform
symbol cross-references also added them to constants, but based on
the reference address rather than the operand value.  We could
generate an adjustment from the value, but I'm not sure if that's
actually useful.
2020-03-18 08:04:13 -07:00
Andy McFadden
63b84dcece Fix display of project/platform cross-ref adjustments
We were trying to use the in-file calculation for an external
address, so the adjustment was always zero.

Also, don't pass a fill brush for wireframe rendering.  (No change
in behavior.)
2020-03-17 13:49:14 -07:00
Andy McFadden
0bbb307d4e Correct handling of no-op .ORG statements
These were being overlooked because they didn't actually cause
anything to happen (a no-op .ORG sets the address to what it would
already have been).  The assembly source generator works in a way
that causes them to be skipped, so everybody was happy.

This seemed like the sort of thing that was likely to cause problems
down the road, however, so we now split regions correctly when a
no-op .ORG is encountered.  This affects the uncategorized data
analyzer and selection grouping.

This changed the behavior of the 2004-numeric-types test, which was
visibly weird in the UI but generated correct output.

Added the 2024-ui-edge-cases test to provide a place to exercise
edge cases when testing the UI by hand.  It has some value for the
automated regression test, so it's included there.

Also, changed the AddressMapEntry objects to be immutable.  This
is handy when passing lists of them around.
2020-02-28 14:49:18 -08:00
Andy McFadden
c535201884 Prefer narrower project/platform symbols
We want to be able to declare a symbol for a struct or buffer that
spans the entire width, and then declare more-specific items within
it that take precedence.  This worked for everything but the very
first byte, because on an exact match we were resolving the conflict
alphabetically.

Now, if one is wider than the other, we use the narrower definition.

Updated 2021-external-symbols with some additional test cases.
2020-01-23 10:49:22 -08:00
Andy McFadden
0013718d59 Clear Lv xrefs at start of xref gen
Local variable cross-references were accumulating without bound on
every refresh.
2020-01-14 17:56:55 -08:00
Andy McFadden
422af1193c Tweak def symbol sort order
The list of EQUs at the top of the file is sorted, by type, then
value, then name.  This adds width as an additional check, so that
if you have overlapping items the widest comes first.

This is nice when you have a general entry for a block of data, and
then specific entries for some locations within the block.
2020-01-04 16:56:31 -08:00
Andy McFadden
7c2fbec773 Fix proxy object timeout in visualization editor
The visualization editor was retaining an IPlugin reference for the
visualization generator selection combo box.  After 5 minutes the
proxy object timed out, so if you left the editor open and inactive
for that long you'd start getting weird errors.

We now keep the script identifier string and use that to get a
fresh IPlugin proxy object.
2019-12-28 14:00:48 -08:00
Andy McFadden
091955b9c2 Allow setting the start/end address for a block
If you have a single line selected, Set Address adds a .ORG directive
that changes the addresses of all following data, until the next .ORG
directive is reached.  Sometimes code will relocate part of itself,
and it's useful to be able to set the address at the end of the block
to what it would have been before the .ORG change.

If you have multiple lines selected, we now add the second .ORG to
the offset that follows the last selected line.

Also, fixed a bug in the Symbol value updater that wasn't handling
non-unique labels correctly.
2019-12-25 18:17:50 -08:00
Andy McFadden
3acf83ead3 Check for hidden visualizations
As always, we try to prevent this from happening, but a determined
user can accomplish anything.
2019-12-25 11:15:22 -08:00
Andy McFadden
4e645d911c Render the animation overlay image instead of loading from a file
Mostly because I'm a lousy artist, and if I do it in code it's easy
to make it symmetric and tweak the colors.
2019-12-22 14:02:39 -08:00
Andy McFadden
1cdb31de32 Visualizer improvements
Various changes:
- Generally treat visualization sets like long comments and notes
  when it comes to defining data region boundaries.  (We were doing
  this for selections; now we're also doing it for format-as-word
  and in the data analyzer when scanning for strings/fill.)
- Clear the visualization cache when the address map is altered.
  This is necessary for visualizers that dereference addresses.
- Read the Apple II screen image from a series of addresses rather
  than a series of offsets.  This allows it to work when the image
  is contiguous in memory but split into chunks in the file.
- Put 1 pixel of padding around the images in the main code list,
  so they don't blend into the background.
- Remember the last visualizer used, so we can re-use it the next
  time the user selects "new".
- Move min-size hack from Loaded to ContentRendered, as it apparently
  spoils CenterOwner placement.
2019-12-06 15:05:49 -08:00
Andy McFadden
2f56c56e5c Add visualization thumbnails
Thumbnails are now visible in the main list and in the visualization
set editor.  They're generated on first need, and regenerated when
the set of plugins changes.

Added a checkerboard background for the visualization editor bitmap
preview.  (It looks all official now.)
2019-12-03 16:11:21 -08:00
Andy McFadden
365864ccdf More progress on visualization
Implemented Apple II hi-res bitmap conversion.  Supports B&W and
color.  Uses essentially the same algorithm as CiderPress.

Experimented with displaying non-text items in ListView.  I assumed
it would work, since it's the sort of thing WPF is designed to do,
but it's always wise to approach with caution.  Visualization Sets
now show a 64x64 button as a placeholder for the eventual thumbnail.

Some things were being flaky, which turned out to be because I
wasn't Prepare()ing the plugins before using them from Edit
Visualization.  To make this a deterministic failure I added an
Unprepare() call that tells the plugin that we're all done.

NOTE: this breaks all existing plugins.
2019-11-30 18:02:03 -08:00
Andy McFadden
e7fccfda03 More progress on visualization
Got parameter in/out working in EditVisualization dialog.  Did some
rearranging in PluginCommon interfaces and data structures.  Still
doesn't do anything useful.
2019-11-26 18:54:42 -08:00
Andy McFadden
836626bdc3 Work in progress on visualization
Basic infrastructure for taking a list of parameters from a plugin
and turning it into a collection of UI controls, merging in values
from a Visualization object.  Doesn't yet do anything useful.

WPF makes the hard things easy and the easy things hard.  This was
a hard thing, so it was easy to do (with some helpful sample code).
Yay WPF?
2019-11-25 14:27:38 -08:00
Andy McFadden
bef664ae7e Don't do nearby SYM-1 for zero-page values
It's pretty common for code to access BUFFER-1,X, but it's rare for
the buffer to live on zero page memory.  More often than not we're
auto-formatting zero-page operands with a nearby symbol when they're
just simple variables.  It's more confusing than useful, so we don't
do that anymore.
2019-11-23 16:27:06 -08:00
Andy McFadden
ac30512ed3 Groundwork for visualization sets
Placeholder data structure plus menu command, undoable change, etc.
2019-11-22 20:45:57 -08:00