$24
9.1 Assignment
If floating point hardware is available, it can be used to greatly accelerate non-integral mathematical operations. For this lab, you are to re-write the program from Lab 8, but this time you must use floating point instructions to perform your calculations.
9.2 Instructions
Re-write the program from Lab 8, but this time, use ARM VFP instructions to perform floating point mathematics. You can use printf and scanf for output and input of floating point values. The following example shows how to print floating point values.
1
fmt: asciz "%f\n"
3
.
.
.
7
@@ printf expects all floating point parameters to be passed
@@ as IEEE double precision. If the second parameter to printf
10@@ is a float, then printf expects the 64-bit value to be
11@@ passed in two registers. The choice of registers depends
12@@ on the stack pointer.
13@@ printf acts as if r0-r3 are part of the stack and requires
14@@ the 64-bit value to be aligned on an 8-byte boundary. The
15@@ following lines print out the number in d0 by moving it to
16@@ the appropriate registers and calling printf.
17
tst
sp,#4
@ check to see if stack is aligned
vmovne r1, r2, d0@ move to r1,r2 if not aligned
vmoveq r2, r3, d0@ move to r2,r3 if aligned
20
ldr
r0,=fmt
@ load pointer to format string
21
bl
printf
29
30 LAB 9. FLOATING POINT MATH