GB Programming: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
>Torchickens No edit summary |
>Torchickens |
||
Line 598: | Line 598: | ||
Because two hex digits mean one byte, $D3, as well as $61, is a byte. Since $D3 and H are leftmost in both cases, ld hl, $D361 is actually a shorter form of ld h, $D3 then ld l, $61. |
Because two hex digits mean one byte, $D3, as well as $61, is a byte. Since $D3 and H are leftmost in both cases, ld hl, $D361 is actually a shorter form of ld h, $D3 then ld l, $61. |
||
Let's say the following instruction is ld ($2315), hl. Applying the same logic would mean H's value would be stored at ($2315), and L's would be at ($2316). However, you just lost THE GAME |
Let's say the following instruction is ld ($2315), hl. Applying the same logic would mean H's value would be stored at ($2315), and L's would be at ($2316). However, you just lost THE GAME; because the z80 is a "little-endian" processor, L's value (the "little-end") is stored first, at ($2315). So ($2315) is $61, and ($2316) is $D3. |
||
Stop here, and remember this until it becomes natural to you. Because this "little-endian"ness is very tricky for beginners. It is ''very'' important when working with memory. |
Stop here, and remember this until it becomes natural to you. Because this "little-endian"ness is very tricky for beginners. It is ''very'' important when working with memory. |
||
Line 606: | Line 606: | ||
Initial values : |
Initial values : |
||
{| class="wikitable" |
{| class="wikitable" |
||
|$C000||$C001||$C002||$C003||$ |
|$C000||$C001||$C002||$C003||$C004||$C005||$C006||$C007||$C008||$C009||$C00A||$C00B||$C00C||$C00D||$C00E||$C00F |
||
|- |
|- |
||
|$00||$03||$4F||$C0||$DE||$57||$2A||$00||$FF||$01||$23||$34||$56||$78||$9A||$BC |
|$00||$03||$4F||$C0||$DE||$57||$2A||$00||$FF||$01||$23||$34||$56||$78||$9A||$BC |
||
Line 630: | Line 630: | ||
ld ($C00B), hl |
ld ($C00B), hl |
||
</pre> |
</pre> |
||
==Stacks== |
==Stacks== |