Everybody.
Welcome to next video.
So in this video and be going over variables in assembly.
Now when dealing with variables we have to understand some data types.
So on the screen here we've got a few different data types so the first one is byte which we've been
using before is as DV or defined byte which is how we've been holding our strings so a byte is 8 bits.
And what's important to understand about any of these is that when you don't use the full eight bits
16 30 to 60 for 128 for each respective data type you're going to you're going to have the rest of that
bit set.
So if you use for example four bits out of the eight of byte it's going to fill the last four with 0
0 0 and that's just so that the whole data set is filled by the time it goes into memory.
There's just something to keep in mind so that's why you'll see zeros filled in place instead.
Now we have a bite that's eight bits a word that's 16 a double word is 30 to a quarter word sixty four
and a double quad word is 128.
Now we're going to be dealing with define a word or defined byte and defined word which is D.W. in D.B.
exclusively in this particular course.
Just understand that if you need more room for the data you're holding then you're going to need to
move to some of these other data types.
But for this course we're going to be working on D.B. for defined byte And D.W. for defined word.
So what we've done here is we've already got our template.
We've got our author up here we've got our global start our start and we've got our return code.
So the first thing I want to do is set up some variables.
So we'll do.
Defined by and we'll call this defined by one.
And this is going to be D.B. we're going to give it R and we'll do 0 0 8 for our new line.
We'll go ahead and define byte L for length and we'll do a little cheat here find byte 1 defined by
1 L then we're gonna wanted to files to find another byte so define by 2 which is D.B. we'll do Red
Team nation with us the space there 0 0 0 for the new line define byte 2 L equals fine byte 2 and let's
define a word.
So define the word just D.W. I'll give it a little bit bigger of string Red Team nation rocks and I
will do 0 0 for our new line and then of course we need the length final word.
L
equals.
Define the word perfect.
So now we've got our strings and variables all set up.
So let's go ahead and print this out.
So there shouldn't be anything new.
So we'll do move x 0 x 4 for the write command.
Now we're going to move easy X because we're going.
We don't need to mess with the file descriptor in this particular case.
So this is going to be defined by one and then move X we'll do define byte 1 length.
Then we need to make sure we do our interrupt Xerox 80 to actually execute the Sisko.
Next we're gonna move a X into zero x 4 or foreign zero.
Are X the reason behind this is when you execute as this call the return value of that this call is
moved into e x.
So if you just decided to think E X was going to still be there what you would do is you get the first
one printed and then it wouldn't print because it would try to execute another system call with whatever
value the return code was from the right and try to execute it that way.
And in most cases return is gonna be zero so you'd be doing an exit or you'd be doing a separate switch
called but not an exit so we're going to move you see X and we'll do defined by to move 80 x is defined
by two length and then we'll do our interrupt Xerox 80.
Now we're going to define our last one.
So move x 0 x 4 move FCX to define word and then move ADX
define a word in like and interrupt 80.
Perfect.
So let's go ahead and compile this and see how it works.
So Nazism dash F E F main assembly
as Nazism.
Oh see we got a undefined undefined by D.
Fine.
OK well I copy this.
Here we go.
Yeah.
Perfect.
No go into our linking LV.
Dash M E L F on the score I 386 Dash.
Output is main and then Maine.
Object and run me.
Perfect.
Now we can see we're printing out R which is our defined byte 1 then.
Red team nation which is our defined like two and then our defined word is red team nation rocks.
So we've gone ahead and used variables which we've done before but we didn't really talk too much into
it.
So go ahead and play around with this change some of the strings up see how big you can get this string.
And add a whole bunch of extra text to it that's more than 16 bits and see see what happens with that
result.