Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAP to access UpperMemory only works partially #172

Closed
Pimau opened this issue Sep 29, 2024 · 1 comment
Closed

MAP to access UpperMemory only works partially #172

Pimau opened this issue Sep 29, 2024 · 1 comment
Labels
new New report, not classified yet

Comments

@Pimau
Copy link

Pimau commented Sep 29, 2024

Test Environment (required)

  • Platform: MEGA65r6
  • ROM Release: v920408
  • Core Commit: mega65r6-develo-build-128.7z / mega65r6-20240918.20-develo-d5735ea.cor

Describe the bug
MAP configs where we try to access Attic RAM with an offset which is below 800.0000 do not work. Tested this for MAPHI and MAPLO with different configs.

To Reproduce
Steps to reproduce the behavior:

  1. Execute the example code on page 14-39 "Using MAP to Access Upper Memory"

    • Offset = $7FF.6000
    • High byte = $7F
    • Standard special value = $0F
    • Bank = $F
    • MSB of 16-bit = $60
    • Nibble value for segment selection MAPHI = $2

    What you get is the following: the bytes itself are random and dependent on your system state; more interesting is what memory areas are different and which ones are mapping:

MAPH: 2F60
MAPL: 0000
MAPH high byte: 7F
MAPL high byte: 00
<dbg>mdump 8000000
 :8000000 CE A2 2D 2F FA B7 1A AD  20 AE A7 08 92 8C 27 CE  | ΢-/??.? ??...'?
<dbg>mdump 777a000
 :777A000 00 80 00 00 00 00 00 FF  08 00 FF FF FF FF FF FF  | .......?..??????
<dbg>mdump 7100000
 :7100000 00 80 00 00 00 00 00 FF  08 00 FF FF FF FF FF FF  | .......?..??????
<dbg>mapping
(...)
MAPL
----
MAPH
----
- $A000 <-- $10,0000 
(...)
  1. When you now edit the sample code, so that the Offset becomes $800.0000 or higher, means that the Attic memory you want to map is starting at 800.A000 or higher, the whole thing starts to work as expected.

    • Offset = $800.6000 (to reach 801.0000)
    • High byte = $80
    • Standard special value = $0F
    • Bank = $1
    • MSB of 16-bit = $00
    • Nibble value for segment selection MAPHI = $2

    Modified example code:

    LDA #$00 ; No mapping in MAPLO
    LDX #$00
    LDY #$80 ; High byte of Attic offset
    LDZ #$0F ; Special value
    MAP      ; first MAP
             ; A+X still 0
    LDY #$00 ; MSB of 16-bit
    LDZ #$21 ; segment selection + offset bank
    MAP      ; second MAP
    EOM
    

Expected result is matching:

MAPH: 2100
MAPL: 0000
MAPH high byte: 80
MAPL high byte: 00
<dbg>mdump 8010000
 :8010000 CE A2 2B AF FA B7 3A AB  20 AE A7 88 B2 AC 2F CA  | ΢+???:? ??.??/?
<dbg>mdump 777a000
 :777A000 CE A2 2B 2F FA B7 3A AB  20 AE A7 08 B2 AC 2F CA  | ΢+/??:? ??.??/?
<dbg>mapping
(...)
MAPL
----
MAPH
----- 
- $A000 <-- $1,A000 
(...)

Expected behavior

  • In the first case $777A000 should map $8000000
  • Alternatively we could document this behavior as a rule (maybe, until a fix is available)

Additional comment

  • I have tested a lot more value mixes for MAPLO and MAPHI, so the report is not only based on the above one shot
  • A hypothesis can be that the offset must have at least the same high byte as the memory which it is targeting
  • I could try these tests next: address higher Attic to see if an offset high byte over $80 makes trouble too. This is something not covered yet.
  • I would love to go on with debugging this, but I need somebody giving me starting points to look at. Where is mapping finally done? Is this ROM or FPGA programming or sth else? For sure I will help with testing.
@Pimau Pimau added the new New report, not classified yet label Sep 29, 2024
@dansanderson
Copy link
Collaborator

MAP is entirely in the CPU, not the ROM. I'll move this discussion to: MEGA65/mega65-core#838

With a short program entered via the MONITOR I'm not able to get any upper-byte offset working. It's possible my test is at fault. For now I'll assume this is a reproduction of the issue and we need more troubleshooting.

I tested the Memory chapter pretty thoroughly including this example, so I'll try to recreate the actual test I used (probably a test program via cross-development) to eliminate confusion. Once we're confident in the test steps, we might want to pursue this as a regression between v0.95 and v0.96.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new New report, not classified yet
Projects
None yet
Development

No branches or pull requests

2 participants