# Neon Floating Point

Video Activity

Join over 3 million cybersecurity professionals advancing their career

Sign up with

or

Already have an account? Sign In »

Video Transcription

00:01

Hello. This is Dr Miller in this episode 12.3 of Assembly.

00:05

Today we're gonna talk about vector floating point, the FP and neon on arm.

00:11

So floating point.

00:13

So in arm, we have the V, f p or Vector floating point. And this was traditionally a separate co processor.

00:20

It was on arm versions prior to version eight,

00:24

and then we also have traditional V FP and neon instructions that both provide together both single and double precision floating point operations.

00:33

So they provide the ability that an arm processor can do floating point.

00:38

So for floating point instructions,

00:40

we have the FP versus neon. So both V FP and neon are optional extensions to the are marked pictures. So whoever the manufacturers, if it's apple or if it's a raspberry pi, they get to decide what optional extensions they want to add to arm. And so Neon adds some new instructions that VFW didn't have.

00:59

And so what we end up with is traditionally will have a mixed mode operation on sort of newer processes, so we'll have some instructions that are VfB. Only some instructions are mixed, and then some instructions are

01:10

neon only.

01:11

And then when you're using a device, you'll need to review the armed documentation and the processor version to see what types of instructions you can use on your processor.

01:21

So, for example, the raspberry pi uses V F P version for which has both, um, neon and VF p instructions. Together,

01:30

we've added that to our compiler options allow we weaken compile code for it.

01:36

So here's an example. So we have,

01:38

um, pie, which is a floating point number 3.1415

01:42

and so we can load that address into our zero. So LD r R zero, The address of pie.

01:49

We can

01:51

copy the data from our zero into R two and R three, and then we can do a floating point moves. So if the move into s zero or were loading a floating point number from our too, So use r two and r three,

02:05

and so we look at that in the code we can see that are too gets this value are three gets this value and then if we look at the data at that location, we can see that those two pieces of data match

02:16

and then we go in print dollars Sinus zero. We can see that s zero is 3.1415

02:24

So we have additional operations that we can do. We can do things like we can add two numbers, So v ad. So we're doing a vector ad, and then we're saying we want to do a floating 20.32 bit number. So we'll take

02:37

X and Y, and we'll add them together and store them in D for the destination.

02:43

Or we could take X and Y and we can subtract them. We can do multiplication and weaken do division.

02:47

And you have to look at the arm documentation To understand the different types of operations that you're gonna do.

02:55

We can have sort of more complicated. So we got, negate and multiply. So you take the two together, multiply, um, together, multiply by negative one, and then store that result in SD or weaken do an absolute value.

03:09

Um, or we can do multiple and accumulate. So the destination would be the destination plus S x times s y. And so we can do again all of that in floating point,

03:21

using the

03:22

the M for multiply and accumulate operation

03:29

We can also take and convert from single precision to double precision.

03:34

And so that's the V convert so we can do V convert again. We see a conditional it's optional conditional code,

03:39

and then we can save it into a double precision register or a single position register if we're going up or down.

03:47

So here we're going from a 32 bit register to a 64 bit register, and here we're going from a 64 bit registered to a 32 bit register.

03:58

So you just have to look up the right one so that you can get the right conversion and the right source and destination

04:06

and so we can see here.

04:09

We can take our big, which is afloat, and it's got 1000

04:13

and so we can again load that address. We can use LD R D to load

04:18

those into r two and r three, and then we can move a 32 bit number from our two into s to which is again. You have these of the move command

04:29

and then we can convert that floating point number of S two from a a 32 bit into a 64 bit so floating 32 bit, two floating 64 bit.

04:39

And then when we look at the one, we can see that it has floating 10.64 bit. Number

04:44

is 1000.

04:46

I'm sorry. One million.

04:50

So here's another example. So we can go ahead and we have pie and we have our big number

04:57

so we can load up. I convert that to a 64 bit number in D zero

05:01

and then we can load up big, right? So again, same thing that we did before Convert that into a 64 bit number and then we can do V mole floating 640.64 bit and we can multiply d zero times d one store the result in D two.

05:16

So here we can see d zero is pi d one is a 1,000,000 we multiply them together and get our result in d two.

05:27

And so this I just said a break point and then trace through it using Giff and GTB so that I could look at the values instead of having to necessarily print them off. So the examples very concise.

05:41

So today we talked about some V f p and then yon floating point instructions and how they're kind of Inter mixed together, especially in the arm documentation.

05:50

So looking forward will give an example using Floating Point and we'll look at S I m d. And then in the future we'll talk about some mode and conditional execution.

06:00

So here's our quiz. How would we convert a floating point? 32 bit to 64 bit number

06:08

so we can convert

06:10

the convert?

06:12

We're going to convert to a 60 64 bit number from a 32 bit number.

06:15

We got our 32 bit register in our 64 bit register.

06:20

If you have questions, you can email me Miller, MJ at you and Kate at Utd. You and you can find me on Twitter at Milhouse 30.

Up Next

Assembly

This Assembly language course will provide background and information related to programming in Assembly: the lowest level programming language which is useful in reverse engineering and malware analysis.

Instructed By

Similar Content