Day 5




Subroutines


	Today is going to be short (maybe) and be about subroutines.
The N64 CPU's subroutine call instruction is JAL (Jump And Link) it works
like so:

	JAL LABEL  ; jump to LABEL, putting return address in ra.
	NOP        ; you should put a NOP after JALs also. Delay Slot?

Then at LABEL you have:
	
LABEL:
	NOP ; Delay Slot NOP
	JR ra  ; Jump Register ra (that contains return address)

Note that you can't nest subroutine calls, as a subroutine call will erase
the old return value in ra. The GBA is also like that, the NES is not.

It would help if there was a built-in stack. (Is there?)

The LUI Instruction

I'm not sure what the LUI instruction does, but I'm fairly sure that it loads the second 16bits of a register, like so: LI t1,0 ; t1 = $00000000 LUI t1,$a440 ; after instruction, r1 = $a4400000 Simple enough, if I didn't miss anything.

This Day In Review

Tomorrow, we'll definitely put a pic on the screen! I Can't Wait!, - GbaGuy
Intro - Day 6

Patater GBAGuy Mirror
Contact