程序代写代做代考 arm 11月16日晚上12点之前(国内时间)

11月16日晚上12点之前(国内时间)

题目:
Write an ARM program that takes two integers as input, x and y, and recursively calculates xy.
Your inputs x and y cannot be stored as a variable at any point. This means you cannot store them at a data section address, even when accepting them from scanf; they must be returned from scanf on the stack.
Recursion requires:
• Save the return address, arguments, and local variables in a new stack frame
• Recursively call procedure with BL
• Unwind the stack by restoring the return address, arguments, and local variables, and deallocating the stack frame
Your exponent function should have the following general form:
power(x, y):
 if x is 0
 return 0
 else if y less than 0
 return 0
 else if y is 0
 return 1
 else
 return x * power(x, y – 1)
Your arguments x and y should be passed to your power function in X0 and X1. Your return value should be placed in X2.
Some assumptions:
• x, y are 32-bit integers
• x0 = 1
• xy ≤ 230
Here is a screenshot of some sample cases:

Here is skeleton code for you to start with:

.section .data

input_x_prompt: .asciz “Please enter x: ”
input_y_prompt: .asciz “Please enter y: ”
input_spec: .asciz “%d”
result: .asciz “x^y = %d\n”

.section .text

.global main

main:

# add code and other labels here

# branch to this label on program completion
exit:
mov x0, 0
mov x8, 93
svc 0
ret