Day 19 - The SWI Instruction
You may be wondering why I didn't tell about SWI yesterday, I've done it this
way just mainly to have a logical one sub-topic at a time approach. SWI stands for
SoftWare Interrupt (I think) and is used to call BIOS functions.
Patater GBAGuy Mirror
How to use SWI
SWI is used by ... oh, heck here's the syntax:
swi 0x60000 ; will call Divide
Divide is SWI #6, to call a function, make it's number hex and put 4 zeros after it,
I don't know what the zeros have to do with it, but it won't work without the zeros.
You might be wondering how I knew Divide was #6, go here and
look under "BIOS".
What SoftReset does is, well... reset the GBA, starting code at 0x8000000 (ROM)
or 0x2000000 (RAM, some people move their code to here on startup) depending on some
memory register, it's 0 by default and 0 means 0x8000000 so we don't have any problems
here. Let's call it! :
swi 0x00000 ; SoftReset is #0 , and then 4 zeros after it.
Easy ain't it!?
Day In Review
Tomorrow I'll prove that this does work by calling Divide and putting
the value in Work RAM so you can use Memory Viewer in VisualBoy Advance to verify
the correct answer.
Hope you're excited, I sure am!,
-Mike H a.k.a GbaGuy
Intro - Day 20