1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-11-18 15:06:07 +00:00

Add ability to "erase" previously-defined platform symbols

While disassembling some code I found that I wanted the ROM entry
points, but the zero page usage was significantly different and the
ROM labels were distracting.  Splitting the symbol file in two was
a possibility, but I'm afraid this will lead to a very large
collection of very small files, and we'll lose any sense of relation
between the ROM entry points and the ZP addresses used to pass
arguments.

Platform symbols have the lowest priority when resolving by address,
but using that to hide the unwanted labels requires creating project
symbols or local variables for things that you might not know what
they do yet.  It's possible to hide a platform symbol by adding
another symbol with the same label and an invalid value.

This change formalizes and extends the "hiding" of platform symbols
to full erasure, so that they don't clutter up the symbol table.
This also tightens up the platform symbol parser to only accept
values in the range 0 <= value <= 0x00ffffff (24-bit positive
integers).

An "F8-ROM-nozp" symbol file is now part of the standard set.  A
project can include that to erase the zero-page definitions.

(I'm not entirely convinced this is the right approach, so I'm not
doing this treatment on other symbol files... consider this an
experiment.  Another approach would be some sort of conditional
inclusion, or perhaps erase-by-tag, but that requires some UI work
in the app to define what you want included or excluded.)
This commit is contained in:
Andy McFadden 2019-10-27 10:54:42 -07:00
parent 0709ff94de
commit 0fc121c9cb
4 changed files with 70 additions and 6 deletions

View File

@ -1037,9 +1037,17 @@ namespace SourceGen {
// order, so we can just overwrite earlier symbols with matching labels. // order, so we can just overwrite earlier symbols with matching labels.
foreach (PlatformSymbols ps in PlatformSyms) { foreach (PlatformSymbols ps in PlatformSyms) {
foreach (Symbol sym in ps) { foreach (Symbol sym in ps) {
if (sym.Value == PlatformSymbols.ERASE_VALUE) {
// "erase" value
if (SymbolTable.TryGetValue(sym.Label, out Symbol found)) {
SymbolTable.Remove(found);
}
} else {
// overwrite
SymbolTable[sym.Label] = sym; SymbolTable[sym.Label] = sym;
} }
} }
}
// Now add project symbols, overwriting platform symbols with the same label. // Now add project symbols, overwriting platform symbols with the same label.
foreach (KeyValuePair<string, DefSymbol> kvp in ProjectProps.ProjectSyms) { foreach (KeyValuePair<string, DefSymbol> kvp in ProjectProps.ProjectSyms) {

View File

@ -28,6 +28,8 @@ namespace SourceGen {
/// </summary> /// </summary>
public class PlatformSymbols : IEnumerable<Symbol> { public class PlatformSymbols : IEnumerable<Symbol> {
public const string FILENAME_EXT = ".sym65"; public const string FILENAME_EXT = ".sym65";
private const string ERASE_VALUE_STR = "ERASE";
public const int ERASE_VALUE = -1;
public static readonly string FILENAME_FILTER = Res.Strings.FILE_FILTER_SYM65; public static readonly string FILENAME_FILTER = Res.Strings.FILE_FILTER_SYM65;
/// <summary> /// <summary>
@ -165,20 +167,28 @@ namespace SourceGen {
} else if (typeAndDir == '>') { } else if (typeAndDir == '>') {
direction = DefSymbol.DirectionFlags.Write; direction = DefSymbol.DirectionFlags.Write;
} }
string badParseMsg; string badParseMsg;
int value, numBase; int value, numBase;
bool parseOk; bool parseOk;
string valueStr = matches[0].Groups[GROUP_VALUE].Value;
if (isConst) { if (isConst) {
// Allow various numeric options, and preserve the value. // Allow various numeric options, and preserve the value.
parseOk = Asm65.Number.TryParseInt(matches[0].Groups[GROUP_VALUE].Value, parseOk = Asm65.Number.TryParseInt(valueStr, out value, out numBase);
out value, out numBase);
badParseMsg = badParseMsg =
CommonUtil.Properties.Resources.ERR_INVALID_NUMERIC_CONSTANT; CommonUtil.Properties.Resources.ERR_INVALID_NUMERIC_CONSTANT;
} else if (valueStr.ToUpperInvariant().Equals(ERASE_VALUE_STR)) {
parseOk = true;
value = ERASE_VALUE;
numBase = 10;
badParseMsg = CommonUtil.Properties.Resources.ERR_INVALID_ADDRESS;
} else { } else {
// Allow things like "05/1000". Always hex. // Allow things like "05/1000". Always hex.
numBase = 16; numBase = 16;
parseOk = Asm65.Address.ParseAddress(matches[0].Groups[GROUP_VALUE].Value, parseOk = Asm65.Address.ParseAddress(valueStr, (1 << 24) - 1,
(1 << 24) - 1, out value); out value);
// limit to positive 24-bit values
parseOk &= (value >= 0 && value < 0x01000000);
badParseMsg = CommonUtil.Properties.Resources.ERR_INVALID_ADDRESS; badParseMsg = CommonUtil.Properties.Resources.ERR_INVALID_ADDRESS;
} }

View File

@ -0,0 +1,45 @@
; Copyright 2019 faddenSoft. All Rights Reserved.
; See the LICENSE.txt file for distribution terms (Apache 2.0).
;
; Sometimes code uses the ROM entry points but redefines the zero-page
; addresses for its own purposes. Having the MON_* symbols is distracting.
; This erases them from the symbol table.
;
; To use: include this file, and ensure it comes after F8-ROM.sym65 in
; the platform symbol file list.
;
*SYNOPSIS Remove monitor ROM zero-page symbols
MON_WNDLEFT @ erase
MON_WNDWDTH @ erase
MON_WNDTOP @ erase
MON_WNDBTM @ erase
MON_CH @ erase
MON_CV @ erase
MON_GBASL @ erase
MON_GBASH @ erase
MON_H2 @ erase
MON_V2 @ erase
MON_COLOR @ erase
MON_INVFLAG @ erase
MON_PROMPT @ erase
MON_CSWL @ erase
MON_CSWH @ erase
MON_KSWL @ erase
MON_KSWH @ erase
MON_PCL @ erase
MON_PCH @ erase
MON_A1L @ erase
MON_A1H @ erase
MON_A2L @ erase
MON_A2H @ erase
MON_A3L @ erase
MON_A3H @ erase
MON_A4L @ erase
MON_A4H @ erase
MON_A5L @ erase
MON_A5H @ erase
MON_RNDL @ erase
MON_RNDH @ erase

View File

@ -71,7 +71,8 @@ written.</p>
<p>The VALUE is a number in decimal, hexadecimal (with a leading '$'), or <p>The VALUE is a number in decimal, hexadecimal (with a leading '$'), or
binary (with a leading '%'). The numeric base will be recorded and used when binary (with a leading '%'). The numeric base will be recorded and used when
formatting the symbol in generated output, so use whichever form is most formatting the symbol in generated output, so use whichever form is most
appropriate. Values are unsigned 24-bit numbers.</p> appropriate. Values are unsigned 24-bit numbers. The special value
"erase" may be used to erase a symbol defined in an earlier platform file.</p>
<p>The WIDTH is optional, and ignored for constants. It must be a <p>The WIDTH is optional, and ignored for constants. It must be a
decimal or hexadecimal value between 1 and 65536, inclusive. If omitted, decimal or hexadecimal value between 1 and 65536, inclusive. If omitted,