CSE 2312 - Assignments

Not Graded Practice for Assignment 9


Practice Question 1

Consider the following function in C:
int foo(int a, int b, int c)
{
  if (a / b == c) return a % b;
  else return 0;
}
Implement this function in assembly.


Practice Question 2

Consider the following function in C:
int foo(int a, int b)
{
  int i;
  int result = 0;
  for (i = 0; i < a; i++)
  {
    result = result + b;
    b = b >> 1;
  }

  return result;
}
Implement this function in assembly.


Practice Question 3

Consider the following function in C:
int foo(int a, int b)
{
  if ((a <= 0) || (b <= 0)) return a + b;
  b = a - b;
  return foo(b, a) + a;
}
Implement this function in assembly.


Practice Question 4

The greatest common divisor (GCD) between positive integers A and B, both >= 1, can be computed based on these rules: Implement a function GCD in assembly, that computes GCD(A, B) using the rules stated above.


Practice Question 5

Define a function sort4 in assembly, that takes four arguments and sorts them. At the end of the function, the four arguments are stored, in ascending order, at registers r0, r1, r2, r3.


Back to the list of assignments.