Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I already have this in C i need to transcribe to ARMv8 my code: #include <stdio.

ID: 3866047 • Letter: I

Question

I already have this in C i need to transcribe to ARMv8

my code:

#include <stdio.h>
#include <stdlib.h>

int main()
{
//Prompting users to enter x and a
printf("enter the value of x and a ");
double x;
long int a;
scanf("%lf%ld",&x,&a);
int n=0;
//variable for denominator
long long int den = 1;
//Variable calcuating numerator and answers
double num = 1;
double ans = 0;
double exp = 0;
//Iterate through n from 0 to a
for(n=1;n<=a;n++){

//Calculate numberator x^i
num = num*x;
//Calclate denominator n!
den = den*(n);
//answers
exp=(num/den);
ans = ans + (num/den);
}

printf("E^x is %lf ",exp);
printf("Answer is %lf ",ans);
return 0;
}

Computation of exponential function is given as e. Write a ARMe assembly program to compute the exponential value. Assume the input x is in DO and the input a is in X19. Store the result in D1. The user input x is a double precision floating-point value between -5 and 5. The user input a is a 64-bit non-negative integer less than 16. Assemble, test, and simulate the assembly code using DS-5 simulator

Explanation / Answer

.LC0:
   .ascii "enter the value of x and a"
.LC1:
   .ascii "%lf%ld"
.LC2:
   .ascii "E^x is %lf "
.LC3:
   .ascii "Answer is %lf "
main:
   stmfd sp!, {r4, fp, lr}
   add fp, sp, #8
   sub sp, sp, #60
   ldr r0, .L5
   bl puts
   sub r2, fp, #64
   sub r3, fp, #60
   mov r1, r3
   ldr r0, .L5+4
   bl scanf
   mov r3, #0
   str r3, [fp, #-16]
   mov r3, #1
   mov r4, #0
   str r3, [fp, #-28]
   str r4, [fp, #-24]
   mov r3, #0
   ldr r4, .L5+8
   str r3, [fp, #-36]
   str r4, [fp, #-32]
   mov r3, #0
   mov r4, #0
   str r3, [fp, #-44]
   str r4, [fp, #-40]
   mov r3, #0
   mov r4, #0
   str r3, [fp, #-52]
   str r4, [fp, #-48]
   mov r3, #1
   str r3, [fp, #-16]
.L3:
   ldr r3, [fp, #-64]
   ldr r2, [fp, #-16]
   cmp r2, r3
   bgt .L2
   vldr.64 d7, [fp, #-60]
   vldr.64 d6, [fp, #-36]
   vmul.f64 d7, d6, d7
   vstr.64 d7, [fp, #-36]
   ldr r3, [fp, #-16]
   mov r1, r3
   mov r2, r1, asr #31
   ldr r3, [fp, #-24]
   mul r0, r1, r3
   ldr r3, [fp, #-28]
   mul r3, r2, r3
   add r0, r0, r3
   ldr ip, [fp, #-28]
   umull r3, r4, ip, r1
   add r2, r0, r4
   mov r4, r2
   str r3, [fp, #-28]
   str r4, [fp, #-24]
   str r3, [fp, #-28]
   str r4, [fp, #-24]
   sub r1, fp, #28
   ldmia r1, {r0-r1}
   bl __aeabi_l2d
   vmov d5, r0, r1
   vldr.64 d6, [fp, #-36]
   vdiv.f64 d7, d6, d5
   vstr.64 d7, [fp, #-52]
   sub r1, fp, #28
   ldmia r1, {r0-r1}
   bl __aeabi_l2d
   vmov d5, r0, r1
   vldr.64 d6, [fp, #-36]
   vdiv.f64 d7, d6, d5
   vldr.64 d6, [fp, #-44]
   vadd.f64 d7, d6, d7
   vstr.64 d7, [fp, #-44]
   ldr r3, [fp, #-16]
   add r3, r3, #1
   str r3, [fp, #-16]
   b .L3
.L2:
   sub r3, fp, #52
   ldmia r3, {r2-r3}
   ldr r0, .L5+12
   bl printf
   sub r3, fp, #44
   ldmia r3, {r2-r3}
   ldr r0, .L5+16
   bl printf
   mov r3, #0
   mov r0, r3
   sub sp, fp, #8
   ldmfd sp!, {r4, fp, lr}
   bx lr
.L5:
   .word .LC0
   .word .LC1
   .word 1072693248
   .word .LC2
   .word .LC3

--------------------------

The given C program has been converted to ARM using gcc 5.4