1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-11-29 10:50:28 +00:00

Show large adjustments in hex

We emit address adjustments like "LDA thing+1", which are usually
small values.  Sometimes they're large, e.g. "LDA thing-61440",
which is harder to understand than "LDA thing-$F000".  So now we
show small adjustments in decimal, and large adjustments in hex.

The current definition of "small" is abs(adjust) < 256.
This commit is contained in:
Andy McFadden 2020-01-02 13:09:18 -08:00
parent 6c27b032bc
commit 5548469ba1
8 changed files with 47 additions and 38 deletions

View File

@ -639,18 +639,27 @@ namespace Asm65 {
}
/// <summary>
/// Formats an adjustment, as "+decimal" or "-decimal". If no adjustment
/// is required, an empty string is returned.
/// Formats an adjustment. Small values are formatted as "+decimal" or "-decimal",
/// larger values are formatted as hex. If no adjustment is required, an empty string
/// is returned.
/// </summary>
/// <param name="adjValue">Adjustment value.</param>
/// <returns>Formatted string.</returns>
public string FormatAdjustment(int adjValue) {
if (adjValue == 0) {
return string.Empty;
} else if (Math.Abs(adjValue) >= 256) {
// not using mHexPrefix here, since dec vs. hex matters
if (adjValue < 0) {
return "-$" + (-adjValue).ToString(mHexValueFormats[0]);
} else {
return "+$" + adjValue.ToString(mHexValueFormats[0]);
}
} else {
// This formats in decimal with a leading '+' or '-'. To avoid adding a plus
// on zero, we'd use "+#;-#;0", but we took care of the zero case above.
return adjValue.ToString("+0;-#");
}
// This formats in decimal with a leading '+' or '-'. To avoid adding a plus
// on zero, we'd use "+#;-#;0", but we took care of the zero case above.
return adjValue.ToString("+0;-#");
}
/// <summary>

View File

@ -65,12 +65,12 @@ start clc
lda #zip+64
lda #absl
lda #(absl >> 8)
lda #absl-4096
lda #absl-$1000
lda #(absl >> 8)-16
lda #(absl >> 16)
lda #absh
lda #(absh >> 8)
lda #absh-61440
lda #absh-$f000
lda #(absh >> 8)+16
lda #(absh >> 16)+1
lda #(start & $ffff)
@ -90,11 +90,11 @@ start clc
.word zip
.word absl
.word 0+(absl >> 8)
.word absl-4096
.word absl-$1000
.word 0+(absl >> 8)-16
.word absh
.word 0+(absh >> 8)
.word absh-61440
.word absh-$f000
.word 0+(absh >> 8)+16
.word 0+(start & $ffff)
.word 0+(start >> 8)

View File

@ -19,11 +19,11 @@ start clc
lda #<absh
lda #>absh
lda #<absh+64
lda #>absh+256
lda #>absh+$100
lda #<absl
lda #>absl
lda #<absl-64
lda #>absl-256
lda #>absl-$100
lda #<start
lda #>start
lda #^start
@ -59,14 +59,14 @@ start clc
lda #zip+64
lda #absl
lda #>absl
lda #absl-4096
lda #>absl-4096
lda #absl-$1000
lda #>absl-$1000
lda #^absl
lda #absh
lda #>absh
lda #absh+4096
lda #>absh+4096
lda #^absh+65536
lda #absh+$1000
lda #>absh+$1000
lda #^absh+$10000
lda #start
lda #>start
lda #^start
@ -84,12 +84,12 @@ start clc
dw zip
dw absl
dw >absl
dw absl-4096
dw >absl-4096
dw absl-$1000
dw >absl-$1000
dw absh
dw >absh
dw absh+4096
dw >absh+4096
dw absh+$1000
dw >absh+$1000
dw start
dw >start
dw ^start
@ -110,9 +110,9 @@ start clc
adrl >start
adrl ^start
:skipdata lda #^biggie-65536
mvn #^biggie,#^biggie-1114112
mvp #^start,#^start+1114112
:skipdata lda #^biggie-$10000
mvn #^biggie,#^biggie-$110000
mvp #^start,#^start+$110000
mvn #18,#1
mvp #%00000001,#%00010010
per :skipdata
@ -189,12 +189,12 @@ start clc
asc 'he quick brown fox jumps over the lazy dogs.'
:L118E lda #<thirty2+2
lda #>thirty2+768
lda #>thirty2+$300
lda #^thirty2
rep #$30
mx %00
lda #thirty2+3
lda #>thirty2+1024
lda #>thirty2+$400
lda #^thirty2
rts

View File

@ -64,12 +64,12 @@ start: clc
lda #zip+64
lda #absl
lda #absl >> 8
lda #absl-4096
lda #absl-$1000
lda #absl >> 8 -16
lda #absl >> 16
lda #absh
lda #absh >> 8
lda #absh-61440
lda #absh-$f000
lda #absh >> 8 +16
lda #absh >> 16 +1
lda #start & $ffff
@ -89,11 +89,11 @@ start: clc
.word zip
.word absl
.word absl >> 8
.word absl-4096
.word absl-$1000
.word absl >> 8 -16
.word absh
.word absh >> 8
.word absh-61440
.word absh-$f000
.word absh >> 8 +16
.word start & $ffff
.word start >> 8

View File

@ -36,8 +36,8 @@ L1000 lda CodeWrap+255
ldx L1000
ldy L1000+1
lda _L1148
lda CodeWrap+585
lda CodeWrap+592
lda CodeWrap+$249
lda CodeWrap+$250
nop
lda $1ffe
lda SameName1-1

View File

@ -35,8 +35,8 @@ L1000 lda CodeWrap+255
ldx L1000
ldy L1000+1
lda :L1148
lda CodeWrap+585
lda CodeWrap+592
lda CodeWrap+$249
lda CodeWrap+$250
nop
lda $1ffe
lda SameName1-1
@ -112,7 +112,7 @@ L1000 lda CodeWrap+255
lda $4000
lda $4001
lda BankWrap+8
lda <BankWrap-65512
lda <BankWrap-$ffe8
nop
lda ReadOnly
lda ReadOnly+1

View File

@ -36,8 +36,8 @@ L1000 lda CodeWrap+255
ldx L1000
ldy L1000+1
lda @L1148
lda CodeWrap+585
lda CodeWrap+592
lda CodeWrap+$249
lda CodeWrap+$250
nop
lda $1ffe
lda SameName1-1

View File

@ -37,8 +37,8 @@ L1000: lda CodeWrap+255
ldx L1000
ldy L1000+1
lda L1148
lda CodeWrap+585
lda CodeWrap+592
lda CodeWrap+$249
lda CodeWrap+$250
nop
lda $1ffe
lda SameName1-1