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(); }...
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.....
I have to do the following MIPS coding assignment. Question 1 Write a MIPS program that...
I have to do the following MIPS coding assignment. Question 1 Write a MIPS program that meets the following requirements (NOTE: your program statements should follow the order of the requirements and each requirement should correspond to only one assembly instruction): Loads the hexadecimal equivalent of 23710 into register 13 using an immediate bitwise OR instruction Loads the hexadecimal equivalent of 183410 into register 17 using an immediate bitwise OR instruction Performs the bitwise AND operation on the operands stored...
Coding Problem 1: In this program, you are asked to write a program in assembly (MIPS)...
Coding Problem 1: In this program, you are asked to write a program in assembly (MIPS) which works as a simple calculator. The program will get two integer numbers, and based on the requested operation, the result should be shown to the user. a. The program should print a meaningful phrase for each input, and the result. i. “Enter the first number” ii. “Enter the second number” iii. “Enter the operation type” iv. “The result is” b. The user should...
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...
Write a MIPS assembly program that prompts the user first for a string, then for a...
Write a MIPS assembly program that prompts the user first for a string, then for a character. The program should then search the string for the character and print out the number of times the character appears in the string. You can use as many restrictions as you want, just be sure to list them. You must allocate space in the .data segment of your program for the user string.
Write a MIPS program that executes the statement: s = (a + b) – (c +...
Write a MIPS program that executes the statement: s = (a + b) – (c + 101), where a, b, and c are user provided integer inputs, and s is computed and printed as an output. Answer the following: a. Suppose the user enters a = 5, b = 10, and c = -30, what is the expected value of s? b. Which instruction in your program computed the value of s and which register is used? c. What is...
write a mips program to find the number of elements of the array that are divisible...
write a mips program to find the number of elements of the array that are divisible by 3.
Write a simple MIPS program that asks the user to input a string and then a...
Write a simple MIPS program that asks the user to input a string and then a character. The program should then count how many times that character appears in the string and print out that value. Please use comments.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT