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

Write and run an ARM VFP assembly program to calculate the volume of a sphere: 4

ID: 3837291 • Letter: W

Question

Write and run an ARM VFP assembly program to calculate the volume of a sphere: 4(pi*r^3)/3 if r = 25.5. Your TI Launchpad supports floating point operations, however it is switched off at reset (so you must turn it on!)

It was a question from my textbook ARM Assembly Language Programming & Architecture

So far I have Written this code in order to solve the equation and was wondering how I could go about outputting this value and making sure I have enabled the floating point.

; have to enable The CPAC register in order to use floating point: offset 0xD88

Explanation / Answer

Answer

Below is the required ARM code:

func(float):
stmfd sp!, {fp, lr}
add fp, sp, #4
sub sp, sp, #16
str r0, [fp, #-16] @ float
ldr r1, .L3
ldr r0, [fp, #-16] @ float
bl __aeabi_fmul
mov r3, r0
ldr r1, [fp, #-16] @ float
mov r0, r3
bl __aeabi_fmul
mov r3, r0
ldr r1, [fp, #-16] @ float
mov r0, r3
bl __aeabi_fmul
mov r3, r0
ldr r1, .L3+4
mov r0, r3
bl __aeabi_fmul
mov r3, r0
ldr r1, .L3
mov r0, r3
bl __aeabi_fdiv
mov r3, r0
str r3, [fp, #-8] @ float
ldr r3, [fp, #-8] @ float
mov r0, r3
sub sp, fp, #4
ldmfd sp!, {fp, lr}
bx lr
.L3:
.word 1077936128
.word 1082130432

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote