[Solved] CSF342 Computer Architecture Lab Sheet 6

$25

File Name: CSF342_Computer_Architecture_Lab_Sheet_6.zip
File Size: 376.8 KB

SKU: [Solved] CSF342 Computer Architecture Lab Sheet 6 Category: Tag:
5/5 - (1 vote)

Goals for the Lab: We build up on prior labs and explore basics of functions and recursion.

Background:

  • Calling a subroutine is between a caller, who makes the subroutine call, and the callee, which is the subroutine itself.
  • The caller passes arguments to the callee by placing the values into the argument registers $a0-$a3.
  • The caller calls jal followed by the label of the subroutine. This saves the return address in $ra. The return address is PC + 4, where PC is the address of the jal instruction. If the callee uses a frame pointer, then it usually sets it to the stack pointer. The old frame pointer must be saved on the stack before this happens.
  • The callee usually starts by pushing any registers it needs to save on the stack. If the callee calls a helper subroutine, then it must push $ra on the stack. It may need to push temporary ($t0-$t7) or saved registers ($s0-$s7) as well.
  • Once the subroutine is complete, the return value is placed in $v0-$v1.The callee then calls jr $ra to return back to the caller.

Exercise 1 With Sample Code: Study the code given below.

Exercise 2: Write a function to count the number of vowels in a given string and also return the string after removing the vowels and print that string in main function. Call the function twice with two different strings.

Input : String (without space)

Output : Single integer

Exercise 3: Write a program that asks if the user wants a triangle or a square. It then asks the user for the size of the object (the number of lines it takes to draw the object). The program then writes a triangle or a square of stars * to the console.

*******

*******

*******

*******

*******

*******

or

*

**

***

****

***** ******

Write a subroutine for each figure. In them, use a subroutine print_star_line that writes a line of a given number of stars. (that number is passed as an argument to print_star_line function).

Take home assignment:

Print the pyramid as:

*

**

***

****

*****

******

*******

Exercise 4: Find Factorial of a given integer recursively. Take care of the base case.

Exercise 5: Disassemble the following hex instructions.

  • 02002009
  • 03e00008
  • 0c100013

References: http://stackoverflow.com/questions/18991655/howdoyouperformarecursiveoperationinmipsassembly

http://stackoverflow.com/questions/22317560/mipsassemblyremovingvowelsfromaninputstring

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CSF342 Computer Architecture Lab Sheet 6
$25