please translate these c++ coding to the simplest QtSPIM MIPS assembly language statement
#include<iostream>
using namespace std;
int main()
{
int change;
int totalCredit;
cout<<"Please scan your card";
cin>>totalCredit;
if(totalCredit>=3)
{
change=totalCredit-3;
cout<<"45 min";
}
else
{
cout<<"00";
}
return 0;
}
Please find the code below:
.globl main
.data
prompt1: .asciiz "Please scan your card : "
promptZero: .asciiz "00"
promptTime: .asciiz "45 min"
.text
main:
li $t0,0 #using as change
li $v0, 4
la $a0, prompt1
syscall
li $v0,5
syscall
move $t1, $v0 #t1 as totalCredit
blt $t1,3,else #if total credit less than 3
sub $t0,$t1,3 #change = totalCredit - 3
li $v0, 4
la $a0, promptTime
syscall
j exit
else:
li $v0, 4
la $a0, promptZero
syscall
exit:
output:
please translate these c++ coding to the simplest QtSPIM MIPS assembly language statement #include<iostream> using namespace...
1.Write an assembly language program that corresponds to the following C++ program: #include <iostream> using namespace std; const int amount = 20000; int num; int sum; int main () { cin >> num; sum = numb + amount; cout << "sum = " ,<< sum << endl; return 0; } 2. Test the program in the previous question twice. The first time, enter a value for num to make the sum within the allowed range for the Pep/8 computer. The...
#include <iostream> #include <chrono> using namespace std; double improvedPow(double x, int y) { // To be implemented by you } int main() { cout << "To calculate x^y ..." << endl; double x; int y; cout << "Please enter x: "; cin >> x; cout << "Please enter y: "; cin >> y; if(x == 0) { if (y > 0) cout << 0 << endl; else cout << "x^y is not defined" <<endl; } else { cout << improvedPow(x,y)...
please write this in "MARIE assembly language" #include <iostream> using namespace std; int DivideByTwo(int, int); // Data section int Data[] = { 0x0102, 0x0105, 0x0106, 0x0108, 0x011A, 0x0120, 0x0225, 0x0230, 0x0231, 0x0238, 0x0339, 0x0350, 0x0459, 0x055F, 0x066A, 0x0790, 0x08AB, 0x09AF, 0x0AB9, 0x0BBD, 0x0CC1, 0x0DCA, 0x0EFE, 0x0FFE }; int main() { int* BAddr = &Data[0]; int* EAddr = &Data[23]; int Count = 24; // the number of Data int Ffff = 0xffff; // value for "not found" int num; // input...
Convert this C++ program to x86 assembly language using the Irvine library: #include <iostream> unsigned int x; unsigned int c; unsigned int result; // f(x) = 8x + c // Make sure to push and pop all necessary registers to the stack to // ensure only the EAX register is modified upon return from the function unsigned int Equation(unsigned int x, unsigned int c) { // You CANNOT use the mul or imul operations to perform the multiplication return (8...
Write the missing statements for the following program. #include <iostream> using namespace std; int main(void) { int Num1; cout << "Enter 2 numbers: "; cin >> Num2; if (Num1 < Num2) cout << "Smallest number is " << Num1; else cout << "Smallest number is " << Num2; return 0; }
Write following program using Switch statement. #include <iostream> using namespace std; int main() int number; cout << "Enter an integer cin >> number; if (number > B) cout << You entered a positive integer: " << number << endl; else if (number (8) cout<<"You entered a negative integer: " << number << endl; cout << "You entered e." << endl; cout << "This line is always printed." return 0;
what is the output for the following code? explain the steps. /*#include <iostream> using namespace std; int f(int &i) { i = 10; return(5 * i); } int main() { int n = 5; f(n); cout << n << "\n"; return 0; } #include <iostream> using namespace std; int sub1(int n) { n--; return n; } int main() { int m = 10; for(int j = 0; j < 10; j++) m -= sub1(j); cout << m << "\n"; return...
In
PEP8 code.
assembly pep8 code.
30. Write an assembly language program that corresponds to the following C+ program #include <iostream> using namespace std; int num; int main() cin >> num: num = num/ 16; cout << "num = " << num << endl; return 0; 21 de
Question 1: Fix the 2D dynamic array initialization in following code #include <iostream> using namespace std; int main(){ int rows = 5; int cols = 5; int x; int** arr = new int[rows][cols] cin >> x; arr[x][x] = x; cout << "arr[x][x] = " << arr[x][x]; return 0; } Question 2: Fix the code to initialize the 2D array elements to x #include <iostream> using namespace std; int main(){ int rows; int cols; int x;...
#include <iostream> #include <string> using namespace std; int main() { int number; int sum = 0; while(true) { cout << "Please enter a number between 1 and 11: "; cin >> number; if (number >= 1 && number <= 11) { cout << number << endl; sum = sum + number; //only add the sum when number is in range: 1-11, so add wthin this if case } else { cout << number << endl; cout << "Out of range;...