Jump anywhere: Difference between revisions

m
Line 1,965:
* &nbsp; <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>.
* &nbsp; <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>.
 
 
Branches apply a signed offset to the current program counter. They are limited only by distance; scope does not exist in assembly. Typically you do not have calculate this offset yourself. The assembler will abstract this out of the hardware and let you use a label like you would with a <code>j</code>. The actual offset is calculated during the assembly process, which means you don't have to measure it yourself by counting bytes.
1,489

edits