Jump to content

Gotchas: Difference between revisions

m
Line 553:
 
=={{header|Z80 Assembly}}==
===JP (HL) Does Not Dereference===
For every other instruction, parentheses indicate a dereference of a pointer.
<lang Z80>LD HL,(&C000) ;load the word at address &C000 into HL
Line 560:
 
JP (HL) ;set the program counter equal to HL. Nothing is loaded from memory pointed to by HL.</lang>
 
This syntax is misleading since nothing is being dereferenced. For example, if HL equals &8000, then <code>JP (HL)</code> effectively becomes <code>JP &8000</code>. It doesn't matter what bytes are stored at &8000-&8001. In other words, <code>JP (HL)</code> ''does not dereference.''
 
Strangely enough, [[8080 Assembly]] uses a more sensible <code>PCHL</code> (set Program Counter equal to HL) to describe this function. So this gotcha is actually exclusive to Z80.
1,489

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.