Gotchas: Difference between revisions
Content added Content deleted
Puppydrum64 (talk | contribs) |
Puppydrum64 (talk | contribs) |
||
Line 406: | Line 406: | ||
System.print(rect.diagonal) // runtime error (if previous line commented out) |
System.print(rect.diagonal) // runtime error (if previous line commented out) |
||
// Rectangle does not implement 'sqrt(_)'</lang> |
// Rectangle does not implement 'sqrt(_)'</lang> |
||
=={{header|Z80 Assembly}}== |
|||
===JP (HL)=== |
|||
This is a bit of misleading syntax. For every other instruction, parentheses indicate a dereference of a pointer. |
|||
<lang Z80> |
|||
LD HL,(&C000) ;load the word at address &C000 into HL |
|||
LD A,(HL) ;treating the value in HL as a memory address, load the byte at that address into A. |
|||
EX (SP),HL ;exchange HL with the top two bytes of the stack. |
|||
JP (HL) ;set the program counter equal to HL. Nothing is loaded from memory pointed to by HL.</lang> |
|||
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. |