Question

Find out how to populate the registers with appropriate parameters to swap the values 4 and...

Find out how to populate the registers with appropriate parameters to swap the values 4 and 5 in the array arr. What are the instructions that will populate the general registers with the appropriate values?

arr:    .word     1,2,3,4,5

To populate r0:
To populate r1:
To populate r2:

0 0
Add a comment Improve this question Transcribed image text
Answer #1

You dint mention any specific assembaly language. So make concept cleare I used MIPS

t0,t1 and t2 gemnral purpose registers are used for r0,r1 and r2 respectively.

I run it on mars simulator. You can see the value by running step by step

if output is4554 means 45 before swapping and 54 after swaping

..........................cade..............................

.data
arr: .word 1,2,3,4,5
.text
addi $t0,$zero,12 # t0 represents r0 as array index t0=12 as 4 is at 4th possition
lw $t1,arr($t0)
#printing initial value of at location 4 you can think of arr[3]
lw $a0,arr($t0)
li $v0,1
syscall
addi $t0,$t0,4
lw $t2,arr($t0)# $t2 as r2
#printing initial value of at location 5 you can think of arr[4]
lw $a0,arr($t0)
li $v0,1
syscall
#swapping
sw $t1,arr($t0)
subi $t0,$t0,4
sw $t2,arr($t0)

#After swapping printing value
#printing initial value of at location 4 you can think of arr[3]
lw $a0,arr($t0)
li $v0,1
syscall
addi $t0,$t0,4
#printing initial value of at location 5 you can think of arr[4]
lw $a0,arr($t0)
li $v0,1
syscall

.........................end............................

........................output.............................

히 X CAUsersSantlal PrajapatiDesktopswapHomeworkLibasm-MARS 4.5 File Edit u Settings Tools Help - Run speed at max (no interaction E

Add a comment
Know the answer?
Add Answer to:
Find out how to populate the registers with appropriate parameters to swap the values 4 and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Exercise 1 (9 pts) We have seen that ARM has 16*32 bits registers (plus floating point...

    Exercise 1 (9 pts) We have seen that ARM has 16*32 bits registers (plus floating point registers) There is also a status register: CPSR. It contains, among other things, the following important status bits N Negative, set when the result of an arithmetic operation is negative (according to the two's complement encoding of the natural numbers . Z- Zero, set when the result of an operation is zero . C Carry, set when an operation results in a carry bit...

  • Ox00000000. Initially N-Z=C=V=0. Find the new values ofr3, N, Z, C, and V running each following...

    Ox00000000. Initially N-Z=C=V=0. Find the new values ofr3, N, Z, C, and V running each following instructions 5. Suppose r0 0XFFFFFFFF, rl = 0x00000001 and r2 independently (i.e. same starting values for each case). Not graded: check results with TIVA. ADDS r3, r0, r2 а. b. SUBS r3, r1, r0 ; note: not the LSLS instruction r3, r0, #1 LSL с.

  • name: Problem 4. [20 pts] Development Flow - Draw a typical developme explain each step. (What happens when your cod...

    name: Problem 4. [20 pts] Development Flow - Draw a typical developme explain each step. (What happens when your code goes from.c file to celf fle to a board) hen nt flow for an ARM processor and Problem 5. [30 pts] Assembly- The following values are kept in memory starting at ex8003000. Write all the assembly program that reads the values from the memory and finds the maximum and minimum of these numbers. Write the results to R1 and R2...

  • How would answer question #4 of this ? #1 and 2 #include<iostream> #include <fstream> using namespace...

    How would answer question #4 of this ? #1 and 2 #include<iostream> #include <fstream> using namespace std; void read(int arr[]) {    string line;    ifstream myfile("input.txt");    int i = 0;    if (myfile.is_open())    {        while (getline(myfile, line))        {            arr[i];            i++;        }        myfile.close();    } } void output(int arr[]) {    ofstream myfile("output.txt");    if (myfile.is_open())    {        int i = 0;...

  • 1) Assume the registers are initialized to the indicated values: Se al A c and code...

    1) Assume the registers are initialized to the indicated values: Se al A c and code frogments MUST use 32 ぁ ar movennes (anor be "nedfra-ne ibrary function or procedural calls ino- Pe Peue c for ll codr ond code frogments only othu ey document your code with Comments unless the code size is Drow Fow Chort for any flow of control involving branches and loops Use PoCedures as modules to organize most of the code and code fragments. In...

  • Please, I need help, I cannot figure out how to scan variables in to the function...

    Please, I need help, I cannot figure out how to scan variables in to the function prototypes! ******This is what the program should look like as it runs but I cannot figure out how to successfully build the code to do such.****** My code: #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <math.h> #include <conio.h> float computeSeriesResistance(float R1, float R2, float R3); float computeParallelResistance(float R1, float R2, float R3); float computeVoltage(int current, float resistance); void getInputR(float R1, float R2, float R3); void getInputCandR(int...

  • ASSEMBLY LANGUAGE The matrix (two-dimensional array) with ROWS and COLS dimensions of integer values is given....

    ASSEMBLY LANGUAGE The matrix (two-dimensional array) with ROWS and COLS dimensions of integer values is given. Perform various matrix processing activities according to the algorithms below. Store the results into the output vector (one-dimensional array) with appropriate size. For Grade 7) Count the number of odd values (n mod 2 <> 0) for each row. For Grade 9) Calculate the sum of positive values for each column. To obtain inputs and return the results, define appropriate type C/C++ functions. Please...

  • 4. For the amplifier in the figure below use the parameters in the table: +Vcc Re VBE- 0.7V, Ri- ...

    4. For the amplifier in the figure below use the parameters in the table: +Vcc Re VBE- 0.7V, Ri- 1002, R1-160k2, R2-320k2 R3-200k2, R6-40 k2, Rc-60k2, Vcc- 12V, Ry Do a) Draw the DC equivalent circuit and calculate the Q-point. c) Draw the AC equivalent circuit with the small signal model for the transistor. d) Calculate the voltage gain, Av-Vo/vi. Assume ro infinite. e) Draw the circuit to find the amplifier input resistance (Rin). Calculate Rin f Draw the circuit...

  • Trying to figure out how to find absolute extreme values of a function on an interval....

    Trying to figure out how to find absolute extreme values of a function on an interval. treme values of the function on the intera Find the absolute extreme values of the function 5) f(O) = sin(8 +3,0 ses **

  • Page 4 3. Pipeline is an instruction-level parallel processing techni microprocessor systems. The instruction throughput can be dramaticallu increased by this key technique. However, there are so...

    Page 4 3. Pipeline is an instruction-level parallel processing techni microprocessor systems. The instruction throughput can be dramaticallu increased by this key technique. However, there are so called hazard problems. (a) Branch instruction will introduce problems to a pipelined instruction execution. Explain how this may happen in a DLX machine, and state ONE strategy that can be used to resolve the problem (6 marks) (b) Data hazards occur in instruction execution in a pipelined machine. () What is meant by...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT