GB Programming: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
>ISSOtm (→Flags: Remove flags that don't exist on Game Boy) |
>Bbbbbbbbba m (→A special jp: Change "jp (hl)" to "jp hl") |
||
Line 770: | Line 770: | ||
There is one special case of jp, though ! |
There is one special case of jp, though ! |
||
{| class="wikitable" |
{| class="wikitable" |
||
|JP |
|JP HL |
||
|Has execution jumping to the address pointed to by hl.<br/>Does not accept any conditionals. |
|Has execution jumping to the address pointed to by hl.<br/>Does not accept any conditionals. |
||
|} |
|} |
||
Line 776: | Line 776: | ||
<pre> |
<pre> |
||
ld hl, $2457 |
ld hl, $2457 |
||
jp |
jp hl |
||
</pre> |
</pre> |
||
will jump to $2457. Some might argue that "jp $2457" is better, as it'd save 1 byte and preserve the hl register. |
will jump to $2457. Some might argue that "jp $2457" is better, as it'd save 1 byte and preserve the hl register. |
||
However, jp |
However, "jp hl" is used to do dynamic jumps: "jp hl" may jump to a different location every time it is ran. When doing "static" (ie. always the same) jumps, it '''is''' better to use jp $xxyy. "jp hl" mostly used with function pointer tables - we'll see that later. |
||
===Comparing stuff=== |
===Comparing stuff=== |