Assembly

Course
Time
13 hours 15 minutes
Difficulty
Beginner
CEU/CPE
14

Video Transcription

00:01
Hello. This is Dr Miller in this episode 12.6 of Assembly.
00:07
Today we're gonna talk about S I m d. And we're gonna talk about processing data,
00:12
so processing data,
00:14
so we'll give a
00:16
We'll give a few examples here. So we got our vector paralyze Maximum and Beck Vector pair wise minimum. So we'll look at the's in examples.
00:25
So we can either do a pair wise men or Max. So that's the operation that we can do, And then we can have a particular condition again. And then the data type Either signed 8 16 32 or unsigned 8 16 32 or this could be on of 32 bit floating point number,
00:44
and then we'll have three registers or destination are in an M, which are are two sources that we're going to use for the example.
00:54
So here we load into our zero some data. So I got
00:58
01100 to 20 and then we got alternate all zero efs in our one.
01:06
So I take are zero and save both of them to s here on s one. So that's the bottom half of the bottom and the top of D zero and then are one goes into s two industries. Those are the two parts of D one,
01:19
all right, And then we're gonna do the max you ate.
01:23
So we're doing unsigned eight bit pieces of data
01:29
and we got are two sources and then our destination. And even so you can see when you look at this, I got d zero and d one.
01:36
I
01:38
I filled amount, So they're all the same. So it's easy to see so we can see what it does is it takes it looks a d zero and d one, and then it does a maximum
01:47
on each one of these. So the max between 20 and F
01:52
is 20 and so that's the result that we get. And the maximum between two and F is f.
01:57
The maximum between 10 and F is f, and the maximum between one in F is f
02:02
sorry wanted? Yep.
02:05
Um and then we can see here we again do 20 and f get 20 and then
02:10
zero to
02:13
in f We get f in 10 enough. We get 10 and one in f we get f.
02:17
All right, So went down the line. And for each one of these, it calculated which of these was the maximum using an unsigned number. And so we don't have negative numbers.
02:28
If we did right then would get a different result If we had that sign Bit set. So we had anything
02:35
from a through F as the first digit, then we would have had negative numbers fit some of those.
02:42
We can also do addition on multiple elements at once. So we got vector add or V ed
02:47
again, we have a condition. Then we have some data type. So we can either operate on 8 16 32 64 or floating 32 bit numbers.
02:58
Um and then we can either operate on the Q registers or we can operate on the D registers.
03:05
So here we go ahead, and we're gonna load up here is D zero and then here is D one and then we do V add on both of those to get the result.
03:14
So it goes down the line and adds 1 to 60 gets 61 12 50 get 51 12 40. Get 41.
03:21
So on down the line right so each one gets added in its own column. And then that result is stored in D two,
03:27
which was the destination that we chose here.
03:29
So here we're able to add eight distinct numbers all at the same time with one instruction.
03:36
And if you think about if we were going to do this bone bite at a time, then we would end up having at least eight instructions to do each additional add on each one of those bites.
03:46
So here we can actually do even two things at once, right? So we can multiply by a scaler and then doing accumulate.
03:53
So you multiply D n times the m X. So we'll see that here in a little bit. You multiply those two together, you store it and then add it to whatever is in the destination.
04:04
So we got our data type image or 16 or 32 floating 320.32.
04:10
Um, we got our destination and our, um
04:15
yep, our destination register there, and then we've got the scaler that we want to do. Sorry, we got our destination, and then our source of the operation that we're gonna do the multiply.
04:28
So here again, we can see loading d zero d one d two.
04:31
So if we kind of looked down the line, we have, um d zero has 1234
04:38
Um And what we're gonna do is we're gonna multiply by d zero, the third element. And third, starting this is 012 and three. So I've underlined it. So we're gonna multiply by four.
04:49
So we're gonna take every element of the one. We're going to multiply by four and then added to what's in D two. So d two had a 000 b 000 c 000 d 000
05:01
Right. And so we're gonna take four times three. That gives us 12. Add that to a zero. We get
05:08
a c. So 12 and hex see,
05:12
four times five is 20.
05:14
Add that to the B zero. We get 20 and hexes 14.
05:18
Four times seven is 28. So that's one C Add that to see
05:25
with the zeros and then four times nine is 24 in hex.
05:30
Um, and then add that to the D so you can see that it was able to do this multiplication and then add it to the accumulated register inside of D two.
05:40
So we're able here to do
05:42
four operations for multiply and then four additions, all with one instruction,
05:48
which was
05:49
a lot more useful. Right here. We have
05:51
a total of two for 67 instructions. But we did eight things,
05:58
Um, with just seven instructions.
06:01
Another example is vector exclusive or
06:05
so your as it's called
06:09
so we can do exclusive or we got our destination register and then are two sources Q and Q M or
06:15
D N and D M. Right? And so we're going to use those when we do the,
06:20
um, exclusive or operation.
06:26
So
06:27
here we go ahead and we load in some data, so we'll just look at the data before and after and see how that works.
06:32
So if we load in some data with D zero and D one, So this has 5365 right, and this has 616 f
06:42
so on and so forth. If we exclusive or them together
06:46
right, you can expand all those bits. And so if you take 53 and 61 and exclusively or them together, you get 32.
06:53
Um, same thing here. Right? So you go through and we'll store that result in this register.
06:59
So then what I did is I showed that if we take d one and D two and we exclusive or those together store that Indy three
07:08
notice that if I take these two
07:11
that
07:12
our result here is the same as D zero.
07:16
So the exclusive or is a reversible process, right? So if we exclusive or
07:23
two pieces of data that were in part of this will get the third piece out
07:29
And so one of the things that will do in our example next time is we're going to do an encryption example.
07:34
And so almost every piece of encryption uses exclusive or in some form or fashion.
07:41
So what you end up doing
07:42
is he generate a set of bites that you want to use is your encryption key
07:47
and then you exclusive or them with your original plain text to get your encrypted text
07:53
and then to get your original text out, you again take the key and exclusive, or it with the encrypted text, and you end up with your plain text again.
08:03
And so That's what we'll be doing in the next song when we do our example.
08:11
So today we gave some examples of some s I M D instructions that allowed us to do some processing on data
08:20
in the future Will give an example that encryption example of S I m d. We'll talk about some mode and then conditional execution.
08:30
So quiz, How does s I m d create faster performance?
08:35
So it allows us to possible multiple pieces of data with one instruction.
08:41
If you have questions, you can email me Miller MJ at you and Kate I e d u and find me on Twitter at No House 30.

Up Next

Assembly

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

Instructed By

Instructor Profile Image
Matthew Miller
Assistant Professor at the University of Nebraska at Kearney
Instructor