Host introspection: Difference between revisions

No edit summary
Line 163:
12 PRINT "LITTLE-ENDIAN"</lang>
 
=={{header|ARM Assembly}}==
The word size of the ARM is 32-bit, which can't really be proven without knowing it ahead of time.
 
The ARM CPU's endianness can be set to either little-endian or big-endian. Not all ARM CPUs have this feature, but this test will work regardless of whether the endian switch features exist on any particular model or not. The easiest way to test endianness is to write a word to RAM, then read the 0th byte from that memory location and see what it is. (The example below uses VASM syntax.)
 
<lang ARM Assembly>EndianTest:
mov r0,#0xFF
mov r1,#0x02000000 ;an arbitrary memory location on the Game Boy Advance.
;(The GBA is always little-endian but this test doesn't use that knowledge to prove it.)
str r0,[r1] ;on a little-endian CPU a hexdump of 0x02000000 would be: FF 00 00 00
;on a big-endian CPU it would be: 00 00 00 FF
ldrB r0,[r1] ;load just the byte at 0x02000000. If the machine is big-endian this will load 00; if little-endian, 0xFF.
cmp r0,#0
beq isBigEndian
;else, do whatever is needed to display "little-endian" to the screen. This part isn't implemented.</lang>
=={{header|Babel}}==
<lang babel>main :
1,489

edits