Question

As a first time MIPS user I seem to be confused. I have some classmate who have said that there XSPIM is big endian. However, in Linux it is little endian byte order. If MIPS can be little endian or big-endian. Is there a way to find out in XSPIM if it runs as little endian or big endian in your machine?

Was it helpful?

Solution

SPIM adopts the endian-ness of the machine on which it runs. (http://www.dsi.unive.it/~arcb/LAB/spim.htm#Byte%20Order)

Here's a little program to check the endian-ness of your machine:

.data
word:      .word 1
bigStr:    .asciiz "Big Endian\n"
littleStr: .asciiz "Little Endian\n"

.text

main:

la $t0 word
lb $t1 0($t0)

beqz $t1 bigEndian

littleEndian:

    la $a0 littleStr
    addi $v0 $zero 4
    syscall

    jr $ra

bigEndian:

    la $a0 bigStr
    addi $v0 $zero 4
    syscall

    jr $ra
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top