Your inputs x and y cannot be stored as a global variable at any point
Ask Expert

Be Prepared For The Toughest Questions

Practice Problems

Your inputs x and y cannot be stored as a global variable at any point

Objective

Write an ARM program that takes two integers as input, x and y, and recursively calculates xy.

Requirements and Specifications

Your inputs x and y cannot be stored as a global 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.

You may use X19-X27 only in your main function.

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.

Again, you may use X19-X27 in your main function, but you may not use X19-X27 in your recursive function.

Some assumptions:

x, y are 32-bit integers

x0 = 1

00 = 0

xy ≤ 230

IT MUST LOOK LIKE THIS.


SKELETON CODE MUST BE USED

.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

how-to-install-the-emulator-windows-1

how-to-use-the-emulator-1

Hint
ComputerA program is a predetermined set of sequential activities that a computer is programmed to carry out. The program in the modern computer that John von Neumann described in 1945 contains a sequence of instructions that the machine executes one at a time. The application is often stored in a location that the computer can access....

Know the process

Students succeed in their courses by connecting and communicating with
an expert until they receive help on their questions

1
img

Submit Question

Post project within your desired price and deadline.

2
img

Tutor Is Assigned

A quality expert with the ability to solve your project will be assigned.

3
img

Receive Help

Check order history for updates. An email as a notification will be sent.

img
Unable to find what you’re looking for?

Consult our trusted tutors.

Developed by Versioning Solutions.