So welcome back.
This where we left off, we went to the went to the datasheet and the reference my not to get to the
memory locations of Iowa registers of interest, and then we assign symbolic names to them.
And this lesson, we will go ahead and stop right in the initialization, you know, subroutine for
what you call your driver.
So when, of course, that when our application starts, we start from demesne.
Right.
So as soon as we enter the main, we're going to branch into a subroutine that will create.
So over here, I would see our center this a bit
like this.
OK.
So we starts from Maine over here.
As soon as we enter Maine, I'm going to want to see B.L. Branch to the subroutine that we shall call.
We shall call this GPL.
You it in its G.P.A. underscore in its just bear with me as I find a right indentation to use.
OK.
Just bear with me.
I think we are good here.
OK.
So as soon as it starts, Bill, GPL, you, GPL, you in it.
So let's implement this.
This label, GPL, you in it.
Can we do this to implement a label?
OK.
So first I'm gonna be putting some comment to show what this looks like in C language.
So in C we would do it, not in Matosi would do RACC and then we'll access the HP one enabler register.
It would be one E and R.
And then what we're gonna do is add this to the GPL you enable which is your X zero one.
Right.
Zero X or one.
The reason I'm clean in this is, um, I just remembered it will be better if we created a symbolic
name to hold this.
So this we going to create a symbolic name to hold this um this as well as the bits for as well as the
bit for 10 and the bit for certain to output mode in the motor register.
So we can see dot eku you over here and then I'm going to call this GPL, you a enable GPL, you e e
n and GPL you eat and basically means shift one two, position zero.
And um, we can um come over here and do another one.
EKU you and this we shall use to set our GPL you gpl u five.
g.P I will put a pin five to output so I'll call this, I can call this Moate register five more to
five out.
And we do this by we know what we do, we just shift one two position number ten like this because we
have to set a bit ten in the register.
One together is to save us output and then we can have early on we can have a symbolic name though.
Ten on the ality would do eku you
LCD naledi underscore on and then this.
We simply know we set bitta number five to one to ten on the LCD.
We can do LHD off if we want.
And I know you will guess what that is set in bits five to zero.
Simple as that.
So not only have this symbolically, we can copy this and then.
Okay.
So in our comment we know to enable GPL, you put a we do this in C language.
Okay.
In assembly, what we do is they load.
Load operates and then right back to memory.
So we're going to load this into a register, RSU, we're going to load this.
We're going to load the address.
So I'm gonna start off by saying I use the cups yellowed are zero comma.
And what we want to load is it'll be one enabler register.
RACC, HP, one, and they registered this one here.
We want to load it into our, you know, one, this means load the address of, you know, HP one.
I think I should put comments here,
load address
of our RCC, HP one E an R to our zero.
And we know that we know this is the address.
This symbolic name hosts it.
And once we've done this, what we want to do is load the value at the address found in our zero into
our one.
So what we want to do in layman's terms, we want to get the current content of this register, which
is the memory location.
This memory location, which is out in these two numbers.
Want to get it?
Current content of that.
And another way of saying dice load value at address found in register eiris.
You go into our one because register Ansaru has the address.
We want the value at this address.
We want to load down to our one.
Yeah.
If you don't understand this, if you don't understand this, just leave it to the questions and answers
area.
OK.
So I'll just say it as found in our zero into our one.
Right.
To do this, we do load and then we do our one like this and then square brackets.
Ursu.
OK.
So then our one now would have the current content of the memory location which is the RACC underscore
each one and they will register.
So what we want to do is we want to perform on all operation with our GPL.
You enable and by performing our operation, we don't change the current content.
We just add one new bit and enable to its current content.
So what I'm gonna do is c take the content of register iris you are it with GPL you enable and start
A resorts back into our zero.
So I'll see all over here.
Sorry.
Take the content off register.
Ah one course after this instruction we'll have it into our one will have the value in our one.
Take the content of register our one or it's with GPL.
You enable the symbolic name here.
It's an immediate value.
So we use this pound sign and then put a resource back into our one.
OK.
I'll see you over here.
There is no relevant comment here.
I think this is straightforward.
OK, so once this is done, after this, we should have we should have the right the right bit arrangement
to set the pin.
We have to write to back to memory.
So after this, the contents of our one would have a one new 30 turbit's value that.
Would that preserve the initial status of the HP one enabler register as well as enables GPL, you put
it so well, we have to do next is C store the content in our one at the address found in our zero.
OK, yeah.
We make an assembly sound like it's just normal English language.
We say store the content in our one D address found in our zero.
This should be one no exclamation.
Goodness.
Losing it.
OK, so how do we execute this?
We use the stall operation.
This instruction, we say stall.
And then this is the saucer.
And this is the destination.
Stored content in our one at the address found in our zero.
OK, so after this we would we would we would have enabled or would she tell you a clock access to G.P.A.?
You put it.
The next thing we have to do is set a wire.
GPL your mode.
Register one a set.
You call you P a five to output pin.
So next we have to do GPL you a mode register and then we want a pause mode five out to it like this.
So we start off Habbo.
You post the video and try to do this.
Given what you've seen with this, try to do this on your own.
And once you've tried, we can do it together.
OK, so to do that, we do load.
And then we do our zero e course GPL you e underscore mode register.
I'm not going to comment this much.
And then we do load our one piracy row and then we do the all operation, all oh we do our one with
mode five out this constant that we created.
And then finally we store back to memory, which is the register which is.
Yeah.
The memory address stored in the register store R one.
R zero.
OK.
Right.
So after this we would have GPL you.
Put a PIN five set as an output pin.
And if you do not understand how this accomplishes that, then please start watching the video from
scratch again.
Or maybe it's in the Q&A area.
But I'm sure by now this is like very straightforward to you.
OK.
Next, we need to turn on the LCD and what we do to turn it on is basically set bits.
Number five in the output data register to one.
So in some language, BABYMETAL would do GPL u.
Oh.
Ah.
And then if we want to do friendly programming, we can do this early on.
But if we don't care about the other bits, we can simply write this to it.
And this vertical line, if you've noticed, for those of you with, um, you know, those of you who
can.
Yeah.
Analyze, you realize that this is equivalent to our operation that we always do here.
So if I remove this, for instance, in this example, we want to use this.
So we wouldn't need to do it at all.
So let's see how this would look in assembly.
I would simply to load RC room and then the GPL, you A or D r.
Once that is done, I'm going to load ality on into a different register early on here.
I'm going to load this into rates that are one.
So lowed register R-1 because early on like this.
And once that is done, I'm simply going to store what is in register our one at the memory location
held in register ARVA zero one over here in our zero.
Right.
And once this is done, we can return from our subroutine by doing B LR because we are done with this
subroutine because they allow me to return.
OK.
And then we can use the end directive to indicate with ended.
Right.
Okay.
So this is our program so far.
It starts from Maine and then its branches to the subroutine.
Are you in it?
And then when it enters here, it would it would enable clock access to G.P.A..
You Port A..
It would, um, it would set GPL, you put a pin five two outputs pin and then it would set GPL.
You put a PIN five output data register bits five to one.
And this would turn on the LCD because the LCD connected to P five.
And then would return from the subroutine.
And this is just to indicate this the end of the assembly file.
So what we want to do is, yeah, we can leave here.
Let's build a SC applicable here to build and let's see how many arrows we've created.
Okay.
Right.
We have arrows with a symbolic name assignment.
OK.
So the reason why that is.
Yes.
So us you do this as this becomes your job and you do this, you stop mixing syntax.
The syntax is different in the arm assembler.
Over.
Yeah.
When you do that, EKU you and you give your new name.
You've got to put a comma here.
So let's just put some commas.
Let's see if this fixes the arrows.
So I could put comma.
I have a comma here and then comma everywhere.
Okay.
I think I may have clean motor.
OK.
Come here as well.
Comma here, comma everywhere.
Everyone gets a comma.
Coma and then.
Now, let's see what we have a quake to build.
Let's see how many arrows we have left.
We have four.
OK.
Was the cause, the C o r one.
This is on shifted register required on shift, shifted register required or one d or shift to register
required.
Is that right?
The reason for this error is the lack of farm.
I'm not a directive.
We're going to add another directive to indicate the syntax we use.
And so I come over here and see what the syntax over here and I'll say a unified, unified like this.
OK, so let's build and see.
Click over here to build.
We have two arrows, he says.
Let's see.
It says on define symbol mode.
Five out the C word, five out.
Let's see, maybe we have a typo.
OK.
Over here to return mode four is what five control is to save.
Click over here to build.
It's in.
It's built successfully.
Okay.
Looking good.
So we've reached an energy plan with driver in assembly.
Let's see if it runs.
And if it turns on the ality, I'll click over here to go to debug.
And then click this and then.
OK.
It's open and I'll say, okay, over here.
It's downloading.
Okay, it's done.
Click here to run.
And my LRB is on.
OK.
So this the end of this lesson, if you have any questions at all.
Just leave it in the questions and answers area.
And I hope you're enjoying the course.
This is really simple.
If you have any questions, just leave it there.
Or if you leave it in the Q&A section and you'll note receiving a quick response, you can message me.
Just remember the directives, the directives and then the symbolic name assignment and then the rest
of the comment states here very step by step.
OK, that's all a simulator.
So for those of you who are watching this in the Cuban mics can remix Cuba Idee e course if you want
to land more ebow assembly programming and how to write drivers for other peripherals like the ADC to
Taimur and to land the complete assembly program.
And you can take a look at the Amah Assembly programming course.
There is part one and part two.
And after that, you'll be able to write your complete firmware in assembly before.
So if you're watching this in the ARM Assembly course, just to show you how to create the project and
cube I.D. E, then you already know what I'm talking about.
But we are going to we're not going to dive deeper into assembly.
This is just to show how one would go about creating assembly assembly projects in Cuba.
The next one we're gonna do is we're going to take a quote created in the Carl MBK using the arm assembler,
and then we're going to bring it here and change it to run on Diesem Cube Idee, which uses the GCSE
assembler so that we can see that it's basically the same thing.
We simply need to change a few directives.
So we're going to do that now.