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();
}
please find the below code,, which is converted into assembly mips...
.section .mdebug.abi32
.previous
.gnu_attribute 4, 1
.abicalls
.text
.align 2
.globl _Z6checkiv
$LFB0 = .
.set nomips16
.ent _Z6checkiv
.type _Z6checkiv, @function
Z6checkiv:
.frame $fp,24,$31
# vars= 8, regs= 1/0, args= 0, gp= 8
.mask 0x40000000,-4
.fmask 0x00000000,0
.set noreorder
.set nomacro
addiu $sp,$sp,-24
$LCFI0:
sw $fp,20($sp)
$LCFI1:
move $fp,$sp
movz $31,$31,$0
$LCFI2:
sw $0,8($fp)
b $L2
nop
$L7:
lw $2,8($fp)
li $3,2
# 0x2
beq $2,$3,$L5
nop
li $3,3
# 0x3
beq $2,$3,$L6
nop
li $3,1
# 0x1
bne $2,$3,$L9
nop
$L4:
lw $2,8($fp)
nop
addiu $2,$2,5
sw $2,8($fp)
b $L2
nop
$L5:
lw $2,8($fp)
nop
addiu $2,$2,-1
sw $2,8($fp)
b $L2
nop
$L6:
lw $2,8($fp)
nop
addiu $2,$2,2
sw $2,8($fp)
b $L2
nop
$L9:
lw $2,8($fp)
nop
addiu $2,$2,1
sw $2,8($fp)
$L2:
lw $2,8($fp)
nop
slt $2,$2,10
andi $2,$2,0x00ff
bne $2,$0,$L7
nop
move $sp,$fp
lw $fp,20($sp)
addiu $sp,$sp,24
j $31
nop
.set macro
.set reorder
.end _z6checkiv
$LFE0:
.size _z6checkiv, .-_z6checkiv
.ident "GCC: (debian 4.4.5-8) 4.4.5"
Convert the following code to assembly MIPS void checki() { int i = 0; while(i <...
its brr[8] (40%) Convert the following C-pseudo code into MIPS assembly code as a standalone program (including main and all the required directives). You can use any register. You must comply, however, with the convention of register usage. Before writing your code perform an explicit register allocation phase. Note that the C snippet is int arr[8]; int brr[4]-{1, 2, 3, 4, 5, 6, 7, 8) int i-8; while (i>-0) arrli]-brr[i-); (40%) Convert the following C-pseudo code into MIPS assembly code...
How do i convert the following C program into MIPS assembly? int main(void) { short var1[4] ={5, 8, 13, 6}; short var2[4]= {16, 4, 7, 15}; short result[4]={0}; for (int i=0 ; i< 4; i++) result[i] = var1[i] - var2[i]; }
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...
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
5. Consider the following C code: int main() int x = 1; switch (x) case 1: i=1; case 2: i=5; return 0; Based on this code, answer the following: (a) Convert the above C code to MIPS assembly. (b) The condition you are testing is met at Case 1. You do not want the Case 2 to be tested. Add appropriate instructions in MIPS for this implementation. (c) If int x is any integer other than 1 or 2, you...
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...
MIPS assembly language Covert this code to MIPS: #include <stdio.h> int function (int a) int main)i int x=5 ; int y: y function(x); printf "yd",y); return 0; int function (int a) return 3*a+5; Assumptions: . Place arguments in $a0-$a3 . Place return values in $vO-$v1 Return address saved automatically in $ra . lgnore the stack for this example. (Thus, the function will destroy registers used by calling function
Convert the below code into if else selection: #include <iostream> using namespace std; int main() { int num; sin. >> num; switch (num) { case 1: cout << "Casel: Value is: << num << endl; break; case 2: break; case 3: cout << "Case3: Value is: " << num << endl; break; default: cout << "Default: Value is: << num << endl; break; } return; }
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 below C code to basic MIPS. Please leave comments for explanation #include <stdio.h> int main(void) { printf("Insert two numbers\n"); int a,b; scanf("%d",&a); scanf("%d",&b); a=a<<2; b=b<<2; printf("%d&%d\n",a,b); return 0; }