Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
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

Need a better way to load code into RAM #41

Open
velipso opened this issue Jun 1, 2023 · 0 comments
Open

Need a better way to load code into RAM #41

velipso opened this issue Jun 1, 2023 · 0 comments

Comments

@velipso
Copy link
Owner

velipso commented Jun 1, 2023

Now that we can allocate structs to IWRAM or EWRAM, it would be nice to have the equivalent for code:

.begin irqNone = iwram
  .arm
  mov   r0, #0x04000000
  ldr   ip, [r0, #0x200]!
  and   r2, ip, ip, lsr #16
  strh  r2, [r0, #2]
  ldr   r3, [r0, #-0x208]
  orr   r3, r3, r2
  str   r3, [r0, #-0x208]
  bx    lr
.end

This should expose:

.printf "%08X", irqNone       // the location in IWRAM
.printf "%08X", irqNone._rom  // the location in ROM
.printf "%d", irqNone._bytes  // the size of the code

So it is up to the user to memcpy the function from ROM to IWRAM, then they can bl irqNone.

Larger blocks should be supported, and layering too (eventually):

.begin iwramCode = iwram(-1) // all layers
  .include './saveCopy.gvasm'
  .include './sndFrame.gvasm'
  .embed './silence.gvsong'
.end
.begin iwramTemp = iwram(1) // layer 1 only
  .include './saveInit.gvasm'
  .include './sndInit.gvasm'
.end
.struct Player = iwram(2) // layer 2 only
  .i32 health
.end

This means Player will overlap iwramTemp. Also, you can copy all of iwramCode in one memcpy.

Then, iwramCode.saveCopy should point to RAM. Maybe there should be iwramCopy._rom.saveCopy too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant