void swap (int arr[], int i, int j) { int temp = arr[i]; arr[i] = arr[j]; arr[j] } temp; void selectionSort (int arr[], int n) { for (int i = 0; i < n 1; i++) { int min i; for (int j=i+1; j < n; j++) { if (arr[j] arr[min]) min = j; swap (arr, min, i); } } } int main() { int arr[] = { 3, 5, 8, 4, 1, 9, -2 }; int n = 7; selectionSort (arr, n); return 0; } 1. Tranlaste the above C program to MIPS codes, suppose the starting address of codes is binary number 1000, the starting address of data is binary number 100000. 2. Translate the first MIPS codes of "if (arr[j] Add ALU (MAX- Add result Shift RegDst Branch left 2 MemRead Instruction [31-26] MemtoReg Control ALUOP MemWrite ALUSrc RegWrite Instruction [25-21] Read Read address register 1 Read Instruction [20-16] data 1 Read Instruction register 2 0 [31-0] M Read Write data 2 Instruction Instruction [15-11] x register memory 1 Write MJX result Zero ALU ALU Read Address data data Registers Data Write data memory 16 Instruction [15-0] Sign- extend Instruction (5-0) 32 32 ALU control Ox

New Perspectives on HTML5, CSS3, and JavaScript
6th Edition
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Patrick M. Carey
Chapter14: Exploring Object-based Programming: Designing An Online Poker
Section14.1: Visual Overview: Custom Objects, Properties, And Methods
Problem 7QC
icon
Related questions
Question
Help with question #3 please
void swap (int arr[], int i, int j)
{
int temp = arr[i];
arr[i] = arr[j];
arr[j]
}
temp;
void selectionSort (int arr[], int n)
{
for (int i = 0; i < n 1; i++) {
int min i;
for (int j=i+1; j < n; j++) {
if (arr[j] arr[min])
min = j;
swap (arr, min, i);
}
}
}
int main()
{
int arr[] = { 3, 5, 8, 4, 1, 9, -2 };
int n = 7;
selectionSort (arr, n);
return 0;
}
1. Tranlaste the above C program to MIPS codes, suppose the starting address of codes is binary
number 1000, the starting address of data is binary number 100000.
2. Translate the first MIPS codes of "if (arr[j] <arr [min]) min j;" to Machine lan-
guage codes
3. Run the above machine codes at the first time on Figure 4.17, refer to Figure 4.19, 4.20, 4.21,
4.24. Label the values on all the input and output lines in the following datapath diagram.
2
Transcribed Image Text:void swap (int arr[], int i, int j) { int temp = arr[i]; arr[i] = arr[j]; arr[j] } temp; void selectionSort (int arr[], int n) { for (int i = 0; i < n 1; i++) { int min i; for (int j=i+1; j < n; j++) { if (arr[j] arr[min]) min = j; swap (arr, min, i); } } } int main() { int arr[] = { 3, 5, 8, 4, 1, 9, -2 }; int n = 7; selectionSort (arr, n); return 0; } 1. Tranlaste the above C program to MIPS codes, suppose the starting address of codes is binary number 1000, the starting address of data is binary number 100000. 2. Translate the first MIPS codes of "if (arr[j] <arr [min]) min j;" to Machine lan- guage codes 3. Run the above machine codes at the first time on Figure 4.17, refer to Figure 4.19, 4.20, 4.21, 4.24. Label the values on all the input and output lines in the following datapath diagram. 2
сл
PC
4->
Add
ALU
(MAX-
Add result
Shift
RegDst
Branch
left 2
MemRead
Instruction [31-26]
MemtoReg
Control
ALUOP
MemWrite
ALUSrc
RegWrite
Instruction [25-21]
Read
Read
address
register 1
Read
Instruction [20-16]
data 1
Read
Instruction
register 2
0
[31-0]
M
Read
Write
data 2
Instruction
Instruction [15-11] x
register
memory
1
Write
MJX
result
Zero
ALU ALU
Read
Address
data
data Registers
Data
Write
data memory
16
Instruction [15-0]
Sign-
extend
Instruction (5-0)
32
32
ALU
control
Ox
Transcribed Image Text:сл PC 4-> Add ALU (MAX- Add result Shift RegDst Branch left 2 MemRead Instruction [31-26] MemtoReg Control ALUOP MemWrite ALUSrc RegWrite Instruction [25-21] Read Read address register 1 Read Instruction [20-16] data 1 Read Instruction register 2 0 [31-0] M Read Write data 2 Instruction Instruction [15-11] x register memory 1 Write MJX result Zero ALU ALU Read Address data data Registers Data Write data memory 16 Instruction [15-0] Sign- extend Instruction (5-0) 32 32 ALU control Ox
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
New Perspectives on HTML5, CSS3, and JavaScript
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:
9781305503922
Author:
Patrick M. Carey
Publisher:
Cengage Learning