Question

In: Computer Science

Write a MIPS assembly program to implement each of the following operations. 1. DM[6892] = DM[6884]...

Write a MIPS assembly program to implement each of the following operations.

1. DM[6892] = DM[6884]

(Copy the 32-bit data at data memory address 6884 to data memory address 6892.)

2. DM[7968] = DM[6796] + DM[6800]

(Add the 32-bit data at data memory address 6792 and the 32-bit data at data memory address 6800, then store the sum into data memory address 7968.)

Solutions

Expert Solution

Answer : Given data

1. DM[6892] = DM[6884]

(Copy the 32-bit data at data memory address 6884 to data memory address 6892.)

li $t0,6892 #load destination address
li $t1,6884 #load source address
lw $t2,0(t1) #load data from source to t2
sw $t2,0(t0) #store data to destination

Output screenshot:

Before:

Used addresses 10010000 and 10010008 instead of 6892 and 6884

After:Please note that the source remains the same

2. DM[7968] = DM[6796] + DM[6800]

(Add the 32-bit data at data memory address 6792 and the 32-bit data at data memory address 6800, then store the sum into data memory address 7968.)

Code:

li $t0,0x7968 #load destination address
li $t1,0x6796 #load source address 1
li $t2,0x6800 #load source address 2
lw $t3,0($t1) #load data 1
lw $t4,0($t2) #load data 2
add $t4,$t3,$t4 #add data1 and data2
sw $t4,0($t0) #store sum to destination

Output screenshot:

Used addresses 10010000(dest),10010008 and 10010010

Before:

After:

______________THE END______________


Related Solutions

Write a MIPS assembly program to implement each of the following operations. 1. DM[6892] = DM[6884]...
Write a MIPS assembly program to implement each of the following operations. 1. DM[6892] = DM[6884] (Copy the 32-bit data at data memory address 6884 to data memory address 6892.) 2. DM[7968] = DM[6796] + DM[6800] (Add the 32-bit data at data memory address 6792 and the 32-bit data at data memory address 6800, then store the sum into data memory address 7968.)
Use MARS to write and simulate a MIPS assembly language program to implement the strlen function....
Use MARS to write and simulate a MIPS assembly language program to implement the strlen function. The program should ask for a user's input and print the length of the user's input. Write the main function to call strlen. The main function should: - Prompt the user for input - Pass that input to strlen using registers $a0. - Preserve (i.e. push onto the stack) any T registers that the main function uses. The strlen function should: - Preserve any...
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...
Write a program in MIPS assembly language to perform the calculation of the following equation and...
Write a program in MIPS assembly language to perform the calculation of the following equation and save the result accordingly:    f = 5x + 3y + z Assumptions: - Registers can be used to represent variables x, y, z, and f - Initialize x, y, and z to values of your choice. f can be initialized to zero. - Use comments to specify your register usage and explain your logic
Write the MIPS assembly codes to implement the following function: copy a block of words from...
Write the MIPS assembly codes to implement the following function: copy a block of words from one address to another. Assume that the starting address of the source block be in register $t1 and that the destination address be in $t2. The instruction also requires that the number of words to copy in $t3 (which is >0, that means how many words are needed to copy). Furthermore, assume that the values of these registers as well as register $t4 can...
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.
MIPS Assembly LanguageWrite a MIPS assembly language program that asks the user toinput an...
MIPS Assembly LanguageWrite a MIPS assembly language program that asks the user to input an integer and then prints out a string that shows how that integer should be encoded using 16 bits. Your program should handle both positive and negative valued inputs. Your program should also print out an error message if the given input cannot be expressed as a 16 bit signed integer.As an example, if the input is 12, your program should output “0000000000001100”. If the input...
Write a MIPS assembly language program that implements the following pseudo-code operation: result = x +...
Write a MIPS assembly language program that implements the following pseudo-code operation: result = x + y – z + A[j] x and y should be in reserved memory words using the .word directive and labeled as x and y. Initialize x=10 and y=200. Read in z from the console. Input the value -8. This is the value for z, not for –z. Store this value in memory with the label z. To begin, you could just initialize z to...
Assignment Description: Write a MIPS assembly language program that adds the following two integers and displays...
Assignment Description: Write a MIPS assembly language program that adds the following two integers and displays the sum and the difference. In the .data section, define two variables num1 and num2 both words. Initialize num1 to 92413 10 and num2 to D4B 16 (use 0xD4B to initialize, Note that D4B is a hexadecimal number). Your main procedure/function should load the values of num1 and num2 into two temporary registers, and display them on the console window. Then add the values...
Write a mips assembly language program to ask the user to enter two integers A and...
Write a mips assembly language program to ask the user to enter two integers A and B and then display the result of computing the expression: A + 2B - 5.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT