1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-11-22 16:33:48 +00:00

Added a working 256MB memory block remapping (MAP instruction) test.

This commit is contained in:
jespergravgaard 2020-09-21 01:32:51 +02:00
parent 77c15f80aa
commit a57b77f911
15 changed files with 2793 additions and 1338 deletions

View File

@ -1,4 +1,4 @@
//KICKC FRAGMENT CACHE 1813f9ad84 1813f9c5cd
//KICKC FRAGMENT CACHE 185628ba62 185628d2c2
//FRAGMENT vbuz1=vbuc1
lda #{c1}
sta {z1}

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
//KICKC FRAGMENT CACHE 1813f9ad84 1813f9c5cd
//KICKC FRAGMENT CACHE 185628ba62 185628d2c2
//FRAGMENT vbuz1=vbuc1
lda #{c1}
sta {z1}

View File

@ -1,4 +1,4 @@
//KICKC FRAGMENT CACHE 1813f9ad84 1813f9c5cd
//KICKC FRAGMENT CACHE 185628ba62 185628d2c2
//FRAGMENT vbuz1=vbuc1
lda #{c1}
sta {z1}

View File

@ -1,4 +1,4 @@
//KICKC FRAGMENT CACHE 1813f9ad84 1813f9c5cd
//KICKC FRAGMENT CACHE 185628ba62 185628d2c2
//FRAGMENT vbuz1=_deref_pbuc1
lda {c1}
sta {z1}

View File

@ -0,0 +1 @@
lda {m1}+1

View File

@ -0,0 +1 @@
ldx {m1}+1

View File

@ -0,0 +1 @@
ldy {m1}+1

View File

@ -0,0 +1,24 @@
lda {m2}+3
lsr
sta {m1}+3
lda {m2}+2
ror
sta {m1}+2
lda {m2}+1
ror
sta {m1}+1
lda {m2}
ror
sta {m1}
lsr {m1}+3
ror {m1}+2
ror {m1}+1
ror {m1}
lsr {m1}+3
ror {m1}+2
ror {m1}+1
ror {m1}
lsr {m1}+3
ror {m1}+2
ror {m1}+1
ror {m1}

View File

@ -111,6 +111,7 @@
"args": [
"-vasmout",
"-Sc",
"-Si",
"-odir",
"~/c64/tmp/",
"-e",

View File

@ -1,4 +1,6 @@
// Test the MAP instruction for remapping memory
// See section 2.3.4 in http://www.zimmers.net/cbmpics/cbm/c65/c65manual.txt for a description of the CPU memory remapper of the C65.
// See Appendix G in file:///Users/jespergravgaard/Downloads/MEGA65-Book_draft%20(5).pdf for a description of the CPU memory remapper of the MEGA65.
#pragma target(mega65)
#include <mega65.h>
@ -24,6 +26,15 @@ void main() {
block2[4] = block1[2];
block1[5] = block2[1];
// Remap [$4000-$5fff] to both point to [$ff80000-$ff81fff] COLORAM! (notice usage of page offsets)
memoryRemap256M(MEMORYBLOCK_4000, 0xff800-0x00040, 0);
// Put colors in the upper left corner!
block1[0] = 0;
block1[1] = 1;
// Remap [$4000-$5fff] back to normal memory!
memoryRemap256M(0, 0, 0);
}
@ -46,6 +57,7 @@ const unsigned char MEMORYBLOCK_E000 = 0b10000000;
// Remap some of the eight 8K memory blocks in the 64K address space of the 6502 to point somewhere else in the first 1MB memory space of the MEGA65.
// After the remapping the CPU will access the mapped memory whenever it uses instructions that access a remapped block.
// See section 2.3.4 in http://www.zimmers.net/cbmpics/cbm/c65/c65manual.txt for a description of the CPU memory remapper of the C65.
// remapBlocks: Indicates which 8K blocks of the 6502 address space to remap. Each bit represents one 8K block
// - bit 0 Memory block $0000-$1fff. Use constant MEMORYBLOCK_0000.
// - bit 1 Memory block $2000-$3fff. Use constant MEMORYBLOCK_2000.
@ -55,27 +67,27 @@ const unsigned char MEMORYBLOCK_E000 = 0b10000000;
// - bit 5 Memory block $a000-$bfff. Use constant MEMORYBLOCK_A000.
// - bit 6 Memory block $c000-$dfff. Use constant MEMORYBLOCK_C000.
// - bit 7 Memory block $e000-$ffff. Use constant MEMORYBLOCK_E000.
// lowerMemoryPageOffset: Offset that will be added to any remapped blocks in the lower 32K of memory (block 0-3).
// lowerPageOffset: Offset that will be added to any remapped blocks in the lower 32K of memory (block 0-3).
// The offset is a page offset (meaning it is multiplied by 0x100). Only the lower 12bits of the passed value is used.
// - If block 0 ($0000-$1fff) is remapped it will point to lowerMemoryPageOffset*$100.
// - If block 1 ($2000-$3fff) is remapped it will point to lowerMemoryPageOffset*$100 + $2000.
// - If block 2 ($4000-$5fff) is remapped it will point to lowerMemoryPageOffset*$100 + $4000.
// - If block 3 ($6000-$7fff) is remapped it will point to lowerMemoryPageOffset*$100 + $6000.
// upperMemoryPageOffset: Offset that will be added to any remapped blocks in the upper 32K of memory (block 4-7).
// - If block 0 ($0000-$1fff) is remapped it will point to lowerPageOffset*$100.
// - If block 1 ($2000-$3fff) is remapped it will point to lowerPageOffset*$100 + $2000.
// - If block 2 ($4000-$5fff) is remapped it will point to lowerPageOffset*$100 + $4000.
// - If block 3 ($6000-$7fff) is remapped it will point to lowerPageOffset*$100 + $6000.
// upperPageOffset: Offset that will be added to any remapped blocks in the upper 32K of memory (block 4-7).
// The offset is a page offset (meaning it is multiplied by 0x100). Only the lower 12bits of the passed value is used.
// - If block 4 ($8000-$9fff) is remapped it will point to upperMemoryPageOffset*$100 + $8000
// - If block 5 ($a000-$bfff) is remapped it will point to upperMemoryPageOffset*$100 + $a000.
// - If block 6 ($c000-$dfff) is remapped it will point to upperMemoryPageOffset*$100 + $c000.
// - If block 7 ($e000-$ffff) is remapped it will point to upperMemoryPageOffset*$100 + $e000.
void memoryRemap(unsigned char remapBlocks, unsigned int lowerMemoryPageOffset, unsigned int upperMemoryPageOffset) {
// - If block 4 ($8000-$9fff) is remapped it will point to upperPageOffset*$100 + $8000
// - If block 5 ($a000-$bfff) is remapped it will point to upperPageOffset*$100 + $a000.
// - If block 6 ($c000-$dfff) is remapped it will point to upperPageOffset*$100 + $c000.
// - If block 7 ($e000-$ffff) is remapped it will point to upperPageOffset*$100 + $e000.
void memoryRemap(unsigned char remapBlocks, unsigned int lowerPageOffset, unsigned int upperPageOffset) {
char * aVal = 0xfc;
char * xVal = 0xfd;
char * yVal = 0xfe;
char * zVal = 0xff;
*aVal = <lowerMemoryPageOffset;
*xVal = (remapBlocks << 4) | (>lowerMemoryPageOffset & 0xf);
*yVal = <upperMemoryPageOffset;
*zVal = (remapBlocks & 0xf0) | (>upperMemoryPageOffset & 0xf);
*aVal = <lowerPageOffset;
*xVal = (remapBlocks << 4) | (>lowerPageOffset & 0xf);
*yVal = <upperPageOffset;
*zVal = (remapBlocks & 0xf0) | (>upperPageOffset & 0xf);
asm {
lda aVal // lower blocks offset page low
ldx xVal // lower blocks to map + lower blocks offset high nibble
@ -100,12 +112,64 @@ void memoryRemapBlock(unsigned char blockPage, unsigned int memoryPage) {
memoryRemap(blockBits, pageOffset, pageOffset);
}
// Test corner case behaviors
// - Mapping two blocks to the same memory : [$4000-$5fff] >> [$10000-$12000], [$6000-$7fff] >> [$10000-$12000]
// Remap some of the eight 8K memory blocks in the 64K address space of the 6502 to point somewhere else in the entire 256MB memory space of the MEGA65.
// After the remapping the CPU will access the mapped memory whenever it uses instructions that access a remapped block.
// See section 2.3.4 in http://www.zimmers.net/cbmpics/cbm/c65/c65manual.txt for a description of the CPU memory remapper of the C65.
// See Appendix G in file:///Users/jespergravgaard/Downloads/MEGA65-Book_draft%20(5).pdf for a description of the CPU memory remapper of the MEGA65.
// remapBlocks: Indicates which 8K blocks of the 6502 address space to remap. Each bit represents one 8K block
// - bit 0 Memory block $0000-$1fff. Use constant MEMORYBLOCK_0000.
// - bit 1 Memory block $2000-$3fff. Use constant MEMORYBLOCK_2000.
// - bit 2 Memory block $4000-$5fff. Use constant MEMORYBLOCK_4000.
// - bit 3 Memory block $6000-$7fff. Use constant MEMORYBLOCK_6000.
// - bit 4 Memory block $8000-$9fff. Use constant MEMORYBLOCK_8000.
// - bit 5 Memory block $a000-$bfff. Use constant MEMORYBLOCK_A000.
// - bit 6 Memory block $c000-$dfff. Use constant MEMORYBLOCK_C000.
// - bit 7 Memory block $e000-$ffff. Use constant MEMORYBLOCK_E000.
// lowerPageOffset: Offset that will be added to any remapped blocks in the lower 32K of memory (block 0-3).
// The offset is a page offset (meaning it is multiplied by 0x100). Only the lower 20bits of the passed value is used.
// - If block 0 ($0000-$1fff) is remapped it will point to lowerPageOffset*$100.
// - If block 1 ($2000-$3fff) is remapped it will point to lowerPageOffset*$100 + $2000.
// - If block 2 ($4000-$5fff) is remapped it will point to lowerPageOffset*$100 + $4000.
// - If block 3 ($6000-$7fff) is remapped it will point to lowerPageOffset*$100 + $6000.
// upperPageOffset: Offset that will be added to any remapped blocks in the upper 32K of memory (block 4-7).
// The offset is a page offset (meaning it is multiplied by 0x100). Only the lower 20bits of the passed value is used.
// - If block 4 ($8000-$9fff) is remapped it will point to upperPageOffset*$100 + $8000
// - If block 5 ($a000-$bfff) is remapped it will point to upperPageOffset*$100 + $a000.
// - If block 6 ($c000-$dfff) is remapped it will point to upperPageOffset*$100 + $c000.
// - If block 7 ($e000-$ffff) is remapped it will point to upperPageOffset*$100 + $e000.
void memoryRemap256M(unsigned char remapBlocks, unsigned long lowerPageOffset, unsigned long upperPageOffset) {
char * lMb = 0xfa;
char * uMb = 0xfb;
char * aVal = 0xfc;
char * xVal = 0xfd;
char * yVal = 0xfe;
char * zVal = 0xff;
*lMb = >((unsigned int)(lowerPageOffset>>4));
*uMb = >((unsigned int)(upperPageOffset>>4));
*aVal = < <lowerPageOffset;
*xVal = (remapBlocks << 4) | (> <lowerPageOffset & 0xf);
*yVal = < <upperPageOffset;
*zVal = (remapBlocks & 0xf0) | (> <upperPageOffset & 0xf);
asm {
lda lMb // lower blocks offset megabytes
ldx #$0f // lower signal for MB offset
ldy uMb // upper blocks offset megabytes
ldz #$00 // upper signal for MB offset
map
lda aVal // lower blocks offset page low
ldx xVal // lower blocks to map + lower blocks offset high nibble
ldy yVal // upper blocks offset page
ldz zVal // upper blocks to map + upper blocks offset page high nibble
map
eom
}
}
// Test more corner case behaviors
// - [DONE] Mapping two blocks to the same memory : [$4000-$5fff] >> [$10000-$12000], [$8000-$9fff] >> [$10000-$12000]
// - Mapping two blocks to overlapping memory : [$4000-$5fff] >> [$10000-$12000], [$6000-$7f00] >> [$11000-$12ff]
// - Mapping a block to the 1MB border : [$4000-$5fff] >> [$ff000-$100fff] or [$ff000-$00fff] ?
// - Mapping a block over zeropage : [$0000-$1fff] >> [$10000-$12000]. Does zp-addressing-mode access the mapped memory?
// Add memory block remapping to the full 256MB memory

View File

@ -1,4 +1,6 @@
// Test the MAP instruction for remapping memory
// See section 2.3.4 in http://www.zimmers.net/cbmpics/cbm/c65/c65manual.txt for a description of the CPU memory remapper of the C65.
// See Appendix G in file:///Users/jespergravgaard/Downloads/MEGA65-Book_draft%20(5).pdf for a description of the CPU memory remapper of the MEGA65.
// MEGA65 Registers and Constants
// The MOS 6526 Complex Interface Adapter (CIA)
// http://archive.6502.org/datasheets/mos_6526_cia_recreated.pdf
@ -47,14 +49,14 @@ main: {
// memoryRemap(MEMORYBLOCK_4000|MEMORYBLOCK_8000, 0x0c0, 0x080)
// Remap [$4000-$5fff] and [$8000-$9fff] to both point to [$10000-$11fff] (notice usage of page offsets)
lda #<$80
sta.z memoryRemap.upperMemoryPageOffset
sta.z memoryRemap.upperPageOffset
lda #>$80
sta.z memoryRemap.upperMemoryPageOffset+1
sta.z memoryRemap.upperPageOffset+1
ldz #MEMORYBLOCK_4000|MEMORYBLOCK_8000
lda #<$c0
sta.z memoryRemap.lowerMemoryPageOffset
sta.z memoryRemap.lowerPageOffset
lda #>$c0
sta.z memoryRemap.lowerMemoryPageOffset+1
sta.z memoryRemap.lowerPageOffset+1
jsr memoryRemap
// block2[4] = block1[2]
// Put 0x55, 0xaa into $10004 in a convoluted way
@ -63,6 +65,34 @@ main: {
// block1[5] = block2[1]
lda block2+1
sta block1+5
// memoryRemap256M(MEMORYBLOCK_4000, 0xff800-0x00040, 0)
// Remap [$4000-$5fff] to both point to [$ff80000-$ff81fff] COLORAM! (notice usage of page offsets)
ldz #MEMORYBLOCK_4000
lda #<$ff800-$40
sta.z memoryRemap256M.lowerPageOffset
lda #>$ff800-$40
sta.z memoryRemap256M.lowerPageOffset+1
lda #<$ff800-$40>>$10
sta.z memoryRemap256M.lowerPageOffset+2
lda #>$ff800-$40>>$10
sta.z memoryRemap256M.lowerPageOffset+3
jsr memoryRemap256M
// block1[0] = 0
// Put colors in the upper left corner!
lda #0
sta block1
// block1[1] = 1
lda #1
sta block1+1
// memoryRemap256M(0, 0, 0)
// Remap [$4000-$5fff] back to normal memory!
ldz #0
lda #0
sta.z memoryRemap256M.lowerPageOffset
sta.z memoryRemap256M.lowerPageOffset+1
sta.z memoryRemap256M.lowerPageOffset+2
sta.z memoryRemap256M.lowerPageOffset+3
jsr memoryRemap256M
// }
rts
}
@ -73,7 +103,7 @@ main: {
// Ie. the memory that will be pointed to is $100 * the passed page address. Only the lower 12bits of the passed value is used.
// memoryRemapBlock(byte register(X) blockPage)
memoryRemapBlock: {
.label pageOffset = 2
.label pageOffset = $d
// pageOffset = memoryPage-blockPage
stx.z $ff
lda #<$100
@ -103,15 +133,16 @@ memoryRemapBlock: {
// memoryRemap(blockBits, pageOffset, pageOffset)
taz
lda.z pageOffset
sta.z memoryRemap.upperMemoryPageOffset
sta.z memoryRemap.upperPageOffset
lda.z pageOffset+1
sta.z memoryRemap.upperMemoryPageOffset+1
sta.z memoryRemap.upperPageOffset+1
jsr memoryRemap
// }
rts
}
// Remap some of the eight 8K memory blocks in the 64K address space of the 6502 to point somewhere else in the first 1MB memory space of the MEGA65.
// After the remapping the CPU will access the mapped memory whenever it uses instructions that access a remapped block.
// See section 2.3.4 in http://www.zimmers.net/cbmpics/cbm/c65/c65manual.txt for a description of the CPU memory remapper of the C65.
// remapBlocks: Indicates which 8K blocks of the 6502 address space to remap. Each bit represents one 8K block
// - bit 0 Memory block $0000-$1fff. Use constant MEMORYBLOCK_0000.
// - bit 1 Memory block $2000-$3fff. Use constant MEMORYBLOCK_2000.
@ -121,31 +152,31 @@ memoryRemapBlock: {
// - bit 5 Memory block $a000-$bfff. Use constant MEMORYBLOCK_A000.
// - bit 6 Memory block $c000-$dfff. Use constant MEMORYBLOCK_C000.
// - bit 7 Memory block $e000-$ffff. Use constant MEMORYBLOCK_E000.
// lowerMemoryPageOffset: Offset that will be added to any remapped blocks in the lower 32K of memory (block 0-3).
// lowerPageOffset: Offset that will be added to any remapped blocks in the lower 32K of memory (block 0-3).
// The offset is a page offset (meaning it is multiplied by 0x100). Only the lower 12bits of the passed value is used.
// - If block 0 ($0000-$1fff) is remapped it will point to lowerMemoryPageOffset*$100.
// - If block 1 ($2000-$3fff) is remapped it will point to lowerMemoryPageOffset*$100 + $2000.
// - If block 2 ($4000-$5fff) is remapped it will point to lowerMemoryPageOffset*$100 + $4000.
// - If block 3 ($6000-$7fff) is remapped it will point to lowerMemoryPageOffset*$100 + $6000.
// upperMemoryPageOffset: Offset that will be added to any remapped blocks in the upper 32K of memory (block 4-7).
// - If block 0 ($0000-$1fff) is remapped it will point to lowerPageOffset*$100.
// - If block 1 ($2000-$3fff) is remapped it will point to lowerPageOffset*$100 + $2000.
// - If block 2 ($4000-$5fff) is remapped it will point to lowerPageOffset*$100 + $4000.
// - If block 3 ($6000-$7fff) is remapped it will point to lowerPageOffset*$100 + $6000.
// upperPageOffset: Offset that will be added to any remapped blocks in the upper 32K of memory (block 4-7).
// The offset is a page offset (meaning it is multiplied by 0x100). Only the lower 12bits of the passed value is used.
// - If block 4 ($8000-$9fff) is remapped it will point to upperMemoryPageOffset*$100 + $8000
// - If block 5 ($a000-$bfff) is remapped it will point to upperMemoryPageOffset*$100 + $a000.
// - If block 6 ($c000-$dfff) is remapped it will point to upperMemoryPageOffset*$100 + $c000.
// - If block 7 ($e000-$ffff) is remapped it will point to upperMemoryPageOffset*$100 + $e000.
// memoryRemap(byte register(Z) remapBlocks, word zp(2) lowerMemoryPageOffset, word zp(4) upperMemoryPageOffset)
// - If block 4 ($8000-$9fff) is remapped it will point to upperPageOffset*$100 + $8000
// - If block 5 ($a000-$bfff) is remapped it will point to upperPageOffset*$100 + $a000.
// - If block 6 ($c000-$dfff) is remapped it will point to upperPageOffset*$100 + $c000.
// - If block 7 ($e000-$ffff) is remapped it will point to upperPageOffset*$100 + $e000.
// memoryRemap(byte register(Z) remapBlocks, word zp($d) lowerPageOffset, word zp(2) upperPageOffset)
memoryRemap: {
.label aVal = $fc
.label xVal = $fd
.label yVal = $fe
.label zVal = $ff
.label __1 = 6
.label __6 = 7
.label lowerMemoryPageOffset = 2
.label upperMemoryPageOffset = 4
// <lowerMemoryPageOffset
lda.z lowerMemoryPageOffset
// *aVal = <lowerMemoryPageOffset
.label __1 = $f
.label __6 = 8
.label lowerPageOffset = $d
.label upperPageOffset = 2
// <lowerPageOffset
lda.z lowerPageOffset
// *aVal = <lowerPageOffset
sta aVal
// remapBlocks << 4
tza
@ -154,29 +185,29 @@ memoryRemap: {
asl
asl
sta.z __1
// >lowerMemoryPageOffset
lda.z lowerMemoryPageOffset+1
// >lowerMemoryPageOffset & 0xf
// >lowerPageOffset
lda.z lowerPageOffset+1
// >lowerPageOffset & 0xf
and #$f
// (remapBlocks << 4) | (>lowerMemoryPageOffset & 0xf)
// (remapBlocks << 4) | (>lowerPageOffset & 0xf)
ora.z __1
// *xVal = (remapBlocks << 4) | (>lowerMemoryPageOffset & 0xf)
// *xVal = (remapBlocks << 4) | (>lowerPageOffset & 0xf)
sta xVal
// <upperMemoryPageOffset
lda.z upperMemoryPageOffset
// *yVal = <upperMemoryPageOffset
// <upperPageOffset
lda.z upperPageOffset
// *yVal = <upperPageOffset
sta yVal
// remapBlocks & 0xf0
tza
and #$f0
sta.z __6
// >upperMemoryPageOffset
lda.z upperMemoryPageOffset+1
// >upperMemoryPageOffset & 0xf
// >upperPageOffset
lda.z upperPageOffset+1
// >upperPageOffset & 0xf
and #$f
// (remapBlocks & 0xf0) | (>upperMemoryPageOffset & 0xf)
// (remapBlocks & 0xf0) | (>upperPageOffset & 0xf)
ora.z __6
// *zVal = (remapBlocks & 0xf0) | (>upperMemoryPageOffset & 0xf)
// *zVal = (remapBlocks & 0xf0) | (>upperPageOffset & 0xf)
sta zVal
// asm
lda aVal
@ -188,3 +219,119 @@ memoryRemap: {
// }
rts
}
// Remap some of the eight 8K memory blocks in the 64K address space of the 6502 to point somewhere else in the entire 256MB memory space of the MEGA65.
// After the remapping the CPU will access the mapped memory whenever it uses instructions that access a remapped block.
// See section 2.3.4 in http://www.zimmers.net/cbmpics/cbm/c65/c65manual.txt for a description of the CPU memory remapper of the C65.
// See Appendix G in file:///Users/jespergravgaard/Downloads/MEGA65-Book_draft%20(5).pdf for a description of the CPU memory remapper of the MEGA65.
// remapBlocks: Indicates which 8K blocks of the 6502 address space to remap. Each bit represents one 8K block
// - bit 0 Memory block $0000-$1fff. Use constant MEMORYBLOCK_0000.
// - bit 1 Memory block $2000-$3fff. Use constant MEMORYBLOCK_2000.
// - bit 2 Memory block $4000-$5fff. Use constant MEMORYBLOCK_4000.
// - bit 3 Memory block $6000-$7fff. Use constant MEMORYBLOCK_6000.
// - bit 4 Memory block $8000-$9fff. Use constant MEMORYBLOCK_8000.
// - bit 5 Memory block $a000-$bfff. Use constant MEMORYBLOCK_A000.
// - bit 6 Memory block $c000-$dfff. Use constant MEMORYBLOCK_C000.
// - bit 7 Memory block $e000-$ffff. Use constant MEMORYBLOCK_E000.
// lowerPageOffset: Offset that will be added to any remapped blocks in the lower 32K of memory (block 0-3).
// The offset is a page offset (meaning it is multiplied by 0x100). Only the lower 20bits of the passed value is used.
// - If block 0 ($0000-$1fff) is remapped it will point to lowerPageOffset*$100.
// - If block 1 ($2000-$3fff) is remapped it will point to lowerPageOffset*$100 + $2000.
// - If block 2 ($4000-$5fff) is remapped it will point to lowerPageOffset*$100 + $4000.
// - If block 3 ($6000-$7fff) is remapped it will point to lowerPageOffset*$100 + $6000.
// upperPageOffset: Offset that will be added to any remapped blocks in the upper 32K of memory (block 4-7).
// The offset is a page offset (meaning it is multiplied by 0x100). Only the lower 20bits of the passed value is used.
// - If block 4 ($8000-$9fff) is remapped it will point to upperPageOffset*$100 + $8000
// - If block 5 ($a000-$bfff) is remapped it will point to upperPageOffset*$100 + $a000.
// - If block 6 ($c000-$dfff) is remapped it will point to upperPageOffset*$100 + $c000.
// - If block 7 ($e000-$ffff) is remapped it will point to upperPageOffset*$100 + $e000.
// memoryRemap256M(byte register(Z) remapBlocks, dword zp(4) lowerPageOffset)
memoryRemap256M: {
.label lMb = $fa
.label uMb = $fb
.label aVal = $fc
.label xVal = $fd
.label yVal = $fe
.label zVal = $ff
.label __0 = 9
.label __6 = $f
.label __7 = $d
.label lowerPageOffset = 4
// lowerPageOffset>>4
lda.z lowerPageOffset+3
lsr
sta.z __0+3
lda.z lowerPageOffset+2
ror
sta.z __0+2
lda.z lowerPageOffset+1
ror
sta.z __0+1
lda.z lowerPageOffset
ror
sta.z __0
lsr.z __0+3
ror.z __0+2
ror.z __0+1
ror.z __0
lsr.z __0+3
ror.z __0+2
ror.z __0+1
ror.z __0
lsr.z __0+3
ror.z __0+2
ror.z __0+1
ror.z __0
// >((unsigned int)(lowerPageOffset>>4))
lda.z __0+1
// *lMb = >((unsigned int)(lowerPageOffset>>4))
sta lMb
// *uMb = >((unsigned int)(upperPageOffset>>4))
lda #0
sta uMb
// <lowerPageOffset
lda.z lowerPageOffset
sta.z __7
lda.z lowerPageOffset+1
sta.z __7+1
// < <lowerPageOffset
lda.z __7
// *aVal = < <lowerPageOffset
sta aVal
// remapBlocks << 4
tza
asl
asl
asl
asl
sta.z __6
// > <lowerPageOffset
lda.z __7+1
// > <lowerPageOffset & 0xf
and #$f
// (remapBlocks << 4) | (> <lowerPageOffset & 0xf)
ora.z __6
// *xVal = (remapBlocks << 4) | (> <lowerPageOffset & 0xf)
sta xVal
// *yVal = < <upperPageOffset
lda #0
sta yVal
// (remapBlocks & 0xf0) | (> <upperPageOffset & 0xf)
tza
and #$f0
// *zVal = (remapBlocks & 0xf0) | (> <upperPageOffset & 0xf)
sta zVal
// asm
lda lMb
ldx #$f
ldy uMb
ldz #0
map
lda aVal
ldx xVal
ldy yVal
ldz zVal
map
eom
// }
rts
}

View File

@ -17,47 +17,78 @@ main::@2: scope:[main] from main::@1
main::@3: scope:[main] from main::@2
[8] *((const byte*) main::block2+(byte) 4) ← *((const byte*) main::block1+(byte) 2)
[9] *((const byte*) main::block1+(byte) 5) ← *((const byte*) main::block2+(byte) 1)
[10] call memoryRemap256M
to:main::@4
main::@4: scope:[main] from main::@3
[11] *((const byte*) main::block1) ← (byte) 0
[12] *((const byte*) main::block1+(byte) 1) ← (byte) 1
[13] call memoryRemap256M
to:main::@return
main::@return: scope:[main] from main::@3
[10] return
main::@return: scope:[main] from main::@4
[14] return
to:@return
(void()) memoryRemapBlock((byte) memoryRemapBlock::blockPage , (word) memoryRemapBlock::memoryPage)
memoryRemapBlock: scope:[memoryRemapBlock] from main main::@1
[11] (byte) memoryRemapBlock::blockPage#2 ← phi( main/(byte) $40 main::@1/(byte) $80 )
[12] (word) memoryRemapBlock::pageOffset#0 ← (word) $100 - (byte) memoryRemapBlock::blockPage#2
[13] (byte) memoryRemapBlock::block#0 ← (byte) memoryRemapBlock::blockPage#2 >> (byte) 5
[14] (byte) memoryRemapBlock::blockBits#0 ← (byte) 1 << (byte) memoryRemapBlock::block#0
[15] (byte) memoryRemap::remapBlocks#1 ← (byte) memoryRemapBlock::blockBits#0
[16] (word) memoryRemap::lowerMemoryPageOffset#1 ← (word) memoryRemapBlock::pageOffset#0
[17] (word) memoryRemap::upperMemoryPageOffset#1 ← (word) memoryRemapBlock::pageOffset#0
[18] call memoryRemap
[15] (byte) memoryRemapBlock::blockPage#2 ← phi( main/(byte) $40 main::@1/(byte) $80 )
[16] (word) memoryRemapBlock::pageOffset#0 ← (word) $100 - (byte) memoryRemapBlock::blockPage#2
[17] (byte) memoryRemapBlock::block#0 ← (byte) memoryRemapBlock::blockPage#2 >> (byte) 5
[18] (byte) memoryRemapBlock::blockBits#0 ← (byte) 1 << (byte) memoryRemapBlock::block#0
[19] (byte) memoryRemap::remapBlocks#1 ← (byte) memoryRemapBlock::blockBits#0
[20] (word) memoryRemap::lowerPageOffset#1 ← (word) memoryRemapBlock::pageOffset#0
[21] (word) memoryRemap::upperPageOffset#1 ← (word) memoryRemapBlock::pageOffset#0
[22] call memoryRemap
to:memoryRemapBlock::@return
memoryRemapBlock::@return: scope:[memoryRemapBlock] from memoryRemapBlock
[19] return
[23] return
to:@return
(void()) memoryRemap((byte) memoryRemap::remapBlocks , (word) memoryRemap::lowerMemoryPageOffset , (word) memoryRemap::upperMemoryPageOffset)
(void()) memoryRemap((byte) memoryRemap::remapBlocks , (word) memoryRemap::lowerPageOffset , (word) memoryRemap::upperPageOffset)
memoryRemap: scope:[memoryRemap] from main::@2 memoryRemapBlock
[20] (word) memoryRemap::upperMemoryPageOffset#2 ← phi( main::@2/(byte) $80 memoryRemapBlock/(word) memoryRemap::upperMemoryPageOffset#1 )
[20] (byte) memoryRemap::remapBlocks#2 ← phi( main::@2/(const nomodify byte) MEMORYBLOCK_4000|(const nomodify byte) MEMORYBLOCK_8000 memoryRemapBlock/(byte) memoryRemap::remapBlocks#1 )
[20] (word) memoryRemap::lowerMemoryPageOffset#2 ← phi( main::@2/(byte) $c0 memoryRemapBlock/(word) memoryRemap::lowerMemoryPageOffset#1 )
[21] (byte~) memoryRemap::$0 ← < (word) memoryRemap::lowerMemoryPageOffset#2
[22] *((const byte*) memoryRemap::aVal) ← (byte~) memoryRemap::$0
[23] (byte~) memoryRemap::$1 ← (byte) memoryRemap::remapBlocks#2 << (byte) 4
[24] (byte~) memoryRemap::$2 ← > (word) memoryRemap::lowerMemoryPageOffset#2
[25] (byte~) memoryRemap::$3 ← (byte~) memoryRemap::$2 & (byte) $f
[26] (byte~) memoryRemap::$4 ← (byte~) memoryRemap::$1 | (byte~) memoryRemap::$3
[27] *((const byte*) memoryRemap::xVal) ← (byte~) memoryRemap::$4
[28] (byte~) memoryRemap::$5 ← < (word) memoryRemap::upperMemoryPageOffset#2
[29] *((const byte*) memoryRemap::yVal) ← (byte~) memoryRemap::$5
[30] (byte~) memoryRemap::$6 ← (byte) memoryRemap::remapBlocks#2 & (byte) $f0
[31] (byte~) memoryRemap::$7 ← > (word) memoryRemap::upperMemoryPageOffset#2
[32] (byte~) memoryRemap::$8 ← (byte~) memoryRemap::$7 & (byte) $f
[33] (byte~) memoryRemap::$9 ← (byte~) memoryRemap::$6 | (byte~) memoryRemap::$8
[34] *((const byte*) memoryRemap::zVal) ← (byte~) memoryRemap::$9
[24] (word) memoryRemap::upperPageOffset#2 ← phi( main::@2/(byte) $80 memoryRemapBlock/(word) memoryRemap::upperPageOffset#1 )
[24] (byte) memoryRemap::remapBlocks#2 ← phi( main::@2/(const nomodify byte) MEMORYBLOCK_4000|(const nomodify byte) MEMORYBLOCK_8000 memoryRemapBlock/(byte) memoryRemap::remapBlocks#1 )
[24] (word) memoryRemap::lowerPageOffset#2 ← phi( main::@2/(byte) $c0 memoryRemapBlock/(word) memoryRemap::lowerPageOffset#1 )
[25] (byte~) memoryRemap::$0 ← < (word) memoryRemap::lowerPageOffset#2
[26] *((const byte*) memoryRemap::aVal) ← (byte~) memoryRemap::$0
[27] (byte~) memoryRemap::$1 ← (byte) memoryRemap::remapBlocks#2 << (byte) 4
[28] (byte~) memoryRemap::$2 ← > (word) memoryRemap::lowerPageOffset#2
[29] (byte~) memoryRemap::$3 ← (byte~) memoryRemap::$2 & (byte) $f
[30] (byte~) memoryRemap::$4 ← (byte~) memoryRemap::$1 | (byte~) memoryRemap::$3
[31] *((const byte*) memoryRemap::xVal) ← (byte~) memoryRemap::$4
[32] (byte~) memoryRemap::$5 ← < (word) memoryRemap::upperPageOffset#2
[33] *((const byte*) memoryRemap::yVal) ← (byte~) memoryRemap::$5
[34] (byte~) memoryRemap::$6 ← (byte) memoryRemap::remapBlocks#2 & (byte) $f0
[35] (byte~) memoryRemap::$7 ← > (word) memoryRemap::upperPageOffset#2
[36] (byte~) memoryRemap::$8 ← (byte~) memoryRemap::$7 & (byte) $f
[37] (byte~) memoryRemap::$9 ← (byte~) memoryRemap::$6 | (byte~) memoryRemap::$8
[38] *((const byte*) memoryRemap::zVal) ← (byte~) memoryRemap::$9
asm { ldaaVal ldxxVal ldyyVal ldzzVal map eom }
to:memoryRemap::@return
memoryRemap::@return: scope:[memoryRemap] from memoryRemap
[36] return
[40] return
to:@return
(void()) memoryRemap256M((byte) memoryRemap256M::remapBlocks , (dword) memoryRemap256M::lowerPageOffset , (dword) memoryRemap256M::upperPageOffset)
memoryRemap256M: scope:[memoryRemap256M] from main::@3 main::@4
[41] (byte) memoryRemap256M::remapBlocks#2 ← phi( main::@3/(const nomodify byte) MEMORYBLOCK_4000 main::@4/(byte) 0 )
[41] (dword) memoryRemap256M::lowerPageOffset#2 ← phi( main::@3/(dword)(number) $ff800-(number) $40 main::@4/(byte) 0 )
[42] (dword~) memoryRemap256M::$0 ← (dword) memoryRemap256M::lowerPageOffset#2 >> (byte) 4
[43] (byte~) memoryRemap256M::$1 ← > (word)(dword~) memoryRemap256M::$0
[44] *((const byte*) memoryRemap256M::lMb) ← (byte~) memoryRemap256M::$1
[45] *((const byte*) memoryRemap256M::uMb) ← (byte) 0
[46] (word~) memoryRemap256M::$7 ← < (dword) memoryRemap256M::lowerPageOffset#2
[47] (byte~) memoryRemap256M::$5 ← < (word~) memoryRemap256M::$7
[48] *((const byte*) memoryRemap256M::aVal) ← (byte~) memoryRemap256M::$5
[49] (byte~) memoryRemap256M::$6 ← (byte) memoryRemap256M::remapBlocks#2 << (byte) 4
[50] (byte~) memoryRemap256M::$8 ← > (word~) memoryRemap256M::$7
[51] (byte~) memoryRemap256M::$9 ← (byte~) memoryRemap256M::$8 & (byte) $f
[52] (byte~) memoryRemap256M::$10 ← (byte~) memoryRemap256M::$6 | (byte~) memoryRemap256M::$9
[53] *((const byte*) memoryRemap256M::xVal) ← (byte~) memoryRemap256M::$10
[54] *((const byte*) memoryRemap256M::yVal) ← (byte) 0
[55] (byte~) memoryRemap256M::$17 ← (byte) memoryRemap256M::remapBlocks#2 & (byte) $f0
[56] *((const byte*) memoryRemap256M::zVal) ← (byte~) memoryRemap256M::$17
asm { ldalMb ldx#$0f ldyuMb ldz#$00 map ldaaVal ldxxVal ldyyVal ldzzVal map eom }
to:memoryRemap256M::@return
memoryRemap256M::@return: scope:[memoryRemap256M] from memoryRemap256M
[58] return
to:@return

File diff suppressed because it is too large Load Diff

View File

@ -288,34 +288,57 @@
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@4
(label) main::@return
(const byte*) main::block1 = (byte*) 16384
(const byte*) main::block2 = (byte*) 32768
(void()) memoryRemap((byte) memoryRemap::remapBlocks , (word) memoryRemap::lowerMemoryPageOffset , (word) memoryRemap::upperMemoryPageOffset)
(void()) memoryRemap((byte) memoryRemap::remapBlocks , (word) memoryRemap::lowerPageOffset , (word) memoryRemap::upperPageOffset)
(byte~) memoryRemap::$0 reg byte a 202.0
(byte~) memoryRemap::$1 zp[1]:6 67.33333333333333
(byte~) memoryRemap::$1 zp[1]:15 67.33333333333333
(byte~) memoryRemap::$2 reg byte a 202.0
(byte~) memoryRemap::$3 reg byte a 202.0
(byte~) memoryRemap::$4 reg byte a 202.0
(byte~) memoryRemap::$5 reg byte a 202.0
(byte~) memoryRemap::$6 zp[1]:7 67.33333333333333
(byte~) memoryRemap::$6 zp[1]:8 67.33333333333333
(byte~) memoryRemap::$7 reg byte a 202.0
(byte~) memoryRemap::$8 reg byte a 202.0
(byte~) memoryRemap::$9 reg byte a 202.0
(label) memoryRemap::@return
(const byte*) memoryRemap::aVal = (byte*) 252
(word) memoryRemap::lowerMemoryPageOffset
(word) memoryRemap::lowerMemoryPageOffset#1 lowerMemoryPageOffset zp[2]:2 11.0
(word) memoryRemap::lowerMemoryPageOffset#2 lowerMemoryPageOffset zp[2]:2 53.25
(word) memoryRemap::lowerPageOffset
(word) memoryRemap::lowerPageOffset#1 lowerPageOffset zp[2]:13 11.0
(word) memoryRemap::lowerPageOffset#2 lowerPageOffset zp[2]:13 53.25
(byte) memoryRemap::remapBlocks
(byte) memoryRemap::remapBlocks#1 reg byte z 7.333333333333333
(byte) memoryRemap::remapBlocks#2 reg byte z 21.299999999999997
(word) memoryRemap::upperMemoryPageOffset
(word) memoryRemap::upperMemoryPageOffset#1 upperMemoryPageOffset zp[2]:4 22.0
(word) memoryRemap::upperMemoryPageOffset#2 upperMemoryPageOffset zp[2]:4 19.363636363636363
(word) memoryRemap::upperPageOffset
(word) memoryRemap::upperPageOffset#1 upperPageOffset zp[2]:2 22.0
(word) memoryRemap::upperPageOffset#2 upperPageOffset zp[2]:2 19.363636363636363
(const byte*) memoryRemap::xVal = (byte*) 253
(const byte*) memoryRemap::yVal = (byte*) 254
(const byte*) memoryRemap::zVal = (byte*) 255
(void()) memoryRemap256M((byte) memoryRemap256M::remapBlocks , (dword) memoryRemap256M::lowerPageOffset , (dword) memoryRemap256M::upperPageOffset)
(dword~) memoryRemap256M::$0 zp[4]:9 11.0
(byte~) memoryRemap256M::$1 reg byte a 22.0
(byte~) memoryRemap256M::$10 reg byte a 22.0
(byte~) memoryRemap256M::$17 reg byte a 22.0
(byte~) memoryRemap256M::$5 reg byte a 22.0
(byte~) memoryRemap256M::$6 zp[1]:15 7.333333333333333
(word~) memoryRemap256M::$7 zp[2]:13 8.25
(byte~) memoryRemap256M::$8 reg byte a 22.0
(byte~) memoryRemap256M::$9 reg byte a 22.0
(label) memoryRemap256M::@return
(const byte*) memoryRemap256M::aVal = (byte*) 252
(const byte*) memoryRemap256M::lMb = (byte*) 250
(dword) memoryRemap256M::lowerPageOffset
(dword) memoryRemap256M::lowerPageOffset#2 lowerPageOffset zp[4]:4 4.4
(byte) memoryRemap256M::remapBlocks
(byte) memoryRemap256M::remapBlocks#2 reg byte z 1.5714285714285714
(const byte*) memoryRemap256M::uMb = (byte*) 251
(dword) memoryRemap256M::upperPageOffset
(const byte*) memoryRemap256M::xVal = (byte*) 253
(const byte*) memoryRemap256M::yVal = (byte*) 254
(const byte*) memoryRemap256M::zVal = (byte*) 255
(void()) memoryRemapBlock((byte) memoryRemapBlock::blockPage , (word) memoryRemapBlock::memoryPage)
(label) memoryRemapBlock::@return
(byte) memoryRemapBlock::block
@ -326,21 +349,30 @@
(byte) memoryRemapBlock::blockPage#2 reg byte x 11.0
(word) memoryRemapBlock::memoryPage
(word) memoryRemapBlock::pageOffset
(word) memoryRemapBlock::pageOffset#0 pageOffset zp[2]:2 6.6000000000000005
(word) memoryRemapBlock::pageOffset#0 pageOffset zp[2]:13 6.6000000000000005
reg byte x [ memoryRemapBlock::blockPage#2 ]
zp[2]:2 [ memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 ]
reg byte z [ memoryRemap::remapBlocks#2 memoryRemap::remapBlocks#1 ]
zp[2]:4 [ memoryRemap::upperMemoryPageOffset#2 memoryRemap::upperMemoryPageOffset#1 ]
zp[2]:2 [ memoryRemap::upperPageOffset#2 memoryRemap::upperPageOffset#1 ]
zp[4]:4 [ memoryRemap256M::lowerPageOffset#2 ]
reg byte z [ memoryRemap256M::remapBlocks#2 ]
reg byte a [ memoryRemapBlock::block#0 ]
reg byte a [ memoryRemapBlock::blockBits#0 ]
reg byte a [ memoryRemap::$0 ]
zp[1]:6 [ memoryRemap::$1 ]
reg byte a [ memoryRemap::$2 ]
reg byte a [ memoryRemap::$3 ]
reg byte a [ memoryRemap::$4 ]
reg byte a [ memoryRemap::$5 ]
zp[1]:7 [ memoryRemap::$6 ]
zp[1]:8 [ memoryRemap::$6 ]
reg byte a [ memoryRemap::$7 ]
reg byte a [ memoryRemap::$8 ]
reg byte a [ memoryRemap::$9 ]
zp[4]:9 [ memoryRemap256M::$0 ]
reg byte a [ memoryRemap256M::$1 ]
zp[2]:13 [ memoryRemap256M::$7 memoryRemap::lowerPageOffset#2 memoryRemap::lowerPageOffset#1 memoryRemapBlock::pageOffset#0 ]
reg byte a [ memoryRemap256M::$5 ]
zp[1]:15 [ memoryRemap256M::$6 memoryRemap::$1 ]
reg byte a [ memoryRemap256M::$8 ]
reg byte a [ memoryRemap256M::$9 ]
reg byte a [ memoryRemap256M::$10 ]
reg byte a [ memoryRemap256M::$17 ]