So before we write our first program there are some instructions we need to take a look at and we would
look at the op codes we would use in our program for this first program.
We need to be familiar with seven up codes and we're going to take a look at them now.
The first one is to move up code the move operation.
What it does is that it moves data within the process or without access in memory.
And I say in fairness you should know about the move operation not all data can be moved by this particular
operation.
The move cannot move more than eight feet to follow you.
Also the move cannot move to high registers.
Remember when we created registers we demarcated them into lower registers and higher registers to move
cannot move to higher registers.
Let's see an example of this.
Let's say you have this instruction move our 0 1 50.
What this does is that it puts the value 150 in the register are zero.
And this immediate value.
And as we know 150 is within the 8 bit barrier.
Let's take another look at this example.
This another example also you can move one register into another.
And what this does is that it moves the value of one register into the other and makes them equal in
a sense move our one hour two gives us our 1 course are two copies the value of our R2 into our.
This an incorrect example.
Look at this for instance move our 0 2 5 6 and we know immediate value is out of range the largest number
of 8 bits is 2 5 5 2 something like this would cause an era wouldn't work.
Another incorrect example is move R eight.
Number three.
And as you can guess are eight is a high register.
So we cannot use this instruction on a higher register and we cannot use this instruction with values
greater than 8.
The next instruction or OB code we're going to look at the LTE are and what this means is called register
and what this does is it's loads register with either a 32 bit constant value or another register it
reads a 32 bit volume from memory to register remember the move the one we just saw just moves in in
the register it cannot access memory load on the other hand can access memory and it can access other
values in the register as well.
Let's take a look at this example.
We have lowered our sero 0 x f f f this hexadecimal value.
What this does is that it loads this value into our zero and this another example.
It's a bit different from the first one.
Load our icon square brackets are two.
We've not treated pointers.
I know.
We'll talk about them when we start typing in stuff like I always say yes but this is to give you an
overview so that when we type you just remember we did this and oh this is how it works.
So what this means is the R1 is the value pointed to by our team the instruction load are 1 square brackets
are two meaning point R1 to the value in which are to the value contained in R2 let's say R2 let's say
R2 contains the value to 5 6 then our 1 starts point into 2 5 6.
And yes I know I said 2 5 6.
Remember we are using to load up code not move so to 5 6 would work with load but it wouldn't work would
move.
Remember this white 32 bit values whilst we move
8 8 base values.
Let's look at this other one.
This is the store up code.
And what this does is that it stores a register of value into memory.
An example of this is to store our 0 1 stores the value of our 0 into our 1.
Can you tell the difference.
There is a bit of difference.
It looks quite similar to the load.
However if you look carefully at the comments here this one stores the value of our 1 into R2 and 2
Sorry stores the value of our 0 into R1 the value of R1 into our 0 would to store the first register
or the first operant is the source and the second operant is the destination register.
This is the opposite for to load up code.
So our one sorry our zero into R1 is towards the value of Irish you go into R1.
If we replace this with load of the r zero our 1 0 0 is going to be the destination and our is going
to be the source.
So please do remember this.
A lot of people get confused by this.
And the next one instruction number for is to be instruction.
What this means is branch to a location.
An example of this is B loop and you should know this word loop is not a reserved word is a word that
we give it could have been B turn on or b go b stop this one branches it branches two or jumps to loop.
It's like there is a label in our program called Loop remember we said we put labels by our instructions
so that we can access them easily.
So there's a label somewhere called loop.
If we invoke B loop we count the.
And we would see an example of this when we stop right in the code.
Now we have no five B L and this one is primes to a subroutine B L turn on cost to turn on and turn
on this a subroutine that is different from the B and the says the the B jumps to 1 9 instructions.
Yeah.
To put it in simple terms it comes to an instruction location whereas this one comes to a subroutine
you can think of a subroutine as a block of code perhaps like a function in a high level language.
It goes to a series of operations not just one instruction it goes to series and then goes back so detail
jumps to a subroutine and B comes to an instruction the location of an instruction.
So we have the number six this is P x l ah yes get just abbreviations No we start typing them to start
making more sense.
Yeah.
Just bear with me.
This one returns the value from a subroutine core an example of this is let's say we have the subroutine
called Blue on.
So we move the value 0 x 0 1 which is the value one would move it into R2 and then be X L R meaning
it returns the value to the function that was run in before jump into this subroutine its returns to
value after its run.
This code.
It keeps the value of R2 when it goes back to where it's come from.
Yes.
So this one as you can tell would be used in conjunction with a b l mean and when you entered a subroutine
and a subroutine does its processes and it gets a value you might want to take it back and then use
that value and what you invoke is to be X L R returns from separate subroutine blue on.
Yes.
And this the last one this the N O P and it stands for no operation.
Our do nothing assessors here for example Star 1 A.P. A.P. stores the value of r 0 into our 1 do nothing
for 2 psychos 1 annual P of course one cycle.
This is usually used for padding if you want to give perhaps you want to give time to some operation
to perform in a jump to the next operation you can put it where a series of No operation no operations
we would use it if we'll use this when we start.
So these are the first seven up codes that we going to be using.
The first of an instructions would have this in our program.