13 hours 15 minutes
Hello. This is Dr Miller in this episode 12.6 of Assembly.
Today we're gonna talk about S I m d. And we're gonna talk about processing data,
so processing data,
so we'll give a
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.
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,
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.
So here we load into our zero some data. So I got
01100 to 20 and then we got alternate all zero efs in our one.
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,
all right, And then we're gonna do the max you ate.
So we're doing unsigned eight bit pieces of data
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.
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
on each one of these. So the max between 20 and F
is 20 and so that's the result that we get. And the maximum between two and F is f.
The maximum between 10 and F is f, and the maximum between one in F is f
sorry wanted? Yep.
Um and then we can see here we again do 20 and f get 20 and then
in f We get f in 10 enough. We get 10 and one in f we get f.
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.
If we did right then would get a different result If we had that sign Bit set. So we had anything
from a through F as the first digit, then we would have had negative numbers fit some of those.
We can also do addition on multiple elements at once. So we got vector add or V ed
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.
Um and then we can either operate on the Q registers or we can operate on the D registers.
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.
So it goes down the line and adds 1 to 60 gets 61 12 50 get 51 12 40. Get 41.
So on down the line right so each one gets added in its own column. And then that result is stored in D two,
which was the destination that we chose here.
So here we're able to add eight distinct numbers all at the same time with one instruction.
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.
So here we can actually do even two things at once, right? So we can multiply by a scaler and then doing accumulate.
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.
So we got our data type image or 16 or 32 floating 320.32.
Um, we got our destination and our, um
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.
So here again, we can see loading d zero d one d two.
So if we kind of looked down the line, we have, um d zero has 1234
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.
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
Right. And so we're gonna take four times three. That gives us 12. Add that to a zero. We get
a c. So 12 and hex see,
four times five is 20.
Add that to the B zero. We get 20 and hexes 14.
Four times seven is 28. So that's one C Add that to see
with the zeros and then four times nine is 24 in hex.
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.
So we're able here to do
four operations for multiply and then four additions, all with one instruction,
a lot more useful. Right here. We have
a total of two for 67 instructions. But we did eight things,
Um, with just seven instructions.
Another example is vector exclusive or
so your as it's called
so we can do exclusive or we got our destination register and then are two sources Q and Q M or
D N and D M. Right? And so we're going to use those when we do the,
um, exclusive or operation.
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.
So if we load in some data with D zero and D one, So this has 5365 right, and this has 616 f
so on and so forth. If we exclusive or them together
right, you can expand all those bits. And so if you take 53 and 61 and exclusively or them together, you get 32.
Um, same thing here. Right? So you go through and we'll store that result in this register.
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
notice that if I take these two
our result here is the same as D zero.
So the exclusive or is a reversible process, right? So if we exclusive or
two pieces of data that were in part of this will get the third piece out
And so one of the things that will do in our example next time is we're going to do an encryption example.
And so almost every piece of encryption uses exclusive or in some form or fashion.
So what you end up doing
is he generate a set of bites that you want to use is your encryption key
and then you exclusive or them with your original plain text to get your encrypted text
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.
And so That's what we'll be doing in the next song when we do our example.
So today we gave some examples of some s I M D instructions that allowed us to do some processing on data
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.
So quiz, How does s I m d create faster performance?
So it allows us to possible multiple pieces of data with one instruction.
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.