.globl a
.data
.align 2
.type a, @object
.size a, 4
a:
.word 1234
.globl b
.align 2
.type b, @object
.size b, 4
b:
.word 5678
.comm sum,4,4
.rdata
.align 2
$LC0:
.ascii "%d\000"
.text
.align 2
.globl main
.ent main
.type main, @function
main:
.frame $fp,32,$31 # vars= 0, regs= 2/0, args= 16, gp= 8
.mask 0xc0000000,-4
.fmask 0x00000000,0
.set noreorder
.cpload $25
.set nomacro
addiu $sp,$sp,-32
sw $31,28($sp)
sw $fp,24($sp)
move $fp,$sp
.cprestore 16
movz $31,$31,$0
lw $2,%got(a)($28)
nop
lw $3,0($2)
lw $2,%got(b)($28)
nop
lw $2,0($2)
nop
addu $3,$3,$2
lw $2,%got(sum)($28)
nop
sw $3,0($2)
lw $2,%got(sum)($28)
nop
lw $2,0($2)
nop
move $5,$2
lw $2,%got($LC0)($28)
nop
addiu $4,$2,%lo($LC0)
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,28($sp)
lw $fp,24($sp)
addiu $sp,$sp,32
j $31
nop
2. Write a MIPS program that translates the following C code int a 1234; b 5678 int sum void main () atb sum = cout <...
10) What is the output when the following code fragment is executed? void exam(int i) {cout « i; } void main() { int n; for (n = 3; n <= 4; n++) exam(n); } A) 1234 B) 234 C) 34 D) 4
Consider the following C program: int sub(int *sum) { *sum =*sum +*sum; return 10; } void main() { int num= 3; num = sub(&num)+ num; } What is the value of num after the assignment statement in main, assuming operands are evaluated left to right. operands are evaluated right to left.
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; }
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; }
In mips code please Implement the following C code in MAL and develop a small main program that tests your implementation on an integer array. You must use nested procedures in your implementation. int getArrAvg (int Arr) int sum0 for (int i = 0; i < 10; i += 1) sum-addfn (sum, Arr[i]) return sum/10; int addfn (int a, int b) return ab;
(10pts). Consider the following: void fun1(void); void fun2(void); void fun3(void); void main() { Int a,b,c; … } void fun1(void){ Int b,c,d; … } void fun2(void){ Int c,d,e; … } void fun3(void){ Int d,e,f; … } Given the following calling sequences and assuming that dynamic scoping is used. What variables are visible during execution of the last function called? Include with each visible variable the name of the function in which it was...
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; }
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]; }
16 Points) Question 3 Write down the outputs of the following program into the provided table include <iostream> using namespace std; void fun I(int a); int fun2(int a, int b); int x-3: int main) int x-1,y 0,z-2; x-fun2(y,z); cout sx fun 1 (z); cout (#xtytz(endl; y-fun2(x,x); cout <exty+zscendl; system("pause"); void fun 1 (int a) int fun2(int a, int b) int static c2; return atx; 16 Points) Question 3 Write down the outputs of the following program into the provided table...
Consider the following C++ program: #include <iostream> using namespace std; void f1(int); void f2(int); void f3(int); int main() { f1(10); return 0; } void f1(int n) { f2(n + 5); } void f2(int n) { f3(n - 2); } void f3(int n) { cout << n << endl; // LINE 1 } Just before the program statement marked with the comment "LINE 1" is executed, how many stack frames will be on the program call stack?