6502 Relative Address Mode Transfer

Reading the documentation on 6502, and I could not find it anywhere. When using relative addressing, you can wrap it up. But is it possible to wrap both ends? I suppose this is possible, but unlikely.

And when I mean both ends, I mean, I know that you can wrap from a high PC to a low PC. But can you also wrap from low PC to high PC?

+4
source share
3 answers

Crossing the page border with a relative branch will lead to an additional loop, but it doesnโ€™t matter if the page branch is a forward or backward branch.

You can try this in Visual6502 . Enter the program A9 00 F0 EC ( LDA #00 / BEQ $FFF0 ) at address 0000, skipping the code in one step and see where it ends after BEQ . If you trust only real equipment, you can easily verify this, for example, in the Nintendo entertainment system.

Obviously, in order to be able to get to the FF page with a relative branch, you would have to execute RAM from RAM, and you probably would not want to spend ZP RAM on code, since it should correspond to your most frequently accessible data, so this is hardly will make this specific scenario.

+7
source

Yes, it works and vice versa. But many assemblers do not support this. When you try to place a branch statement at the beginning of the addressing area> $ ff80, assemblers usually cause errors such as "offset too large". But when you try to put an operation code with byte values, for example > 0002 f0 e0 , you will get the result beq $ffe4 . I used 0002 as the first memory address since I used Commodore 64 to try it and $ 0001 cannot be used for this machine. For other machines based on 6502, 0000 should also be in order.

+3
source

In the general case, you can perform your own address calculation using modulo arithmetic, and then use the result for absolute addressing.

0
source

All Articles