Jump anywhere: Difference between revisions
Content added Content deleted
Puppydrum64 (talk | contribs) m (→Long Jump) |
Puppydrum64 (talk | contribs) |
||
Line 1,968: | Line 1,968: | ||
* <code>jal 0xNNNNNNNN</code> sets the program counter equal to <code>0xNNNNNNNN</code>, and moves the old program counter plus 8 into register <code>$ra</code>. |
* <code>jal 0xNNNNNNNN</code> sets the program counter equal to <code>0xNNNNNNNN</code>, and moves the old program counter plus 8 into register <code>$ra</code>. |
||
* <code>jalr $NN,0xNNNNNNNN</code> sets the program counter equal to <code>0xNNNNNNNN</code> and moves the old program counter plus 8 into register <code>$NN</code>. |
* <code>jalr $NN,0xNNNNNNNN</code> sets the program counter equal to <code>0xNNNNNNNN</code> and moves the old program counter plus 8 into register <code>$NN</code>. |
||
Most of the time you won't be jumping to a specific address. You can place a label before any instruction, and a jump to that label is the same as a jump to the address of that instruction. |
|||
<lang mips>j GoHere |
|||
nop ;branch delay slot. This instruction would get executed DURING the jump. We'll make that instruction a NOP, which does nothing. |
|||
GoHere |
|||
addiu $t0,1 ;this instruction is the first one executed after jumping.</lang> |
|||