Screenshot
Program
#Data declaration part
.data
arr: .word 0 0 0 0 0 0 0
0
#arr[8]
brr: .word 1 2 3 4 5 6 7
8 #brr =
{1,2,3,4,5,6,7,8}
#Program starts here
.text
#Main program
.globl main
main:
#Get the base address of arr
la $s0,arr
#Get the base address of brr
la $s1,brr
#Initialize variable i=8
addi $t0,$0,8
#Address increment to get last
addi $t1,$0,4
mul $t1,$t1,$t0
add $s0,$s0,$t1
add $s1,$s1,$t1
#While loop i>=0
whileLoop:
blt $t0,0,exitLoop
#Get brr value into t1
lw $t1,($s1)
#store into arr, brr[i]=arr[i--]
sw $t1,($s0)
#decrement address
addi $s0,$s0,-4
addi $s1,$s1,-4
#Decremnet i
addi $t0,$t0,-1
j whileLoop
#End of the program
exitLoop:
addi $v0,$0,10
syscall
its brr[8] (40%) Convert the following C-pseudo code into MIPS assembly code as a standalone program...
B2. Convert the C code to MIPS assembly with only 2 efficient instructions: Register assignment: timer-v0 int timer = 0x0AC8 0001; B3. Write MIPS assembly code segment for the following C code snippet for (i - 0, i < 100; i++) -array Register assignment: i-) $ao Base of array -> $s0 array [ i+1] [i] / 2;
B2. Convert the C code to MIPS assembly with only 2 efficient instructions: Register assignment: timer-v0 int timer = 0x0AC8 0001; B3. Write...
How can I convert the following C code to MIPS Assembly? +++++++++++++++++++++++++++++++++ MIPS main program ++++++++++++++++++++++++++++++++ .data # Defines variable section of an assembly routine. array: .word x, x, x, x, x, x, x, x, x, x # Define a variable named array as a word (integer) array # with 10 unsorted integer numbers of your own. # After your program has run, the integers in this array # should be sorted. .text # Defines the start of the code...
6. Write the MIPS assembly code that corresponds to the pseudo code below. Assume that the address for integer i is baseaddress+4 and the address for a[0] is baseaddress+8. Assume that the baseaddress is stored in $gp. The code initializes i to O; it then iterates from i-0 to i-9, setting a4i in each iteration. To make your code efficient, i must be loaded into a register at the start, and it must be updated in memory only after you've...
4. (a) Translate the following pseudo-code into MIPS assembly code. Assume that A, B, C are arrays of size N elements, indexed 0..N-1 I=I; WHILE(I<N AND A[I]<B[I]) C[I] = A[I] + B[I-1]
C3. Convert the following C-code to MIPS code. [Use register $al for the variable i, temporary registers for other values, and load the base memory address of the array OxA0000080 to Şao] int i i int array [101; for (i= 0; i<5 ; i=i+1 ) { [i+1] [i] 8; * array = array
C3. Convert the following C-code to MIPS code. [Use register $al for the variable i, temporary registers for other values, and load the base memory address of...
C2. Convert the following c-code to MIPS code. The base memory address of the array a is 0x8000_400C, which must be loaded in the base register Ss0. Register assignments: int a[10]; while (i !- 10) 1 if ( i%2 == 0) a[i] = i * 2; else ail - i* 3 i++i
C2. Convert the following c-code to MIPS code. The base memory address of the array a is 0x8000_400C, which must be loaded in the base register Ss0. Register...
Convert the program you wrote in to an MIPS assembly program. Make sure that you show the symbol table (assume memory is allocated beginning address 5000) and that the equivalent assembly program is commented. int main() { int a[10]; int i = 0; while( i <= 5) { a[i]=i; a[9-i]=9-i; i++; }
Convert the following code to assembly MIPS void checki() { int i = 0; while(i < 10) { switch(i) { case 1: i += 5; break; case 2: i --; break; case 3: i += 2; break; default: i++; } } } void main() { checki(); }
Write a MIPS assembly code that corresponds to the following C code. Note: use the stack to store all register values that you use in the procedures. int aver(int * array, int N){ int i, sum = 0; for ( i=0;i i<N; i++) sum += array[i]; return sum/N;} int Max( int * array, int N){ int i, Maximum = array[i]; for ( i = 1; i< N; i++) if ( array[i] > Maximum) Maximum = array[i]; return Maximum; } int...
MIPS assembly language
Implement the following code in MIPS int array [ ] {2, 3, 4, 5, 6); int main) int num, position; scanf("%d",&num) ; position search(array, printf("The position is: num, 5); %d\n",positio int search(int array, int num, int size int position =-1; for(int i-0;i<size; i++) if(array [i]=num) { position-i; break; return position; Register map $s1: position $a0: array address $a1: num . $a2: size . $VO: return value