Question

In: Computer Science

Write a MIPS program that always checks the bit 0 of a memory data at address...

Write a MIPS program that always checks the bit 0 of a memory data at address 0x0BF81234. If it is equal to one add nth and (n+1)th elements of an array and store it to memory address 0x0BF85678 . Suppose $t0 contains the address of the 0th element of an array of 32-bit data and $t1 = n.

Solutions

Expert Solution

Greetings!!

Code:

li $s0,0x0BF81234                 #address given

lw $t0,0($s0)                          #load word from the given address

andi $t2,$t0,0x00000001        #check whether the LSB is 1

bne $t2,1,done                        #if the LSB is 0, goto label done

mul $t1,$t1,4                          #if the LSB is 1, calculate the offset of nth element

add $s0,$s0,$t1                       #calculate the address of the nth element

lw $t3,0($s0)                          #read the nth element

lw $t4,4($s0)                          #read the n+1 th element

add $t3,$t3,$t4                        #add nth and n+1 th elements

li $s0,0x0BF85678                 #load the given destination address

sw $t3,0($s0)                          #store the sum to the given address

done:

addi $v0,$0,10                        #termination

syscall

Hope this helps


Related Solutions

Using MARS write a MIPS assembly language program to prompt the user to input two 32-bit...
Using MARS write a MIPS assembly language program to prompt the user to input two 32-bit integers X and Y (X and Y can be prompted separately or at the same time), get them from the user then store them in memory locations labeled X and Y respectively. The program then loads X and Y from the main memory to registers, calculates the sum of them (i.e. X + Y) and store the sum into a memory location labeled S....
Count the number of 1’s and 0’s Write a MIPS program that will ask the user...
Count the number of 1’s and 0’s Write a MIPS program that will ask the user to enter an integer, and then output the number of 1’s and 0’s that are present in the integer’s signed 32-bit binary representation. For example, 15 has a binary representation of 0000 0000 0000 0000 0000 0000 0000 1111, which has 28 zeroes and 4 ones. We have provided you the starter code that deals with the input/output logic. The integer input is saved...
Consider a memory system with a 14 bit long address. Produce the answer to each of...
Consider a memory system with a 14 bit long address. Produce the answer to each of the following parts using hexadecimal numbers. a. There is a 1.5k byte RAM device, starting at address $200. What is its last address? b. There is a 1k byte EPROM device, starting at address $900.What is is last address? c. There is a 7k byte ROM device, its last address is at the highest system address. What is its first address? d. Use your...
Suppose the memory cells at address 0x00 through 0x0D in the vole contain the following bit...
Suppose the memory cells at address 0x00 through 0x0D in the vole contain the following bit patterns: Address. contents 0x00. 0x20 0x01. 0x04 0x02 0x21 0x03. 0x01 0x04. 0x40 0x05 0x12 0x06. 0x51 0x07. 0x12 0x08 0xB1 0x09. 0x0C 0x0A. 0xB0 0x0B. 0x06 0x0C. 0xC0 0x0D. 0x00 Assume that the machine starts with its program counter contaning 0x00. WHat bit pattern will be in register 0x00 when the machine Halts? WHat bit pattern will be in register 0x01 when the...
Write a program that asks the user for an integer. The program checks and prints to...
Write a program that asks the user for an integer. The program checks and prints to the screen whether the number is prime or not. For example, if user enters 17, the program should print “17 is prime”; if the user enters 20, the program should print “20 is not prime”. please do it with a “ while Loop”, Thanks..
3.21 [10] <§3.5> If the bit pattern 0×0C000000 is placed into the Instruction Register, what MIPS...
3.21 [10] <§3.5> If the bit pattern 0×0C000000 is placed into the Instruction Register, what MIPS instruction will be executed? 3.22 [10] <§3.5> What decimal number does the bit pattern 0×0C000000 represent if it is a floating point number? Use the IEEE 754 standard. Given the following 32-bit binary sequences representing single precision IEEE 754 floating point numbers: a = 0100 0000 1101 1000 0000 0000 0000 0000 b = 1011 1110 1110 0000 0000 0000 0000 0000 Perform the...
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...
JAVA Write a program that checks the spelling of words in a document. This program uses...
JAVA Write a program that checks the spelling of words in a document. This program uses two text files: A dictionary file containing all known correctly spelled words, and A document to be spell-checked against the dictionary. As the document to be spell checked is read, each of its words is checked against the dictionary words. The program determines whether each word is misspelled. Misspelled words are recorded. is spelled correctly. Correctly spelled words are recorded and their frequency counted....
Design and write a verilog code and testbench for a 16-bit RISC MIPS Processor on vivado...
Design and write a verilog code and testbench for a 16-bit RISC MIPS Processor on vivado and show waveform.
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT