mirror of
https://github.com/fadden/6502bench.git
synced 2026-04-27 03:17:45 +00:00
Treat PEA operand as imm const16
We were treating PEA's operand as an absolute address and attempting to extend it to 24 bits. This wasn't very successful, and was counter-productive when the argument was actually a constant, which is common. Worse, if the operand appeared to reference an internal address outside bank 0, we would output a 24-bit value, breaking 64tass and cc65. We now treat PEA as having an immediate operand. (It was already classified as an "extended immediate", but the operand-address computation was still happening.) This will have little to no effect on projects that use OMF relocation data, because PEA arguments are explicitly identified as symbols or constants. New tests were added to 20032-labels-and-symbols to exercise the code generation failures. A few other tests that used PEA were affected. 20152-local-variables was fixed by adding a symbolic reference, the others remained as-is and the expected output was revised. (issue #172)
This commit is contained in:
1 parent
859a22fe60
commit
4846a26c9a
20 files changed
+293
-101
No files matched your search
+1
-1
@@ -81,7 +81,7 @@ namespace Asm65 {
|
||||
Implied, // OP 1
|
||||
PCRel, // OP label 2 (BCC, BNE, ...)
|
||||
PCRelLong, // OP label 3 (BRL)
|
||||
StackAbs, // OP addr 3 (PEA)
|
||||
StackAbs, // OP addr 3 (PEA), treat as imm const16
|
||||
StackDPInd, // OP (dp) 2 (PEI)
|
||||
StackInt, // OP 2 (BRK, COP)
|
||||
StackPCRelLong, // OP label 3 (PER)
|
||||
|
||||
@@ -962,7 +962,7 @@ namespace SourceGen {
|
||||
// Merge the PBR even if we eventually want the DBR; less to fix later.
|
||||
mAnattribs[offset].OperandAddress = operand | bank;
|
||||
break;
|
||||
case OpDef.AddressMode.StackAbs: // assume PBR
|
||||
//case OpDef.AddressMode.StackAbs: // treat as imm; else assume PBR
|
||||
case OpDef.AddressMode.AbsIndexXInd: // JMP (addr,X); uses program bank
|
||||
mAnattribs[offset].OperandAddress = operand | bank;
|
||||
break;
|
||||
|
||||
@@ -570,6 +570,7 @@ namespace SourceGen {
|
||||
} else if (op == OpDef.OpPEA_StackAbs || op == OpDef.OpPER_StackPCRelLong) {
|
||||
// They might be pushing address-1 to set up an RTS. If the target address isn't
|
||||
// an instruction start, check to see if the following byte is.
|
||||
// (We now treat PEA as immediate, so we won't be here for that.)
|
||||
if (!mAnattribs[targetOffset].IsInstructionStart &&
|
||||
targetOffset + 1 < mAnattribs.Length &&
|
||||
mAnattribs[targetOffset + 1].IsInstructionStart) {
|
||||
|
||||
Binary file not shown.
@@ -1,8 +1,8 @@
|
||||
### 6502bench SourceGen dis65 v1.0 ###
|
||||
{
|
||||
"_ContentVersion":6,
|
||||
"FileDataLength":729,
|
||||
"FileDataCrc32":-1745845873,
|
||||
"FileDataLength":761,
|
||||
"FileDataCrc32":1509582706,
|
||||
"ProjectProps":{
|
||||
"CpuName":"65816",
|
||||
"IncludeUndocumentedInstr":false,
|
||||
@@ -146,6 +146,15 @@
|
||||
"PreLabel":"",
|
||||
"DisallowInward":false,
|
||||
"DisallowOutward":false,
|
||||
"IsRelative":false},
|
||||
|
||||
{
|
||||
"Offset":732,
|
||||
"Addr":135168,
|
||||
"Length":-1024,
|
||||
"PreLabel":"",
|
||||
"DisallowInward":false,
|
||||
"DisallowOutward":false,
|
||||
"IsRelative":false}],
|
||||
"TypeHints":[{
|
||||
"Low":0,
|
||||
@@ -252,6 +261,13 @@
|
||||
"Value":4538,
|
||||
"Source":"User",
|
||||
"Type":"GlobalAddr",
|
||||
"LabelAnno":"None"},
|
||||
|
||||
"733":{
|
||||
"Label":"ptest",
|
||||
"Value":135169,
|
||||
"Source":"User",
|
||||
"Type":"GlobalAddr",
|
||||
"LabelAnno":"None"}},
|
||||
|
||||
"OperandFormats":{
|
||||
@@ -1514,6 +1530,57 @@
|
||||
"Label":"after",
|
||||
"Part":"Low"},
|
||||
|
||||
"Extra":null},
|
||||
|
||||
"736":{
|
||||
"Length":3,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"739":{
|
||||
"Length":3,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Symbol",
|
||||
"SymbolRef":{
|
||||
"Label":"ptest",
|
||||
"Part":"Low"},
|
||||
|
||||
"Extra":null},
|
||||
|
||||
"748":{
|
||||
"Length":3,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"751":{
|
||||
"Length":3,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"754":{
|
||||
"Length":3,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Symbol",
|
||||
"SymbolRef":{
|
||||
"Label":"biggie",
|
||||
"Part":"Low"},
|
||||
|
||||
"Extra":null},
|
||||
|
||||
"757":{
|
||||
"Length":3,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Symbol",
|
||||
"SymbolRef":{
|
||||
"Label":"biggie",
|
||||
"Part":"Bank"},
|
||||
|
||||
"Extra":null}},
|
||||
|
||||
"LvTables":{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
### 6502bench SourceGen dis65 v1.0 ###
|
||||
{
|
||||
"_ContentVersion":4,
|
||||
"_ContentVersion":6,
|
||||
"FileDataLength":237,
|
||||
"FileDataCrc32":1833028653,
|
||||
"ProjectProps":{
|
||||
@@ -26,7 +26,8 @@
|
||||
"Length":1,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Decimal",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"",
|
||||
"HasWidth":false,
|
||||
@@ -43,7 +44,8 @@
|
||||
"Length":1,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"project const",
|
||||
"HasWidth":false,
|
||||
@@ -60,7 +62,8 @@
|
||||
"Length":1,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"project const",
|
||||
"HasWidth":false,
|
||||
@@ -77,7 +80,8 @@
|
||||
"Length":1,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"project addr",
|
||||
"HasWidth":false,
|
||||
@@ -94,7 +98,8 @@
|
||||
"Length":1,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"project addr",
|
||||
"HasWidth":false,
|
||||
@@ -111,7 +116,8 @@
|
||||
"Length":1,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"project addr, should clash",
|
||||
"HasWidth":false,
|
||||
@@ -125,11 +131,21 @@
|
||||
|
||||
"AddressMap":[{
|
||||
"Offset":0,
|
||||
"Addr":4096},
|
||||
"Addr":4096,
|
||||
"Length":-1024,
|
||||
"PreLabel":"",
|
||||
"DisallowInward":false,
|
||||
"DisallowOutward":false,
|
||||
"IsRelative":false},
|
||||
|
||||
{
|
||||
"Offset":126,
|
||||
"Addr":128}],
|
||||
"Addr":128,
|
||||
"Length":-1024,
|
||||
"PreLabel":"",
|
||||
"DisallowInward":false,
|
||||
"DisallowOutward":false,
|
||||
"IsRelative":false}],
|
||||
"TypeHints":[{
|
||||
"Low":0,
|
||||
"High":0,
|
||||
@@ -143,12 +159,14 @@
|
||||
"LongComments":{
|
||||
"-2147483647":{
|
||||
"Text":"Edited to have duplicate labels (PROJ_ZERO, DPCODE).",
|
||||
"IsFancy":false,
|
||||
"BoxMode":false,
|
||||
"MaxWidth":80,
|
||||
"BackgroundColor":0},
|
||||
|
||||
"81":{
|
||||
"Text":"Test name redefinition. This is mostly of interest for assemblers without redefinable variables, but also of interest to the cross-reference window.",
|
||||
"IsFancy":false,
|
||||
"BoxMode":false,
|
||||
"MaxWidth":80,
|
||||
"BackgroundColor":0}},
|
||||
@@ -206,31 +224,37 @@
|
||||
"SubFormat":"Symbol",
|
||||
"SymbolRef":{
|
||||
"Label":"CONST_ZERO",
|
||||
"Part":"Low"}},
|
||||
"Part":"Low"},
|
||||
|
||||
"Extra":null},
|
||||
|
||||
"24":{
|
||||
"Length":2,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Decimal",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"26":{
|
||||
"Length":2,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Decimal",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"136":{
|
||||
"Length":2,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Ascii",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"143":{
|
||||
"Length":2,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Ascii",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"155":{
|
||||
"Length":3,
|
||||
@@ -238,7 +262,19 @@
|
||||
"SubFormat":"Symbol",
|
||||
"SymbolRef":{
|
||||
"Label":"STRING",
|
||||
"Part":"Bank"}}},
|
||||
"Part":"Bank"},
|
||||
|
||||
"Extra":null},
|
||||
|
||||
"158":{
|
||||
"Length":3,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Symbol",
|
||||
"SymbolRef":{
|
||||
"Label":"STRING",
|
||||
"Part":"Low"},
|
||||
|
||||
"Extra":null}},
|
||||
|
||||
"LvTables":{
|
||||
"12":{
|
||||
@@ -247,7 +283,8 @@
|
||||
"Length":2,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"",
|
||||
"HasWidth":true,
|
||||
@@ -264,7 +301,8 @@
|
||||
"Length":1,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"",
|
||||
"HasWidth":true,
|
||||
@@ -281,7 +319,8 @@
|
||||
"Length":1,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"",
|
||||
"HasWidth":true,
|
||||
@@ -298,7 +337,8 @@
|
||||
"Length":1,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"",
|
||||
"HasWidth":true,
|
||||
@@ -317,7 +357,8 @@
|
||||
"Length":1,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"clash with project symbol",
|
||||
"HasWidth":true,
|
||||
@@ -334,7 +375,8 @@
|
||||
"Length":1,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"clash with user label",
|
||||
"HasWidth":true,
|
||||
@@ -361,7 +403,8 @@
|
||||
"Length":1,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"hidden table",
|
||||
"HasWidth":true,
|
||||
@@ -378,7 +421,8 @@
|
||||
"Length":1,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"hidden table",
|
||||
"HasWidth":true,
|
||||
@@ -397,7 +441,8 @@
|
||||
"Length":1,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"not hidden",
|
||||
"HasWidth":true,
|
||||
@@ -414,7 +459,8 @@
|
||||
"Length":1,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"not hidden",
|
||||
"HasWidth":true,
|
||||
@@ -433,7 +479,8 @@
|
||||
"Length":2,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"",
|
||||
"HasWidth":true,
|
||||
@@ -450,7 +497,8 @@
|
||||
"Length":4,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"",
|
||||
"HasWidth":true,
|
||||
@@ -469,7 +517,8 @@
|
||||
"Length":2,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"#1",
|
||||
"HasWidth":true,
|
||||
@@ -488,7 +537,8 @@
|
||||
"Length":2,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"#2",
|
||||
"HasWidth":true,
|
||||
@@ -507,7 +557,8 @@
|
||||
"Length":2,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"#3",
|
||||
"HasWidth":true,
|
||||
@@ -526,7 +577,8 @@
|
||||
"Length":2,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"",
|
||||
"HasWidth":true,
|
||||
@@ -545,7 +597,8 @@
|
||||
"Length":2,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"",
|
||||
"HasWidth":true,
|
||||
@@ -564,7 +617,8 @@
|
||||
"Length":4,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"",
|
||||
"HasWidth":true,
|
||||
@@ -583,7 +637,8 @@
|
||||
"Length":1,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"",
|
||||
"HasWidth":true,
|
||||
@@ -602,7 +657,8 @@
|
||||
"Length":1,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"",
|
||||
"HasWidth":true,
|
||||
@@ -619,7 +675,8 @@
|
||||
"Length":1,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"",
|
||||
"HasWidth":true,
|
||||
@@ -636,7 +693,8 @@
|
||||
"Length":1,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"",
|
||||
"HasWidth":true,
|
||||
@@ -653,7 +711,8 @@
|
||||
"Length":1,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"",
|
||||
"HasWidth":true,
|
||||
@@ -670,7 +729,8 @@
|
||||
"Length":1,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"",
|
||||
"HasWidth":true,
|
||||
@@ -687,7 +747,8 @@
|
||||
"Length":1,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"",
|
||||
"HasWidth":true,
|
||||
@@ -706,7 +767,8 @@
|
||||
"Length":4,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"",
|
||||
"HasWidth":true,
|
||||
@@ -725,7 +787,8 @@
|
||||
"Length":1,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"same as org",
|
||||
"HasWidth":true,
|
||||
@@ -744,7 +807,8 @@
|
||||
"Length":1,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"",
|
||||
"HasWidth":true,
|
||||
@@ -763,7 +827,8 @@
|
||||
"Length":1,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"",
|
||||
"HasWidth":true,
|
||||
@@ -786,7 +851,8 @@
|
||||
"Length":2,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"",
|
||||
"HasWidth":true,
|
||||
@@ -803,7 +869,8 @@
|
||||
"Length":4,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"",
|
||||
"HasWidth":true,
|
||||
@@ -820,7 +887,8 @@
|
||||
"Length":4,
|
||||
"Format":"NumericLE",
|
||||
"SubFormat":"Hex",
|
||||
"SymbolRef":null},
|
||||
"SymbolRef":null,
|
||||
"Extra":null},
|
||||
|
||||
"Comment":"",
|
||||
"HasWidth":true,
|
||||
|
||||
@@ -34,7 +34,7 @@ start clc
|
||||
lda #>start
|
||||
lda #`start
|
||||
pea $feed
|
||||
pea start & $ffff
|
||||
pea $2345
|
||||
pea $0001
|
||||
pea $3456
|
||||
pea $0012
|
||||
@@ -226,6 +226,20 @@ after ldx <after+8,y
|
||||
ldy <after+9,x
|
||||
pei (<after+10)
|
||||
nop
|
||||
jml _L21000
|
||||
|
||||
.here
|
||||
.logical $021000
|
||||
_L21000 nop
|
||||
ptest pea $1001
|
||||
pea $1001
|
||||
pea ptest & $ffff
|
||||
pea $3456
|
||||
pea $0012
|
||||
pea $3456
|
||||
pea $0012
|
||||
pea biggie & $ffff
|
||||
pea biggie >> 16
|
||||
rts
|
||||
|
||||
.here
|
||||
@@ -23,5 +23,6 @@
|
||||
!hex 656172206f6e20746865206669727374206c696e652e20205468652071756963
|
||||
!hex 6b2062726f776e20666f78206a756d7073206f76657220746865206c617a7920
|
||||
!hex 646f67732ea97aa959a934c230a97b56a95a34a93412eaad9f11a59fa5a0b2a1
|
||||
!hex b1a2b7a3a7a4b5a5a1a6b9a700a5c0b1c1b6c2b4c3d4c4ea60
|
||||
!hex b1a2b7a3a7a4b5a5a1a6b9a700a5c0b1c1b6c2b4c3d4c4ea5c001002eaf40110
|
||||
!hex f40110f40110f45634f41200f45634f41200f45634f4120060
|
||||
}
|
||||
@@ -32,7 +32,7 @@ start: clc
|
||||
lda #>start
|
||||
lda #^start
|
||||
pea $feed
|
||||
pea start & $ffff
|
||||
pea $2345
|
||||
pea $0001
|
||||
pea $3456
|
||||
pea $0012
|
||||
@@ -223,5 +223,18 @@ after: ldx <after+8,y
|
||||
ldy <after+9,x
|
||||
pei (<after+10)
|
||||
nop
|
||||
jml @L21000
|
||||
|
||||
.org $021000
|
||||
@L21000: nop
|
||||
ptest: pea $1001
|
||||
pea $1001
|
||||
pea ptest & $ffff
|
||||
pea $3456
|
||||
pea $0012
|
||||
pea $3456
|
||||
pea $0012
|
||||
pea biggie & $ffff
|
||||
pea biggie >> 16
|
||||
rts
|
||||
|
||||
@@ -29,7 +29,7 @@ start clc
|
||||
lda #>start
|
||||
lda #^start
|
||||
pea $feed
|
||||
pea start
|
||||
pea $2345
|
||||
pea $0001
|
||||
pea $3456
|
||||
pea $0012
|
||||
@@ -214,5 +214,18 @@ after ldx <after+8&$ff,y
|
||||
ldy <after+9&$ff,x
|
||||
dfb $d4,$c4
|
||||
nop
|
||||
jml :L21000
|
||||
|
||||
org $021000
|
||||
:L21000 nop
|
||||
ptest pea $1001
|
||||
pea $1001
|
||||
pea ptest
|
||||
pea $3456
|
||||
pea $0012
|
||||
pea $3456
|
||||
pea $0012
|
||||
pea biggie
|
||||
pea ^biggie
|
||||
rts
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
.xs
|
||||
nop
|
||||
L1001 bit L1001
|
||||
caddr pea caddr-1
|
||||
caddr pea $1003
|
||||
per caddr-1
|
||||
lda L1001+2
|
||||
lda caddr
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
!rs
|
||||
nop
|
||||
L1001 bit L1001
|
||||
caddr pea caddr-1
|
||||
caddr pea $1003
|
||||
per caddr-1
|
||||
lda L1001+2
|
||||
lda caddr
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
.i8
|
||||
nop
|
||||
L1001: bit L1001
|
||||
caddr: pea caddr-1
|
||||
caddr: pea $1003
|
||||
per caddr-1
|
||||
lda L1001+2
|
||||
lda caddr
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
org $1000
|
||||
nop
|
||||
L1001 bit L1001
|
||||
caddr pea caddr-1
|
||||
caddr pea $1003
|
||||
per caddr-1
|
||||
lda L1001+2
|
||||
lda caddr
|
||||
|
||||
@@ -273,7 +273,7 @@ L11FC cmp @wL0086,x
|
||||
_L122A sbc (L0080),y
|
||||
sbc (L0080)
|
||||
sbc ($80,s),y
|
||||
pea L0086
|
||||
pea $0086
|
||||
sbc L0080,x
|
||||
inc L0080,x
|
||||
sbc [L0080],y
|
||||
|
||||
@@ -273,7 +273,7 @@ L11FC cmp+2 L0086,x
|
||||
@L122A sbc (L0080),y
|
||||
sbc (L0080)
|
||||
sbc ($80,S),y
|
||||
pea L0086
|
||||
pea $0086
|
||||
sbc+1 L0080,x
|
||||
inc+1 L0080,x
|
||||
sbc [L0080],y
|
||||
|
||||
@@ -273,7 +273,7 @@ L11FC: cmp a:L0086,x
|
||||
@L122A: sbc (L0080),y
|
||||
sbc (L0080)
|
||||
sbc ($80,S),y
|
||||
pea L0086
|
||||
pea $0086
|
||||
sbc z:L0080,x
|
||||
inc z:L0080,x
|
||||
sbc [L0080],y
|
||||
|
||||
@@ -270,7 +270,7 @@ L11FC cmp: L0086,x
|
||||
:L122A sbc (L0080),y
|
||||
dfb $f2,$80
|
||||
sbc ($80,S),y
|
||||
pea L0086
|
||||
pea $0086
|
||||
sbc L0080,x
|
||||
inc L0080,x
|
||||
sbc [L0080],y
|
||||
|
||||
@@ -248,8 +248,22 @@ before nop
|
||||
ldx <after+2&$ff,y
|
||||
ldy <after+3&$ff,x
|
||||
dfb $d4,$c4 ;pei (<zip+4&$ff)
|
||||
|
||||
after nop
|
||||
jml checkpea
|
||||
|
||||
; Dig into PEA, using both internal and external addresses. We want to do
|
||||
; this outside bank 0 to see if the bank byte creeps in.
|
||||
org $021000
|
||||
checkpea nop
|
||||
ptest pea ptest ;don't format
|
||||
pea ptest ;explicitly format as hex
|
||||
pea ptest ;format as symbol
|
||||
|
||||
pea biggie ;don't format
|
||||
pea ^biggie
|
||||
pea biggie ;explicitly format as hex
|
||||
pea ^biggie
|
||||
pea biggie ;format as symbol (low+bank)
|
||||
pea ^biggie
|
||||
|
||||
rts
|
||||
|
||||
+37
-36
@@ -416,18 +416,19 @@ rsrcmsg pea rsrcmsg2|-16
|
||||
sta pArcRead+$06
|
||||
</pre>
|
||||
<p>In both cases we're referencing a 24-bit address as two 16-bit values.
|
||||
Without context, the disassembler will treat the PEA instruction as two
|
||||
independent 16-bit addresses, and the immediate values as constants:</p>
|
||||
Without context, the disassembler will treat the PEA instruction operands
|
||||
and the immediate values as constants:</p>
|
||||
<pre>
|
||||
.dbank $02
|
||||
02/317c: f4 02 00 L2317C pea L20002 & $ffff
|
||||
02/317f: f4 54 32 pea L23254 & $ffff
|
||||
02/3182: a2 0c 20 ldx #WriteCString
|
||||
02/3185: 22 00 00 e1 jsl Toolbox
|
||||
02/3189: a9 00 00 L23189 lda #$0000
|
||||
02/318c: 8d 78 3f sta L23F78 & $ffff
|
||||
02/318f: a9 03 00 lda #$0003
|
||||
02/3192: 8d 7a 3f sta L23F78 & $ffff +2
|
||||
02/327c: f4 02 00 L2327C pea $0002
|
||||
02/327f: f4 54 33 pea $3354
|
||||
02/3282: a2 0c 20 ldx #WriteCString
|
||||
02/3285: 22 00 00 e1 jsl Toolbox
|
||||
02/3289: a9 00 01 L23289 lda #$0100
|
||||
02/328c: 8d 78 40 sta L24078 & $ffff
|
||||
02/328f: a9 03 00 lda #$0003
|
||||
02/3292: 8d 7a 40 sta L24078 & $ffff +2
|
||||
|
||||
</pre>
|
||||
<p>Worse yet, those <code>STA</code> instruction operands would have been
|
||||
shown as hex values or incorrect labels if the DBR had been set incorrectly.
|
||||
@@ -436,20 +437,20 @@ address from which the addresses were formed, and we can tell when
|
||||
immediate values are addresses rather than constants. And we can do this
|
||||
even without setting the DBR.</p>
|
||||
<pre>
|
||||
02/317c: f4 02 00 L2317C pea L23254 >> 16
|
||||
02/317f: f4 54 32 pea L23254 & $ffff
|
||||
02/3182: a2 0c 20 ldx #WriteCString
|
||||
02/3185: 22 00 00 e1 jsl Toolbox
|
||||
02/3189: a9 00 00 L23189 lda #L30000 & $ffff
|
||||
02/318c: 8d 78 3f sta L23F78 & $ffff
|
||||
02/318f: a9 03 00 lda #L30000 >> 16
|
||||
02/3192: 8d 7a 3f sta L23F78 & $ffff +2
|
||||
02/327c: f4 02 00 L2327C pea L23354 >> 16
|
||||
02/327f: f4 54 33 pea L23354 & $ffff
|
||||
02/3282: a2 0c 20 ldx #WriteCString
|
||||
02/3285: 22 00 00 e1 jsl Toolbox
|
||||
02/3289: a9 00 01 L23289 lda #L30100 & $ffff
|
||||
02/328c: 8d 78 40 sta L24078 & $ffff
|
||||
02/328f: a9 03 00 lda #L30100 >> 16
|
||||
02/3292: 8d 7a 40 sta L24078 & $ffff +2
|
||||
</pre>
|
||||
<p>The absence of relocation data can be a useful signal as well. For
|
||||
example, when pushing arguments for a toolbox call, the disassembler
|
||||
can tell the difference between addresses and constants without needing
|
||||
emulation or pattern-matching, because only the addresses get
|
||||
relocated. Consider this bit of source code:</p>
|
||||
relocated. Another example:</p>
|
||||
<pre>
|
||||
lda <total_records
|
||||
pha
|
||||
@@ -461,25 +462,25 @@ relocated. Consider this bit of source code:</p>
|
||||
</pre>
|
||||
<p>Without relocation data, it becomes:</p>
|
||||
<pre>
|
||||
02/0aa8: a5 42 lda $42
|
||||
02/0aaa: 48 pha
|
||||
02/0aab: f4 02 00 pea L20002 & $ffff
|
||||
02/0aae: f4 03 31 pea L23103 & $ffff
|
||||
02/0ab1: f4 05 00 pea L20005 & $ffff
|
||||
02/0ab4: f4 00 00 pea L20000 & $ffff
|
||||
02/0ab7: a2 0b 26 ldx #Int2Dec
|
||||
02/0aba: 22 00 00 e1 jsl Toolbox
|
||||
02/0ba8: a5 42 lda $42
|
||||
02/0baa: 48 pha
|
||||
02/0bab: f4 02 00 pea $0002
|
||||
02/0bae: f4 03 32 pea $3203
|
||||
02/0bb1: f4 05 00 pea $0005
|
||||
02/0bb4: f4 00 00 pea $0000
|
||||
02/0bb7: a2 0b 26 ldx #Int2Dec
|
||||
02/0bba: 22 00 00 e1 jsl Toolbox
|
||||
</pre>
|
||||
<p>If we treat the non-relocated operands as constants:</p>
|
||||
<p>With reloc, we update the pointer but not the constants:</p>
|
||||
<pre>
|
||||
02/0aa8: a5 42 lda $42
|
||||
02/0aaa: 48 pha
|
||||
02/0aab: f4 02 00 pea L230C2 >> 16
|
||||
02/0aae: f4 03 31 pea L23103 & $ffff
|
||||
02/0ab1: f4 05 00 pea $0005
|
||||
02/0ab4: f4 00 00 pea $0000
|
||||
02/0ab7: a2 0b 26 ldx #Int2Dec
|
||||
02/0aba: 22 00 00 e1 jsl Toolbox
|
||||
02/0ba8: a5 42 lda $42
|
||||
02/0baa: 48 pha
|
||||
02/0bab: f4 02 00 pea L231C2 >> 16
|
||||
02/0bae: f4 03 32 pea L23203 & $ffff
|
||||
02/0bb1: f4 05 00 pea $0005
|
||||
02/0bb4: f4 00 00 pea $0000
|
||||
02/0bb7: a2 0b 26 ldx #Int2Dec
|
||||
02/0bba: 22 00 00 e1 jsl Toolbox
|
||||
</pre>
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user