User Tools

Site Tools


wswan:guide:elf_quirks

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
wswan:guide:elf_quirks [2024/09/22 09:34] asiewswan:guide:elf_quirks [2024/09/22 11:58] (current) asie
Line 21: Line 21:
 ===== Address space (wswan) ===== ===== Address space (wswan) =====
  
-ELF addresses ''0x80000000 - 0xFFFFFFFF'' correspond to ROM addresses.+ELF addresses ''0x80000000 - 0xFFFFFFFF'' correspond to addresses in ROM.
  
 <code> <code>
Line 29: Line 29:
   ||| |||| |||| |||| |||| |||| |||| ||||   ||| |||| |||| |||| |||| |||| |||| ||||
   ||| |||| |||| ++++-++++-++++-++++-++++- CPU address (bits 0-19)   ||| |||| |||| ++++-++++-++++-++++-++++- CPU address (bits 0-19)
-  +++-++++-++++-------------------------- ROM bank (bits 30-20)+  +++-++++-++++-------------------------- 64KB ROM bank (bits 30-20)
                                           Corresponds to banks 000 - 7FF (128 MB maximum)                                           Corresponds to banks 000 - 7FF (128 MB maximum)
                                           The last ROM bank uses addresses FFFxxxxx                                           The last ROM bank uses addresses FFFxxxxx
 </code> </code>
 +
 +To turn this into a physical address in the cartridge ROM's space, you should use the following equation: ''%%((addr & 0xFFFF) | ((addr & 0x7FF00000) >> 4)) & rom_mask%%''.
 +
 +The high four bits of the CPU address are ignored for physical ROM address transformations. This is because their purpose is to tell the compiler/linker at what address the CPU accesses the 64KB bank, not where it is physically stored on the cartridge. For example:
 +
 +  * The ELF address ''FFFF0000'' means ''ROM bank 7FF, offset 0000, accessed at F0000 by the CPU'',
 +  * The ELF address ''FFF30000'' means ''ROM bank 7FF, offset 0000, accessed at 30000 by the CPU''.
  
 ELF addresses ''0x00000000 - 0x0000FFFF'' correspond to IRAM addresses. ELF addresses ''0x00000000 - 0x0000FFFF'' correspond to IRAM addresses.
Line 44: Line 51:
 </code> </code>
  
-ELF addresses ''0x00010000 0x0001FFFF'' currently correspond to SRAM addresses, but this may be changed in a future version (to support >64KB SRAM), so please don't rely on it.+ELF addresses ''0x00n10000 0x00n1FFFF'' currently correspond to SRAM addresses (where ''n'' is the SRAM bank), but this may be changed in a future version, so please don't rely on it.
  
 ===== Address space (wwitch) ===== ===== Address space (wwitch) =====
wswan/guide/elf_quirks.1726997658.txt.gz · Last modified: 2024/09/22 09:34 by asie