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:
parent
716dce5f28
commit
f31b7f5822
@ -235,7 +235,10 @@ namespace SourceGen {
|
|||||||
Debug.Assert(((int)direction & ~(int)DirectionFlags.ReadWrite) == 0);
|
Debug.Assert(((int)direction & ~(int)DirectionFlags.ReadWrite) == 0);
|
||||||
Direction = direction;
|
Direction = direction;
|
||||||
|
|
||||||
|
// constants don't have masks
|
||||||
|
if (type != Type.Constant) {
|
||||||
MultiMask = multiMask;
|
MultiMask = multiMask;
|
||||||
|
}
|
||||||
|
|
||||||
Tag = tag;
|
Tag = tag;
|
||||||
}
|
}
|
||||||
|
@ -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 need to ensure that all possible values fit within the mask.
|
||||||
// We don't test AddressValue here, because it's okay for the
|
// We don't test AddressValue here, because it's okay for the
|
||||||
// canonical value to be outside the masked range.
|
// canonical value to be outside the masked range.
|
||||||
|
@ -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
|
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
|
matches, another set of bits is examined to determine which register or
|
||||||
RAM address is being accessed.</p>
|
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
|
<p>The mask set is best explained with an example. Suppose the address
|
||||||
<code>???0 ??1? 1??x xxxx</code> (where '?' can be any value, 0/1 must
|
pattern for a set of registers is <code>???0 ??1? 1??x xxxx</code>
|
||||||
be that value, and 'x' means the bit is used to determine the register).
|
(where '?' can be any value, 0/1 must be that value, and 'x' means the bit
|
||||||
So any value between $0280-029f matches, as does $23c0-23df, but
|
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>
|
$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,
|
<p>The corresponding MULTI_MASK line, with values specifed in binary,
|
||||||
would be:</p>
|
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 & AddressMask)</code>.</p>
|
extract the register number with <code>(address & AddressMask)</code>.</p>
|
||||||
|
|
||||||
<p>We don't want to have a huge collection of equates at the top of the
|
<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
|
generated source file, so whatever value is used in the symbol declaration
|
||||||
the "canonical" value. All other matching values are expressed as an
|
is considered the "canonical" value. All other matching values are output
|
||||||
offset.</p>
|
with an offset.</p>
|
||||||
<p>All values must fall between 0 and $00FFFFFF. The set bits in
|
<p>All mask values must fall between 0 and $00FFFFFF. The set bits in
|
||||||
CompareMask and AddressMask must not overlap, and CompareValue must not
|
CompareMask and AddressMask must not overlap, and CompareValue must not
|
||||||
have any bits set that aren't also set in CompareMask.</p>
|
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>
|
<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>,
|
(the file that ends with ".dis65") lives. Add a <code>*SYNOPSIS</code>,
|
||||||
then add the desired symbols.</p>
|
then add the desired symbols.</p>
|
||||||
<p>Finally, add it to your project. Select Edit > Project Properties,
|
<p>Finally, add it to your project. Select Edit > Project Properties,
|
||||||
switch to the Symbol Files tab, click Add Symbol Files, and select your
|
switch to the Symbol Files tab, click Add Symbol Files from Project, and
|
||||||
symbol file. It should appear in the list with a "PROJ:" prefix.</p>
|
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
|
<p>If an example helps, the A2-Amper-fdraw project in the Examples
|
||||||
directory has a project-local symbol file, called "fdraw-exports".
|
directory has a project-local symbol file, called "fdraw-exports".
|
||||||
(Amper-fdraw provides an Applesoft BASIC interface to the machine-language
|
(fdraw-exports is a list of exported symbols from the fdraw library,
|
||||||
fdraw library.)</p>
|
for which Amper-fdraw provides an Applesoft BASIC interface.)
|
||||||
|
|
||||||
<p>NOTE: in the current version of SourceGen, changes to .sym65 files are
|
<p>NOTE: in the current version of SourceGen, changes to .sym65 files are
|
||||||
not detected automatically. Closing and re-opening the project
|
not detected automatically. Closing and re-opening the project
|
||||||
|
@ -61,10 +61,12 @@ something that people actually want.</p>
|
|||||||
<h2><a name="fundamental-concepts">Fundamental Concepts</a></h2>
|
<h2><a name="fundamental-concepts">Fundamental Concepts</a></h2>
|
||||||
|
|
||||||
<p>The next few sections present some general concepts and terminology. The
|
<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
|
rest of the documentation assumes you've read and understood this.</p>
|
||||||
be helpful if you already understand something about the 6502 instruction
|
<p>It will be helpful if you already understand something about the 6502
|
||||||
set and assembly-language programming, but disassembling other programs is
|
instruction set and assembly-language programming, but disassembling
|
||||||
actually a pretty good way to learn how to code in assembly.</p>
|
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>
|
<h2><a name="begin">About 6502 Code</a></h2>
|
||||||
|
|
||||||
|
@ -82,6 +82,9 @@ MultiWrite > $c005 3 ;$c005/6/7, write-only
|
|||||||
; Test: read C003 C004 C005 C006 C007
|
; Test: read C003 C004 C005 C006 C007
|
||||||
; Test: write C004 C005 C006 C007 C008
|
; 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
|
; Invalid values. These cause a warning at load time, and the symbol will
|
||||||
|
Loading…
Reference in New Issue
Block a user