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>
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);
printf("Insert two numbers\n");
scanf("%d",&a);
scanf("%d",&b);
c=a|b;
printf("%d|%d=%d\n",a,b,c);
printf("Insert two numbers\n");
scanf("%d",&a);
scanf("%d",&b);
c=a^b;
printf("%d^%d=%d\n",a,b,c);
printf("Insert two numbers\n");
scanf("%d",&a);
scanf("%d",&b);
a=a<<2;
b=b<<2;
printf("%d&%d\n",a,b);
printf("Insert two numbers\n");
scanf("%d",&a);
scanf("%d",&b);
a=a>>2;
b=b>>2;
printf("%d&%d\n",a,b);
printf("Insert two numbers\n");
int d;
scanf("%d",&a);
scanf("%d",&b);
c=~a;
d=~b;
printf("~%d=%d\n""~%d=%d\n",a,c,b,d);
return 0;
}
.data prompt: .asciiz "Insert two numbers\n" andsym: .asciiz "&" orsym: .asciiz "|" xorsym: .asciiz "^" negsym: .asciiz "~" eqsym: .asciiz "=" newline:.asciiz "\n" .text # display prompt la $a0, prompt li $v0, 4 syscall # read a number li $v0, 5 syscall # store input(a) in $t0 move $t0, $v0 # read another number li $v0, 5 syscall # store input(b) in $t1 move $t1, $v0 and $t2, $t0, $t1 # c = a & b # print a move $a0, $t0 li $v0, 1 syscall # print & la $a0, andsym li $v0, 4 syscall # print b move $a0, $t1 li $v0, 1 syscall # print = la $a0, eqsym li $v0, 4 syscall # print c move $a0, $t2 li $v0, 1 syscall # print \n la $a0, newline li $v0, 4 syscall # display prompt la $a0, prompt li $v0, 4 syscall # read a number li $v0, 5 syscall # store input(a) in $t0 move $t0, $v0 # read another number li $v0, 5 syscall # store input(b) in $t1 move $t1, $v0 or $t2, $t0, $t1 # c = a | b # print a move $a0, $t0 li $v0, 1 syscall # print | la $a0, orsym li $v0, 4 syscall # print b move $a0, $t1 li $v0, 1 syscall # print = la $a0, eqsym li $v0, 4 syscall # print c move $a0, $t2 li $v0, 1 syscall # print \n la $a0, newline li $v0, 4 syscall # display prompt la $a0, prompt li $v0, 4 syscall # read a number li $v0, 5 syscall # store input(a) in $t0 move $t0, $v0 # read another number li $v0, 5 syscall # store input(b) in $t1 move $t1, $v0 xor $t2, $t0, $t1 # c = a ^ b # print a move $a0, $t0 li $v0, 1 syscall # print ^ la $a0, xorsym li $v0, 4 syscall # print b move $a0, $t1 li $v0, 1 syscall # print = la $a0, eqsym li $v0, 4 syscall # print c move $a0, $t2 li $v0, 1 syscall # print \n la $a0, newline li $v0, 4 syscall # display prompt la $a0, prompt li $v0, 4 syscall # read a number li $v0, 5 syscall # store input in $t0 move $t0, $v0 # read another number li $v0, 5 syscall # store input in $t1 move $t1, $v0 # a = a << 2 sll $t0, $t0, 2 # b = b << 2 sll $t1, $t1, 2 # print a move $a0, $t0 li $v0, 1 syscall # print & la $a0, andsym li $v0, 4 syscall # print b move $a0, $t1 li $v0, 1 syscall # print \n la $a0, newline li $v0, 4 syscall # display prompt la $a0, prompt li $v0, 4 syscall # read a number li $v0, 5 syscall # store input in $t0 move $t0, $v0 # read another number li $v0, 5 syscall # store input in $t1 move $t1, $v0 # a = a >> 2 srl $t0, $t0, 2 # b = b >> 2 srl $t1, $t1, 2 # print a move $a0, $t0 li $v0, 1 syscall # print & la $a0, andsym li $v0, 4 syscall # print b move $a0, $t1 li $v0, 1 syscall # print \n la $a0, newline li $v0, 4 syscall # display prompt la $a0, prompt li $v0, 4 syscall # read a number li $v0, 5 syscall # store input(a) in $t0 move $t0, $v0 # read another number li $v0, 5 syscall # store input(b) in $t1 move $t1, $v0 nor $t2, $t0, $t0 # c = ~a nor $t3, $t1, $t1 # d = ~b # print ~ la $a0, negsym li $v0, 4 syscall # print a move $a0, $t0 li $v0, 1 syscall # print = la $a0, eqsym li $v0, 4 syscall # print c move $a0, $t2 li $v0, 1 syscall # print \n la $a0, newline li $v0, 4 syscall # print ~ la $a0, negsym li $v0, 4 syscall # print b move $a0, $t1 li $v0, 1 syscall # print = la $a0, eqsym li $v0, 4 syscall # print d move $a0, $t3 li $v0, 1 syscall # print \n la $a0, newline li $v0, 4 syscall
Convert the below C code to basic MIPS. The result of this code should ask for...
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. 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; }
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; }
This code should exit in 0 is inputed or the code should repeat
adding two number if '1' is inputed. What are three logical or/and
syntax errors in this code?
int choice, numi, num2: Linn printf("Enter a number: "); scanf("%d", &numl); printf("Enter another number: "); scanf("%d", &num2); printf ("Their sum is d\n", (numl+num2)); printf ("Enter 1 to repeat, 0 to exit"); scanf("%d", &choice) } while (choice == 0) HH
This code should be Runnable on MARS (MIPS Assembler and Runtime Simulator) IDE Convert the following c code into mips #include <stdio.h> #include <string.h> char cipherText[200] = "anything"; int countNumberOfCharInCipher(char*); int countNumberOfCharInCipher(char* cText) { return strlen(cText); } int countSpaces(int numberOfChar, char input[]) { int spaceCounter =0; for(int i=0; i < numberOfChar; i++) { if(input[i] == 32) spaceCounter++; } return spaceCounter; } void decrypt(int numberOfChar, int key, char * cipherText, char * plainText) { int j = 0; int i =0;...
Hello, I need help with the following C code. This program asks the user to enter three numbers and outputs the sum on the screen , all im trying to do is have the program reprompt the user for a number if anything other than a number is entered for each of the entries. I wanted to use do while for each of the functions but that did not work for example: Enter Number 1: 2 Enter Number 2: Hello...
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...
/* • The following code consists of 5 parts. • Find the errors for each part and fix them. • Explain the errors using comments on top of each part. */ #include <stdio.h> #include <string.h> int main( ) { ////////////////////////////////////////////////////////////////////////// ////////////// Part A. (5 points) ////////////////// int g(void) { printf("%s", Inside function g\ n " ); int h(void) { printf(" % s ", Inside function h\ n "); } } printf("Part A: \n "); g(); printf(" \n"); ////////////////////////////////////////////////////////////////////////// ////////////// ...
In C please
Write a function so that the main() code below can be replaced by the simpler code that calls function MphAndMinutesToMiles(). Original maino: int main(void) { double milesPerHour, double minutes Traveled; double hours Traveled; double miles Traveled; scanf("%f", &milesPerHour); scanf("%lf", &minutes Traveled); hours Traveled = minutes Traveled / 60.0; miles Traveled = hours Traveled * milesPerHour; printf("Miles: %1f\n", miles Traveled); return 0; 1 #include <stdio.h> 3/* Your solution goes here */ 1 test passed 4 All tests passed...
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; }