Question
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 which
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 which computes factorials: n! = n (n 1) ... 3 2 1. Use the my_mul function in question 1 for all multiplications Each function must save on the stack all variables it modifies. Make sure you comment the code. Demonstrate your code running to the TA. Turn in your lab04b.S file here when complete.
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
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started