Ask Question
4 March, 20:45

Write a new ARMv8 assembly file called "lab04b. S" which is called by your main function. It should have the following specifications: Create a function that computes factorials: n! = n · (n - 1) · ... · 3 · 2 · 1. Use the my_mul function in question 1 for all multiplications Use the concept of recursion. Do NOT directly use the concept of iteration. Do not forget that using the recursion is the same as using the STACK. Make sure you comment on the code. Demonstrate your code running to the TA. Turn in your lab04b. S file here when complete.

+2
Answers (1)
  1. 4 March, 23:22
    0
    my_mul:

    . globl my_mul

    my_mul:

    //Multiply X0 and X1

    / / Does not handle negative X1!

    / / Note : This is an in efficient way to multipy!

    SUB SP, SP, 16 / /make room for X19 on the stack

    STUR X19, [SP, 0] / /push X19

    ADD X19, X1, XZR / /set X19 equal to X1

    ADD X9, XZR, XZR / /set X9 to 0

    mult_loop:

    CBZ X19, mult_eol

    ADD X9, X9, X0

    SUB X19, X19, 1

    B mult_loop

    mult_eol:

    LDUR X19, [SP, 0]

    ADD X0, X9, XZR / / Move X9 to X0 to return

    ADD SP, SP, 16 / / reset the stack

    BR X30
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a new ARMv8 assembly file called "lab04b. S" which is called by your main function. It should have the following specifications: ...” in 📘 Engineering if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers