Host introspection: Difference between revisions
Content added Content deleted
Puppydrum64 (talk | contribs) |
Puppydrum64 (talk | contribs) |
||
Line 1,393: | Line 1,393: | ||
Little endian |
Little endian |
||
</pre> |
</pre> |
||
=={{header|Z80 Assembly}}== |
|||
The Z80's word size is 16-bit, and you'd know this ahead of time simply because there aren't any commands that work with values any larger than that. It's also little-endian, but this can be proven without knowing it in advance using a simple store and load test. |
|||
<lang z80>EndianTest: |
|||
ld hl,&8000 |
|||
ld (&C000),hl ;store &8000 into memory. |
|||
ld a,(&C000) ;loads the byte at &C000 into A. If the Z80 were big-endian, A would equal &80. But it equals zero. |
|||
or a ;still, we need to pretend we don't already know the result and compare A to zero. |
|||
jr z,LittleEndian ;handle the case where Z80 is little-endian (which it is, so this branch is always taken.) |
|||
;else, do whatever you would do to show that the Z80 is big-endian (it isn't, so execution never reaches here.)</lang> |