1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-12-01 22:50:35 +00:00

Fix constants declared with MULTI_MASK

The masks should only be applied to address symbols.  We were
rejecting constants that didn't match the pattern.
This commit is contained in:
Andy McFadden 2019-10-18 16:19:42 -07:00
parent 716dce5f28
commit f31b7f5822
5 changed files with 44 additions and 19 deletions

View File

@ -235,7 +235,10 @@ namespace SourceGen {
Debug.Assert(((int)direction & ~(int)DirectionFlags.ReadWrite) == 0);
Direction = direction;
// constants don't have masks
if (type != Type.Constant) {
MultiMask = multiMask;
}
Tag = tag;
}

View File

@ -198,7 +198,7 @@ namespace SourceGen {
}
}
if (parseOk && multiMask != null) {
if (parseOk && multiMask != null && !isConst) {
// We need to ensure that all possible values fit within the mask.
// We don't test AddressValue here, because it's okay for the
// canonical value to be outside the masked range.

View File

@ -87,11 +87,16 @@ RAM, ROM, and I/O registers appear at multiple addresses. The hardware
looks for certain address lines to be set or clear, and if the pattern
matches, another set of bits is examined to determine which register or
RAM address is being accessed.</p>
<p>This is expressed in symbol files with the MULTI_MASK statement.
Address symbol declarations that follow have the mask set applied. Symbols
whose addresses don't fit the pattern cause a warning and will be
ignored. Constants are not affected.</p>
<p>For example, suppose the access pattern for a set of registers is
<code>???0 ??1? 1??x xxxx</code> (where '?' can be any value, 0/1 must
be that value, and 'x' means the bit is used to determine the register).
So any value between $0280-029f matches, as does $23c0-23df, but
<p>The mask set is best explained with an example. Suppose the address
pattern for a set of registers is <code>???0 ??1? 1??x xxxx</code>
(where '?' can be any value, 0/1 must be that value, and 'x' means the bit
is used to determine the register).
So any address between $0280-029F matches, as does $23C0-23DF, but
$0480 and $1280 don't. The register number is found in the low five bits.</p>
<p>The corresponding MULTI_MASK line, with values specifed in binary,
would be:</p>
@ -102,12 +107,23 @@ determine if an address is in the register set, we check to see if
extract the register number with <code>(address &amp; AddressMask)</code>.</p>
<p>We don't want to have a huge collection of equates at the top of the
file, so whatever value is used in the symbol declaration is considered
the "canonical" value. All other matching values are expressed as an
offset.</p>
<p>All values must fall between 0 and $00FFFFFF. The set bits in
generated source file, so whatever value is used in the symbol declaration
is considered the "canonical" value. All other matching values are output
with an offset.</p>
<p>All mask values must fall between 0 and $00FFFFFF. The set bits in
CompareMask and AddressMask must not overlap, and CompareValue must not
have any bits set that aren't also set in CompareMask.</p>
<p>If an address can be mapped to a masked value and an unmasked value,
the unmasked value takes precedence for exact matches. In the example
above, if you declare <code>REG1 @ $0281</code> outside the MULTI_MASK
declaration, the disassembler will use <code>REG1</code> for all operands
that reference $0281. If other code accesses the same register as $23C1,
the symbol established for the masked value will be used instead.</p>
<p>If there are multiple masked values for a given address, the precedence
is undefined.</p>
<p>To disable the MULTI_MASK and resume normal declarations, write the
tag without arguments:
<pre> *MULTI_MASK</pre></p>
<h3>Creating a Project-Specific Symbol File</h3>
@ -119,13 +135,14 @@ Make sure you create it in the same directory where your project file
(the file that ends with ".dis65") lives. Add a <code>*SYNOPSIS</code>,
then add the desired symbols.</p>
<p>Finally, add it to your project. Select Edit &gt; Project Properties,
switch to the Symbol Files tab, click Add Symbol Files, and select your
symbol file. It should appear in the list with a "PROJ:" prefix.</p>
switch to the Symbol Files tab, click Add Symbol Files from Project, and
select your symbol file. It should appear in the list with a
"PROJ:" prefix.</p>
<p>If an example helps, the A2-Amper-fdraw project in the Examples
directory has a project-local symbol file, called "fdraw-exports".
(Amper-fdraw provides an Applesoft BASIC interface to the machine-language
fdraw library.)</p>
(fdraw-exports is a list of exported symbols from the fdraw library,
for which Amper-fdraw provides an Applesoft BASIC interface.)
<p>NOTE: in the current version of SourceGen, changes to .sym65 files are
not detected automatically. Closing and re-opening the project

View File

@ -61,10 +61,12 @@ something that people actually want.</p>
<h2><a name="fundamental-concepts">Fundamental Concepts</a></h2>
<p>The next few sections present some general concepts and terminology. The
rest of the documentation assumes you've read and understood this. It will
be helpful if you already understand something about the 6502 instruction
set and assembly-language programming, but disassembling other programs is
actually a pretty good way to learn how to code in assembly.</p>
rest of the documentation assumes you've read and understood this.</p>
<p>It will be helpful if you already understand something about the 6502
instruction set and assembly-language programming, but disassembling
other programs is actually a pretty good way to learn how to code in
assembly. You will need to be familiar with hexadecimal numbers and
general programming concepts to make sense of anything, however.</p>
<h2><a name="begin">About 6502 Code</a></h2>

View File

@ -82,6 +82,9 @@ MultiWrite > $c005 3 ;$c005/6/7, write-only
; Test: read C003 C004 C005 C006 C007
; Test: write C004 C005 C006 C007 C008
; try a non-matching constant; should be accepted without complaint
MultiConst = $4567
;
; Invalid values. These cause a warning at load time, and the symbol will