Host introspection: Difference between revisions
Content added Content deleted
Puppydrum64 (talk | contribs) mNo edit summary |
Puppydrum64 (talk | contribs) No edit summary |
||
Line 13: | Line 13: | ||
See also: [[Variable size/Get]] |
See also: [[Variable size/Get]] |
||
=={{header|68000 Assembly}}== |
|||
It's not possible to get the word size without knowing it in advance. But the 68000's big-endian nature can easily be proven even if the programmer didn't know that it was big-endian already. |
|||
Code is called as a subroutine, i.e. <code>JSR TestEndianness</code>. Hardware-specific print routines are unimplemented. |
|||
<lang 68000devpac>TestEndianness: |
|||
LEA UserRam,A0 |
|||
MOVE.L #$0000FFFF,(A0) |
|||
MOVE.B (A0),D0 ;read the 0th byte stored |
|||
BEQ isBigEndian ;if this was little endian, the bytes would be stored FF FF 00 00 |
|||
;must have been little-endian. Spoiler alert: execution will never reach here |
|||
LEA LittleEndianMessage,A3 |
|||
JSR PrintString |
|||
rts |
|||
isBigEndian: |
|||
LEA BigEndianMessage,A3 |
|||
JSR PrintString |
|||
rts |
|||
BigEndianMessage: |
|||
DC.B "BIG-ENDIAN",0 |
|||
EVEN |
|||
LittleEndianMessage: |
|||
DC.B "LITTLE-ENDIAN",0 |
|||
EVEN</lang> |
|||
=={{header|Ada}}== |
=={{header|Ada}}== |