Question

In: Computer Science

Write a MIPS program to check if computer is a big-endian or little-endian system. This must...

Write a MIPS program to check if computer is a big-endian or little-endian system. This must be done in MIPS assembly language.

Solutions

Expert Solution

Greetings!!

Little endian:Lower byte of the data is stored at lower end of the memory.

Example,data 11223344 in a little endian machine is stored as:

2000:44

2001:33

2002:22

2003:11

Big endian:Lower byte of the data is stored at higher end of the memory

Example,data 11223344 in a little endian machine is stored as:

2000:11

2001:22

2002:33

2003:44

MIPS can use either little or big endian and is machine specific.

Code:

Logic used:First 1 word of data is stored and then read the data byte by byte along with the address and then observing the address and byte so that the endianess can be determined

.data

num: .word 0

message: .asciiz " is stored at address "

nl: .asciiz "\n"

.text

#STORE NUMBER 11223344 INTO MEMORY

li $t0,0x11223344

sw $t0,num

#GET THE ADDRESS OF THE MEMORY

la $t0,num

li $t2,0

loop:

beq $t2,4,end

#LOAD FIRST BYTE FROM THE MEMORY

lb $t1,0($t0)

#PRINT THE BYTE

move $a0,$t1

li $v0,1

syscall

#PRINT “IS STORED AT ADDRESS” MESSAGE

la $a0,message

li $v0,4

syscall

#PRINT THE BYTE ADDRESS

move $a0,$t0

li $v0,1

syscall

#PRINT NEWLINE

la $a0,nl

li $v0,4

syscall

addi $t0,$t0,1

addi $t2,$t2,1

#REPEAT

j loop

end:

#TERMINATION

li $v0,10

syscall

Screenshot:

Lower byte of the data is stored at the lower end of the memory and hence the system used little endian scheme.

[Please note that the output is in decimal and the corresponding hex values are given in red colour]

Hope this helps


Related Solutions

what is the different between little endian and big endian on mips ?
what is the different between little endian and big endian on mips ?
need c++ format 1.Check endianness on your system . Either Big or Little Endian 2.Convert a...
need c++ format 1.Check endianness on your system . Either Big or Little Endian 2.Convert a decimal number to 2’s complement (32bits) E.g., 5 -> 0000 0000 0000 0000 0000 0000 0000 1001    here is the start code ********************************************************* #include <iostream> using namespace std; void endianness(); void get_two_complement(); void print_menu(); int main(){ int menu; do { print_menu(); cout<< "Enter a number to select the menu: "; cin >>menu; if(menu == 1){ endianness(); } else if (menu == 2){ get_two_complement(); }...
need c++ format 1.Check endianness on your system . Either Big or Little Endian 2.Convert a...
need c++ format 1.Check endianness on your system . Either Big or Little Endian 2.Convert a decimal number to 2’s complement (32bits) E.g., 5 -> 0000 0000 0000 0000 0000 0000 0000 1001    here is the start code ********************************************************* #include <iostream> using namespace std; void endianness(); void get_two_complement(); void print_menu(); int main(){ int menu; do { print_menu(); cout<< "Enter a number to select the menu: "; cin >>menu; if(menu == 1){ endianness(); } else if (menu == 2){ get_two_complement(); }...
Computer Architecture: Write a MIPS program to compute f = g - (f + 5) Assume...
Computer Architecture: Write a MIPS program to compute f = g - (f + 5) Assume registers $to, $s1 hold values for g and f respectively. The program should display the following prompts and read value entered by the user “Enter a value for f:" “Enter a value for g:" The program the prints: "Answer for f = g - (f + 5):" The program should repeat the above steps 3 times for each input pair, f and g Make...
In Python: Program. At the university, passwords for the campus computer system must meet the following...
In Python: Program. At the university, passwords for the campus computer system must meet the following requirements: The password must be at least seven characters long. It must contain at least one uppercase letter. It must contain at least one lowercase letter. It must contain at least one numeric digit. It must include two special symbols It must contain no spaces Start by translating the pseudocode below into a python function. Add the last two requirements to your function.
This document describes a computer program you must write in Python and submit to Gradescope. For...
This document describes a computer program you must write in Python and submit to Gradescope. For this project, the program will simulate the operation of a vending machine that sells snacks, accepting coins and dispensing products and change. In an actual vending machine, a program running on an embedded computer accepts input from buttons (e.g. a numeric keypad) and devices such as coin acceptors, and its output consists of signals that control a display, actuate motors to dispense products, etc.....
This document describes a computer program you must write in Python and submit to Gradescope. For...
This document describes a computer program you must write in Python and submit to Gradescope. For this project, the program will simulate the operation of a vending machine that sells snacks, accepting coins and dispensing products and change. In an actual vending machine, a program running on an embedded computer accepts input from buttons (e.g. a numeric keypad) and devices such as coin acceptors, and its output consists of signals that control a display, actuate motors to dispense products, etc.....
Check a number if the Database. Write MIPS assembly code for the following requirements. Given the...
Check a number if the Database. Write MIPS assembly code for the following requirements. Given the following code for the data segment. .data Database: .word 1,2,3,4,5,6,7,8,9,10 Ask user to type in a random integer number using syscall #5. Check if this number is within the database or not, print out "number found!" if the number was foudn in the database, print out "No such number found in database!" if not.
Java Question here. Need to write a program that will check ANY operating system and find...
Java Question here. Need to write a program that will check ANY operating system and find out OS name and then write that info to a file in the data directory. here is where I am so far: public void writeOSName() { // TODO write the name of the operating system running this code to a file // in the data directory called os.txt // The file has to be written in the data directory of this project // Use...
Please write the answer on a computer not on a paper I'm a little confused as...
Please write the answer on a computer not on a paper I'm a little confused as to what exactly I'm researching and writing about. If someone could break it down and give me a few minor examples so I can structure the essay around it I would really appreciate it: (Intel 80x86, ARM, MIPS R4000 )Write a two page report on the similarities and differences are of these architectures. Include in your report what you find interesting about the architectures...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT