SIMD Load and Store Data

Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *
or

Already have an account? Sign In »

Course
Time
13 hours 15 minutes
Difficulty
Beginner
Video Transcription
00:01
Hello. This is Dr Miller, and this is Episode 12.5 of Assembly.
00:06
Today, we're gonna talk about S I M. D or single instruction, multiple data and loading data and storing data
00:13
as I am d
00:15
so single instruction, multiple data as I am d allows processes toe operate more efficiently, so multiple pieces of data can be loaded. And it's more efficient than reading data one word at a time.
00:28
So some examples that you might use it for would include images, movies and encryption.
00:34
And for example, in X 86 we had the MX, sse, and SSE to.
00:39
And so, with the popularity of the MX instructions, Arm added this functionality to theirs.
00:48
So s I m. D loading data
00:51
so we can load data using and store data using two different
00:54
primitives will look at each one of these. So the l, d and V S T. So one will load another little store data
01:02
and allows for the different inter leave patterns so we can do 1234 depending on
01:07
on what our data looks like.
01:10
So here's the VLT are extension register load.
01:14
So we've got DLD are we've got the size. So 64 then we can either loaded a label or loaded a register. So are in.
01:25
We always have our conditional operations that we can have,
01:27
and then we can have a particular offset or a label that we want to use to load the data.
01:34
So here we're going to have an example. So we have a bunch of a raise of different words
01:40
and you can see that these are 123123 And these
01:45
and then this one is cafe fief and
01:48
or is our cab a fief for each of those and then just going down the order so we can see some of the differences?
01:56
So let's look at how this runs.
01:59
So if we execute this first instruction and we print d zero,
02:04
we can see that the VLT 1.8 will load them sort of exactly as they were defined in here. So we get cafe feet, Cabaye fief and Cabaye fief.
02:14
I'm loaded when we look here at the 32 bit sized loading of that
02:21
to go to the next one.
02:23
So we're gonna use the load, the inner leave for two and so basically, it will load.
02:28
Um, every other one.
02:30
And so you can see that
02:31
it got the,
02:32
um
02:35
We got beef and cafe in these, right? And so we got C A and then we skip to and then Effie and then b E and then skip to and then e f.
02:46
And in the 2nd 1
02:49
um,
02:50
Well, yeah, that's how we loaded the data in the 2nd 2 Here, we're loading every other. So you get 2468
02:59
and in the 3rd 1 to get 135 and seven. Right. So those get loaded, every other one gets loaded.
03:06
And then when we do the 3rd 1 so VLT three So we're loading every 3rd 1
03:10
We'll see here are alternated. 123123 And so when you load every 3rd 1 into the different registers using this instruction here,
03:22
we can see that we get an entire set of
03:24
one's an entire set of twos, an entire set of threes
03:29
and your typical example for this one would be so. For example, if you're loading pixels, we have
03:35
three different colors red, green and blue, and so those might be in the data Red, green, blue, red, green, blue, red, green, blue.
03:42
And so when you goto load them it will go ahead and load all of the red pixels in one area, the green and another and the blue and another.
03:51
And so that way, if you wanted to
03:53
maybe just increase the red in the picture where you could just increase those red pixels by loading it in. And then
04:00
during one operation on all of that data at once
04:04
So storing data
04:06
So we got the VSD are so weaken store a particular register and then at the location pointed to by RN. Right. So this is the register that we want to save, and then this is the register holding the base that we want to transfer to, and then you could additionally, at an offset that you could
04:25
specify inside of there.
04:29
So here's an example. So we go ahead and load the values ABC
04:33
de, except for his A a B b, C, C D d. We load that into our zero, and then we use the V Duke Command.
04:41
The basically copied that from here into Q zero Q zero is gonna have
04:46
a, B, C, C d, um, all throughout. And so
04:50
then you know, part of Q zero is D zero until I can save the store 64
04:57
d zero and then are one. And so that'll store I'm 64
05:02
um,
05:04
bits worth in each, right, so we can get to 32 bits that we store in there.
05:10
Here. I just went ahead and printed it off. So are one when we're done with here. When I print the value of our one, I get a, B, B, C, C, D, d and R one plus four. So that's going four bites in. Because this took up four bites, we get a B, B, C, C D d.
05:26
And then beyond that, they're zeros. So I put a post eight and there's nothing stored beyond that.
05:30
So leave it to you. You could take this program in and see if you could save all of Q zero using two V store commands.
05:39
That would be an interesting example for you to try.
05:44
And then we got V S, t n and where n is, ah, number that we can use in order to store it.
05:49
And so again, we can dio inter leavings using the and inside of there and so we can
05:57
save data. We have our condition. That's
06:00
ah added,
06:01
we have our data type. And so the different data types would say there's a whole listing of them. I didn't include them all in the slide.
06:10
Um, different alignments. And so we'll just look at an example here of storing a single end element structure. Toe one lean.
06:17
So here again, I got you know, a a three D a one b one C one.
06:23
So I loaded All those into these registers are one through our four. And then I did a V move of for S zero s one s two in history, right? So these all make up,
06:33
um, que zero or D zero d one.
06:38
And so I can store every other so, too, And we're going to do every other bite.
06:43
And so it's actually pretty easy to see
06:46
what happens here. So
06:47
if I look at Q zero before we go ahead and store the data, we got D c B a. D C.
06:57
Sorry,
06:58
D four c three B two a one and then d 80 70 65.
07:03
So when we look in the output, we can see that it basically takes every other one. Right? So we got D. D is the 1st 1 and then D eight
07:11
and then CC
07:13
and then C seven
07:14
and then BB
07:15
and then be six. Right? So it's kept copying. Here, here, here, here, here, here, right going down the line.
07:23
I de four d 43333
07:27
So, again, the the two means every other so copies every other one. So it's a nen are leaving or reenter, leaving the data
07:35
from what it's stored in in D zero and D one. So if used the inter leave toe, load it, then you can use the inter leave to save it back.
07:43
I'm in the example.
07:46
So today we talked about the S I m. D loading of data and then the storing of data
07:54
looking forward, we're gonna use S I m. D to process data, and then we'll do s, um I d s I m d. Example.
08:01
We'll also talk about some mode and conditional execution.
08:05
So how do you load data into a D sized register with no inner leave?
08:11
So we got V l. D one means no Inter leave. Um, we're going to each bite and then are zero points to our memory. And D one is the register that we want to do. So you could pick any register from Z 02 d 31.
08:24
If you have questions, you can email me, Miller, MJ at you and Katie to you, and you can find me on Twitter at Milhouse 30.
Up Next