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;
}
Code in MIPS :
.file 1 ""
.section .mdebug.abi32
.previous
.nan legacy
.module fp=32
.module nooddspreg
.abicalls
.rdata
.align 2
$LC0:
.ascii "Insert two numbers\000"
.align 2
$LC1:
.ascii "%d\000"
.align 2
$LC2:
.ascii "%d&%d\012\000"
.text
.align 2
.globl main
.set nomips16
.set nomicromips
.ent main
.type main, @function
main:
.frame $fp,40,$31 # vars= 8, regs= 2/0, args= 16, gp= 8
.mask 0xc0000000,-4
.fmask 0x00000000,0
.set noreorder
.cpload $25
.set nomacro
addiu $sp,$sp,-40
sw $31,36($sp)
sw $fp,32($sp)
move $fp,$sp
.cprestore 16
movz $31,$31,$0
lw $2,%got($LC0)($28)
nop
addiu $4,$2,%lo($LC0)
lw $2,%call16(puts)($28)
nop
move $25,$2
.reloc 1f,R_MIPS_JALR,puts
1: jalr $25
nop
lw $28,16($fp)
addiu $2,$fp,24
move $5,$2
lw $2,%got($LC1)($28)
nop
addiu $4,$2,%lo($LC1)
lw $2,%call16(__isoc99_scanf)($28)
nop
move $25,$2
.reloc 1f,R_MIPS_JALR,__isoc99_scanf
1: jalr $25
nop
lw $28,16($fp)
addiu $2,$fp,28
move $5,$2
lw $2,%got($LC1)($28)
nop
addiu $4,$2,%lo($LC1)
lw $2,%call16(__isoc99_scanf)($28)
nop
move $25,$2
.reloc 1f,R_MIPS_JALR,__isoc99_scanf
1: jalr $25
nop
lw $28,16($fp)
lw $2,24($fp)
nop
sll $2,$2,2
sw $2,24($fp)
lw $2,28($fp)
nop
sll $2,$2,2
sw $2,28($fp)
lw $2,24($fp)
lw $3,28($fp)
nop
move $6,$3
move $5,$2
lw $2,%got($LC2)($28)
nop
addiu $4,$2,%lo($LC2)
lw $2,%call16(printf)($28)
nop
move $25,$2
.reloc 1f,R_MIPS_JALR,printf
1: jalr $25
nop
lw $28,16($fp)
move $2,$0
move $sp,$fp
lw $31,36($sp)
lw $fp,32($sp)
addiu $sp,$sp,40
j $31
nop
.set macro
.set reorder
.end main
.size main, .-main
.ident "GCC: (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609"
images:



Convert the below C code to basic MIPS. Please leave comments for explanation #include <stdio.h> int main(void) {...
Convert the below C code to basic MIPS. Leave comments for explanation please #include <stdio.h> int main(void) { printf("Insert two numbers\n"); int a,b,c; scanf("%d",&a); scanf("%d",&b); c=a|b; printf("%d|%d=%d\n",a,b,c); return 0; }
Convert the below C code to basic MIPS. The result of this code should be a^b of the two numbers that you input. For example if you input the numbers 3 and 5 you should get a result of 3^5=6 #include int main(void) { printf("Insert two numbers\n"); int a,b,c; scanf("%d",&a); scanf("%d",&b); c=a^b; printf("%d^%d=%d\n",a,b,c); return 0; }
Convert the below C code to basic MIPS. The result of this code should ask for two numbers to be inputed and give the answer. For example if 3 and 5 are inputed then the final answer should be as follows: 3&5=1, 3|5=7, 3^5=6, << = 12&20, >> = 0&1, and finally ~ = -4&-6. Please run the code yourself before you upload it to make sure it works. Start the code with .data. Thank you so much. #include <stdio.h>...
Fix the errors in C code #include <stdio.h> #include <stdlib.h> void insertAt(int *, int); void Delete(int *); void replaceAt(int *, int, int); int isEmpty(int *, int); int isFull(int *, int); void removeAt(int *, int); void printList(int *, int); int main() { int *a; int arraySize=0,l=0,loc=0; int choice; while(1) { printf("\n Main Menu"); printf("\n 1.Create list\n 2.Insert element at particular position\n 3.Delete list.\n4. Remove an element at given position \n 5.Replace an element at given position\n 6. Check the size of...
Solve using C programming
3. lf you are given this code. #include <stdio.h> int main() int var1, var2; int sum; printf("Enter number 1:\n "); scanf("%d",&var1); printf("Enter number 2:In ); scanf("%d",&var2); sum-var1+var2; printf ("Vnsum of two entered numbers : %d", //printf ("Output: %d", res); sum); return e; Modify this code by creating a function called "addition". Make the arguments of the functions numberl and number 2. Add the two values in the function. Return a value called "result". Print "result" in...
i need flowchart for the following c code #include <stdio.h> int main() { int n, i, sum = 0; printf("Enter an integer: "); scanf("%d",&n); i = 1; while ( i <=n ) { sum += i; ++i; } printf("Sum = %d",sum); return 0; }
Convert this C program to Js (Java script) from Visual Studio Code #include<stdio.h> int main(){ char firstName[100]; char lastName[100]; printf("Enter Your Full Name: \n"); scanf("%s %s", firstName, lastName); printf("First Name: %s\n", firstName); printf("Last Name: %s\n", lastName); return 0; }
PUT INTO PYTHON CODE #include <stdio.h> #include <float.h> int main(void) { float a = 1; float b = 0.5; float c = a + b; int bits = 0; while (c != a) { bits = bits + 1; b = b / 2; c = a + b; } printf("%d\n",bits); return 0; }
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
Complete this program in C #include<stdio.h> int main(void) { int sumA(__, __); int answer; //the two parameters are start and end addresses of intA[] answer = sumA(......); printf("..........", intA); printf("The sum of integers in intA is %d.\n", answer); return 0; } //the two parameters of sumA(__, __) are start and end addresses of intA[] int sumA(..........) { ……………………. return ............. }