Assembly

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

Video Transcription

00:00
Hello. This is Dr Miller, and this is Episode 11.10 of Assembly.
00:05
Today, we're going to do an armory example and using indexes.
00:10
So our array example. So what's our problem To be solved.
00:13
So what we're gonna do is we're going to create two strings and then we're gonna copy data from one string into the other, and then we're going to use our right back functions.
00:23
So I've already set up my project.
00:26
So let's let's define our strings here.
00:34
These air ask e. And this is this.
00:43
I'll put an exclamation point, a nice new line in there and able to find our next message.
01:03
Okay,
01:11
so we'll want to push our registers
01:17
and pop them.
01:19
That's only one will need.
01:21
And so then what we're gonna do is we're gonna go ahead and load our messages into registers, so load the addresses
01:29
going to use our one for the 1st 1
01:34
and I'll just use our five for the second,
01:40
okay?
01:42
And then
01:45
what we'd like to do is we would like to check for a null terminator that will tell us when we need to stop. So we'll go ahead and use move use are too
01:53
tohave are no Terminator, which is a zero.
02:01
Okay, And then we'll have our loop here. Here's the top of our loop. When we're all done,
02:07
go ahead and print off our string.
02:14
So we're gonna print off string, too. But we're gonna copy the data from String one,
02:20
so we should get string one.
02:27
Okay,
02:29
so in our loop, at some point at the end, we'll branch back up to the top,
02:35
and then we have to do our loading. So what we need to do is we need to load from message one the piece of data, and then write it to message to so we can use LD R
02:45
We're just gonna load a bite.
02:46
We'll use our zero will be where we're gonna write it to.
02:52
We'll copy the data from our one,
02:53
and then we want to have a right back when we're done until increment by one.
02:59
That's for a character.
03:00
And then, in order to store the data, we want an eye right back into
03:05
register five.
03:07
So store bite
03:10
are zeros where we loaded the data
03:13
and then we're going to use our five,
03:17
and then we also have a right back of one. And so this will automatically upto date pointers in our one in our five
03:24
to the new locations.
03:27
And then after we've written, the data you need to compare
03:30
are zero and are too to see if they're equal.
03:36
And so we'll branch if they're equal to label done, and then if they're not equal here, no branch back up to the top.
03:44
And so, as you can see, unlike our normal examples, we don't have to update our one and are fine, Frank, because we have the right back, which will ensure that the pointer gets updated by the appropriate amount. Here, we're doing bites. So we're only in committing by one
03:58
for each one of these. So this should copy all of the characters in this string to this string,
04:03
um, while putting in a no character in there. So I made sure that my second string was longer so that I had plenty of room.
04:15
And as you can see, it printed off the first string even though when I look at the code reprinted off the second string
04:21
and so we copied the data from the first string into the second string and then printed it off.
04:30
So today we saw an example using copying of a string. And then we used right back with our load and store
04:36
operations in order to make sure that the pointers got updated.
04:42
In the future, we're gonna look at loading and storing multiple registers from to and from memory.
04:47
If you have questions, you can email me Miller, MJ at you and Kate I e. To you, and you can 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