 Welcome to the session 7 of ARM development course. I am very happy to interact with you again. So, in this class before I start teaching you more on instructions how to use them for different purposes. The most important thing is for us as a programmer should be able to provide some values or constants along with a program into the our code ok for the instructions to execute. So, that will involve these two operations ok, we we may do some operations the barrel shifter in the CPU may do some rotate or shift operations or we will be providing some constants which will be used internally in the program. Now, today we will concentrate only on what are the different ways ARM accepts the constant values and how it operates on them ok. So, this is the start oflearning the instruction set because this is going to be there in every instruction that you may encounter especially all the data processing instructions will have some may have some constants which are passed along with the instruction. So, I thought first I will explain how what are the different ways that can be provided to the instruction and it will be mixed with any other data operations ok. So, I all of you I want all of you to pay attention to this it is very interesting part of the instruction set and I wish you will understand follow this and then try out all this in your simulator then you our concepts will become much more clear ok. So, let us get into this. So, you know what all different operations could be performed you might have studied in your batches course given a 32 bit data what do you have in a register we could do various operations on it you could shift it to to the left the big positions or we can shift it to right there are two ways of shifting one is called logical and arithmetic. If you know in arithmetic shift the specific important thing that we need to pay attention to is the sign bit of the value and all of you are by now familiar with two's complement I suppose and for an example if suppose you have a number ok 1 1 0 sorry about 0. So, be ok assume this is a 4 bit number you know that this is a sign bit right. So, if it is a sign bit a signed number it will be interpreted as a negative number then how do you find out the actual value you find the inverse of all this and add 1 to it which will be 0 0 1 1 plus 1 will be 1 0 0 that is minus 4 ok. Now, now suppose if I do a shift right ok what I am I doing I am making the MSB bit position to the lower side of the bits. That means, I am actually reducing the value if I right shift it by 1 I am I am actually reducing it or dividing it by 2 ok. So, it should be it should become like this ok when I right shift it it should become 1 1 1 0. Now, what is this value you again do the same thing is it a negative yes even after shifting it turns out to be a negative value because MSB is set. So, how do you find out the equivalent number of this you complement all of them 0 0 0 1 and then plus 1 you do then it becomes 2 that means, minus 4 here has become minus 2 here by shifting it by 1 bit to the right. So, this is what is called arithmetic shift right ok. So, what do you what do you need to do is when you are doing a arithmetic shift you are interpreting this number as some binary number and it could be a signed or unsigned number. So, if it happens to be a signed number I you want to preserve the sign bit of the number. So, when it is doing the shift it should move the same sign bit along with the numbers. So, effectively that is the difference between arithmetic shift and a logical shift right. What is logical shift right? If you do a logical shift right this will become 0 1 1 0. So, you are not preserving the sign bit this is called logical shift right whereas, this shift is called arithmetic shift right. Now, you may wonder why there are no arithmetic shift left let us try. Now, when you want a number to be shifted where you are actually multiplying by 2 why because this bit position whatever is a number if it moves to the left it is gaining more value in terms of value it is gaining more. So, when you are shifting it this way you will be filling it with 0 here on this side. So, suppose this is the input no minus 4 you have taken and then you are shifting it right left you will be making it like this. So, you are back will you know the right side it will be filled with the 0. So, it is same as logical shift left that is why there is no separatelogical shift left, but there are two different rights it could be logical shift right or administrative. Now, how does the programmer inform the processor they have to mention a particular acronym in the instruction. So, that processor knows whether it has to sign extended or not ok. So, this is very important thingyou should be familiar with before we get into this. So, I thought I will explain you this ok ok. Now, apart from this there are so many other ways this can be done different operations could be done let us see all of them in this class ok. Now, let us first to see what is the general format of a data processing instruction you have to remember the data processing mean it could be any of the operations even move operation is a data processing instruction, but it could be and I am not sure whether you will be able to see from your seat, but I will read it out for you these are all different operations binary Boolean you know operations and exclusive or subtract or add or add with carry or compare or move they are all called data processing instructions. Now, what am I showing here this is the format of an instruction if you remember the ARM instruction is of 32 bits wide all instructions are of 32 bits. So, you should remember that. Now, what is where is this instruction store it is stored in the instruction memory and it is stored 4 byte aligned address and R 15 which happens to be a program counter accesses the memory and then touches this particular instruction any any instruction which is there in the memory and now after fetching it goes into the decode set stage of the pipeline where this instruction is interpreted. Now, for a decode logic to understand the instruction you should have a standard format which is unambiguous. So, that the decode logic will be able to understand what is being conveyed in this particular bit of information which happens to be one instruction. Now, let us go one by one. Now, what are these 4 bits this is called conditional fields. What is this? If you remember I mentioned that every instruction can be combined with a condition that is if that instruction needs to be executed or not whether that instruction has to be executed always or it has to be executed only when some condition is met. If you remember I mentioned that add EQ that means, add instruction will be executed that addition will be performed only when 0 flag is set. So, when that particular execution enters a execute execute execute state stage of the pipeline the processor looks at this 4 bit value and based on this it decides whether it has to be executed always. If it has to be executed always it should be filled with 1110 otherwise it has if some other condition will be there which will be comparing with the CPSR flag and if it satisfies it will execute the instruction otherwise it skip the instruction. So, that is why the conditional flag is sitting here. Now, what is this 0 0 it is implied that this is a data processing instruction and then comes. So, once it is a data processing instruction the rest of the things are you know interpreted the different way. This is not the standard format may be the R and other register locations are fixed, but other play bits will be modified or changed based on the particular instruction which are which is being considered, but it will be unambiguous between one instruction to the other instruction. So, now we are showing what I am showing here is the data processing instruction format and then after this 0 0 is encountered then it will know that ok this is a data processing instruction which is coming in. Now, let me see what is the value of I here. So, this is I is a immediate operator ok. So, if I equal to 0 it will interpret the toll bits of the lower toll bits of the instruction as a 8 bit shift operation followed by a register R m. Now, if you remember again R m is a one of the general purpose register. So, how many registers we have in the ARM processor 16 registers. So, it could be interpreted as 0 0 0 to or 4 ones. So, 0 to 15. So, based on this number it will either pick up R 0 R 1 R 2 R 50 whatever is the instruction which is mentioned here. Now, what is R m R m is the second operand to the ALU ok. So, if you remember there are two operands that can be fed to ALU one directly coming from the register file to ALU the other one comes through a barrel shifter. If you remember again the operation that barrel shifter does it does it in one cycle you know the first phase of the cycle and then operand is made available to the ALU the second operand and first operand is directly read and then the result is returned back into R g. Now, whenever I say R m you should know that the operand which is coming from register file is directly fed to the ALU it does not come through any ALU or any mode of the barrel shifter or anything ok. So, it is directly fed into the ALU R m is the other operand which is called operand 2 we come through barrel shifter. Now, barrel shifter also may do some changes to R m or based on the instruction it may have not have any impact of R m it will be a short circuit then R m will directly come into ALU. I will show you different examples where you will be able to map this with the actual instruction. Now, what is the result coming out that result coming out of the ALU has to be written into R g that is a destination. So, it could be written into any registers one among the 16 registers that can be written into ok. So, you know R m R m and R d are all 4 bit wide in the instruction format. Now, where is it located R m is located here R d is located here and R m can be here or it may not be there if suppose I e happens to be 0 there is no R m mentioned it is a direct immediate value. Now, what do we mean by immediate value? The immediate value means it is part of the instruction. If you see it this whole 12 bit content is has come from the instruction that means, it is coded by the assembler into the instruction and it is kept in the memory that is instruction memory and when the processor was fetching the instruction it has come along with that. Now, if suppose a operand is coming from R m one of the then that means it is using this instruction is using a already existing value in one of the registers as a operand ok or it could take both things that is some part of the you know instruction some part of the operand is taken from R m and then what operation need to be performed on the contents of R m is provided by the constant that is it is as come with the instruction which which is interpreted in a different way and I will explain you in the subsequent session here today. So, barrel shifter takes this value and accordingly it operates on this R m and then gives the result into I L U. Now, how does I L U know what it is supposed to do with these two operand? Because it can it knows that ok R m is coming from this number and R m is coming through barrel shifter are directly, but what is that arithmetic logic is supposed to do? It could do add or subtract or move that is what this opcode is for this field this is again a 5 bit field sorry 4 bit field which will explain what operation it is supposed to do on the operands ok. So, this much you understood now let us see what is this S for if you remember I mentioned that in the instruction you can say move or move S and I say move S that means, that this execution of that particular instruction will impact the CPSR flags the conditional flags which are the conditional flags carry flag 0 flag or negative or overflow flag. So, if this bit is set suppose if you are mentioning your instruction move S then assemble will set this bit 1. So, then what will happen the processor will know ok the programmer wants this instruction to affect the CPSR flags. So, whatever operation is done based on what is the results coming into R D it will set those flags. Suppose if the the programmer has not mentioned S in the instruction then assembler will interpret it and make this bit as 0 then processor when it looks at it it will know that ok this instruction is not supposed to impact the CPSR flags. So, let me not change anything with the CPSR and do only the operation what is you know requested by this instruction. So, this is the way the processor interprets the instruction and this is the way the assembler encodes your assembly instructions into a binary format and it fits into a 32 bit format. So, the processor understands that and accordingly acts on it ok. Now, there may be two possibilities in in yesterday's session in last session I mentioned that the move operands are move instructions are single operand instruction, but you may wonder that there are two registers mentioned, but I say it is single operand. Please remember here operand is only this R 1 R 0 is always this particular value mentioned here is a destination register it is not an operand ok R 1 is moved into R 0. So, there is a only single operand coming. Now, please remember R 0 or R 1 is a anything it could be from R 0 to R 15 any one of this based on the values of R D. Now, R 0 is what it is actually R D here. So, if this instruction has to be there R 0 would have been R D would have been coded as 0 0 0 1 that means, sorry all 0s that means, it is R 0 and R 1 is what always in a single operand instruction that operand is assumed to be R m not R n. So, wherever R m is supposed to be that place it will make 0 0 0 1 to indicate that ok this the it is a single operand instruction and the operand happens to be a R 1. So, there will be 1 here and to indicate that destination register is 0 there will be a 0 here. Now, what happens to R n R n will be ignored ok. How will the processor know that it has to ignore R n because R n also can have any value from 0 0 to 1 1 1. So, it is a valid value, but based on the op code it will know that ok MOV is supposed to have 1 1 0 1. So, if op code is 1 1 0 1 it will not look at this value here and it will know that it is a MOV operation. So, it does not have 2 operands. So, it is R n is ignored. Now, you may wonder why in a single operand instruction R n is not considered and R m is considered because you have a flexibility here only with R m that you can do some of barrel shifter operation before feeding it that value into the ALU. Now, for a MOV instruction what is the need for ALU to come into picture because this is the way it is structured. So, if it is a MOV ALU will just pass on this value out to R d. So, it will R m will come if barrel shifter operation is required based on suppose some you know LSL or something else you have mentioned here then it will operate on that R 1 and then pass on this value to R d and it will go to register back bank again back to register bank. So, this is the way the ARM processor inside interprets your instructions. Now, what about 2 operands is a simple example R 1 and R 2 are 2 operands then you will easily you will be able to map it R 1 is happens to be R n. So, in the location of R n it will have 1 and then R 2 happens to be R m. So, in this location there will be 2 and R d happens to be 0. So, R d will be 0. So, and opcode will say that it is a add instruction. So, wherever add is it will be here 0 1 1 0 1 0 0. So, that opcode will be put. So, that is the way it is interpreted I hope you understand this. Now, I have shown one more arrow here this is a immediate value which is coming along with the instruction. Now, you have to remember when this instruction was fetched it has come along with the instruction. Now, this is executed after 2 cycles in the execute stage that time this value is passed on to the pipeline registers and then made available to the barrel shifter by taking out this value which was there part of the instruction and then it is fed to the barrel shifter. So, that it can operate on now how this immediate values are interpreted is what is going to be explained in this session ok. Now, let us go one by one. Now, operand is actually this operand 2 field this is completely a 12 bit field ok. So, based on the value of i if it is 0 it will be interpreted that 8 bit value is used for shift related operation and this is the register value that is R m which is the input to the barrel shifter. If suppose i happens to be 1 then if this instruction will be the 12 bits will be interpreted this way that means, the complete thing is immediate constant there is no R m here. So, it is not taking any value from the register everything is coming from the immediate constant only and then some operation is performed by the barrel shifter on this immediate operand and then given to the ALU. So, this is what you see at a another arrow coming to the barrel shifter in the previous slide. Now, let us see what all you can represent. Now, immediate operand may be a register as I mentioned it could be a register or an immediate value ok. Now, based on the i bit it will decide ok. If it is i bit is 0 it will interpret this bit combinations as you know R m followed by a shift operation otherwise it will be interpreted except values like first 8 bits will be interpreted as some immediate constant followed by what operation rotate operation needs to be performed only. Do not worry even if you do not follow this fully remember that there is a part of the field instruction field which is interpreted in two different ways based on the particular bit set in the i flag that is enough. How it is interpreted with the actually instruction I will show you so, that it will become very clear pay attention ok. Remember what I am showing and then with a register you say 8 bit value of shift operation. Suppose you say that one operand is coming from R m how many bits will come that is a bit value will come from the one of the registers in the register 5 and then you will perform a shift operation based on this 8 bit value. How this 8 bit value is interpreted I will explain to you. If it is a immediate value the 8 bit value is here and then some 4 bit rotate operation is performed on it. So, no R m is coming here so, there is no register content for doing a rotate operation. So,the bar is shifted does not take any value from register file, but it takes only the immediate constant coming from the pipeline register and perform some operation based on the instruction ok. I hope you understand the difference between these two format let us go further. Now, I am going one more deep level here I mentioned ok one operand is coming from R m that. So, some operation the barrel shifter is supposed to do on the contents of this particular bit value. If R m happens to be 1 that means, R 1 contents are taken if it happens to be 2 the R 2 contents are taken. Now what shift operation needs to be performed that is interpreted in two different ways based on this bit 4 ok. This bit 4 could be 0 or 1 then suppose let us go to the left part of the format. If it happens to be 0 then next two bits are interpreted as one of these operations ok. Either logical shift left or logical right arithmetic right or rotate right I told you about these instructions how they differ. So, based on this bit positions bit values it will interpreted as one of them and then these 5 bits are considered as a 5 bit unsigned integer. Please remember it is a unsigned integer. So, it could change from 0 to 31. Now based on this value it may do that many number of either logical lift left or logical right or any of these operations on R m contents. One example I will tell you suppose R m happens to be a 0 what does it mean? It is a R 0 that is content of R 0 is taken. Now assume that this bit positions were 0 0 then logical left has to be then. Now ok it has to do a logical left shift that ok that means, it will fill the like left to right most point bit positions as 0. Now assume that this 5 bits happen to have 2 a value of 2 then what it will do it will take the contents of R 0 whatever is the value in R 0 it will left shift by 2 bit positions and then that result will be used as a operand to the ALU. Please remember it is after this operation it is taken as a second operand to the ALU. Now based on the off course it will be taken and then particular operation will be done and then the result will be taken back into R D. Now assume if it was in this format then a this is 1. So, it will interpret this as a shift operations or this needs to be done, but instead of interpreting this 5 bits as a some 5 bit shift operation it will take this as the RS that means, it is pointing to one of the registers ok it could be 0 0 to or 4 1. So, that means, it can be R 0 to R 15, but there are some restriction that R 15 cannot be used here, but I am telling you you know possibly that there one of the registers are used and then it will interpret the lower byte of that register has to be taken as a shift operation. So, please keep in back of your mind that the interpretation is separate different based on the bit positions the values of this bit. So, how it is performed I will show you with example. So, it will become clear to you ok let us go forward. Now we are going to concentrate on this part of the combination ok. Now I have taken only that portion. So, you do not have to worry whether it is same or very different. Now you are doing any of these operations based on you know the instruction and then the shift amount could be 31 bits which will be sitting here and then logical write fills with logical write ok. Your bit positions are shifted to write and then the memory positions will be filled with 0. If it is arithmetic write as I mentioned it will be filled with the sign bit it will be extending the sign bit value. If it happens to be 0 it will fill it with 0. If sign bit happens to be 1 it will fill it with the all walls. No arithmetic left is needed because it is same as arithmetic left I explained to you already. Now let us go one by one. I told you that in this particular combination what you have taken R m is coming in one of the R m registered contents are taken in please remember it is not saying R m. So, contents of R m that means, the R m values are not disturbed it is copied and then barrel shifter does some changes to it and then feeds that value to the ALU as a operand 2. Now how much to shift it takes it from the 5 bit value which has come along with the instruction and then based on the 2 bits it will do a logical shift. Now in this case we are taking an example where logical left is 1. Now logical left is this content will be shifted left. Now logical means anyway it will be back filling 0 and then whatever bits going out they may affect the carry or may not based on whether S bit is there. That means, if you have mentioned a S in your instruction along with this logical shift operation then the last bit which has come out of the shifting may sit in the carry filter ok. The least significant bits of the results are printed with the 0 ok you can see this and then whatever bits go out do not map to the result are discarded and the last discarded bit which becomes the shifter carry output which may be latched onto the C bit ok. I will give an example that you will understand the last bit coming out of this will latch onto carry flag provided S flag is set. That means, if you have mentioned the S in your instruction then it will set the carry flag otherwise it may not be ok. So, let us see an example ok it will become clear. Now I will show you how the coding what I mentioned is then here with one instruction then rest of that you will be able to deduce it by with the help of the simulator. I am taking an example of MOVS first let us understand what this means pre condition and post condition before this instruction is executed. Now pre condition is assume the carry flag is 0 ok and then R 2 is already filled with the value all S ok. Now I have an instruction to say MOVS R 1 comma R 2 comma LSL hash 1. Now what is this hash 1 means is a immediate constant come constant coming with the instruction it is coded along with the instruction ok. Now let us see how this instruction is coded and where this how this bit fields are filled one instruction if you see how it gets filled the rest of it you will be able to understand. Now ok first of all is there any conditional thing mentioned here if it was MOVEQ then EQ condition is mentioned that means, it should execute only when 0 flag is set. But here I have put a MOVS that means, I do not want this instruction to be conditionally executed ok. So, it should be always executed. So, the conditional part of that instruction will be 1110 which is meant for all ways because it is going to be executed irrespective of whatever may be the conditional flag status of the conditional flags ok. Now because it is a MOV instruction it is a data processing instruction, but so this will be 0. Now see here between it is changing ok. Now this I is interpreted as 0 who is doing this filling this value assembler ok or it could be a compiler if it was you know C you know C source file was compiled and then it generated the MOVS instruction and then the OVJ file would have put this value. But if you have written an assembly code let us for for for example, let us assume that you have written an assembly like this then the assembler will generate this particular format based on the instruction what you are given. So, it has put a i as 0 because you are interpreting it as a immediate constant ok and then why you are mentioning a register here r m which will be 0 ok and then you have mentioned r 1 here which is a a destination register. So, you mentioned r 1 here. So, r d will be filled with 1 and I have mentioned s here. So, I want this instruction to impact the flags. So, the assembler has promptly put a 1 here and then I mentioned that it is a MOV instruction. So, it has generated an opcode which happens to be 1 1 0 1 per MOV. So, so far so good. Now you may wonder how it has filled 0 here because it is a it does not use a another format it is a immediate constant format. So, it has to be a 0. Now why it has put a 0 and I call it as a do not care because MOV instruction does not interpret or take this value r n at all because it wants one it is interested only in one operand which is r 2 which is passing through the parallel shifter which happens to be r m. So, r m is filled with the 2 now you see here it is a single operand instruction. So, it does not it has filled with the 0, but it wants to interpret as a valid value and then you it is it knows that r 2 is the second operand. So, it has filled the 0 0 1 0 in there. Now it has to interpret this you have mentioned that it is a logical shift left. So, if you rememberpreviously the LSL this 2 bits happens to be 0 0 if it is a logical shift left. So, it has filled promptly a 0 0 value and then it now it has that is to be only filling this constant it is given as 1. So, it has filled to 1. Now I will ask you one question. Suppose you have mentioned LSL hash 0 x 0 2 that means, you want 2 positions you want to shift the logical shift you left you want to do on the operator operand 2. So, this 2 will be reflected by filling a value 2. So, can you write some 45 0 x 7 f you cannot because you have the maximum 0 to 31 here because 5 bit only can be filled into this constant value. So, you may wonder if I give by mistake hash 0 x f of a big number assembler will be give a warning that for this instruction you are allowed to give only between 2 you know 0 to 31. So, based on that assembler will make sure that these kind of wrong instructions do not even come into the program. So, it because if it cannot generate the code for your instruction then it will give a warning. So, this is the way the instruction is coded. So, I have expanded for one instruction and I urge you to not to interpret every instruction that you want come across because then you will be behaving like an assembler which is very laborious job. But if you do one or two instructions and then see what is the binary code generated for a particular instruction it will give you a better idea. Now you may wonder how do I know where this particular format is I will share the instruction for document an ARM instruction set for document which explains for every instruction what is the format follow. So, you can then write a code like this and then look at the generated binary code in the simulator and try to expand that value into bit positions and then map into these positions. So, that you understand what it generates. If you do it for one or two instructions you will be familiar with anything and you will you will be very comfortable doing. You may wonder why is it required anyway assembler is doing why should I bother about these kind of bit level values. I will tell you when you have to debug your code at the assembly level at the binary level there are some occasions where you may encounter the program crashes or it generates a unknown instruction or it generates about data about in those kind of situations there may be a memory corruption in your embedded processor or that could be wrong can be programmed wrongly. So, if you can understand the binary format then you have a good hand handle on how to interpret what is stored in the instruction memory. So, you do it for one or two instructions so that you will become familiar that on you may be acquired you will be doing this. So, this is the value actually the simulator has generated and then I have expanded it like this and explain to youand I hope you understand better. Now, let us see what is this actually performing. Now, R 2 I said that all f's are there that means all bits are once ok all once. Now, you are doing a left shift logical shift left by one position that means all ones are here and then you shift out only by one position and then you have mentioned also that yes is there that means it is supposed to impact the carry flag. So, what happens the last bit which is coming out of the shift happens to be a one because you are doing a only one left shift and then this bit 31 happens to be one because f is there that means that one will go into the carry flag. So, if earlier carry flag was 0 you will see the carry flag is set. Now, once f is there it may based on the result in R 1 the other flags are also set, but please remember only 0 flag andnegative flags are set andoverflow flag is not disturbed because it is not in the anything do with the arithmetic operation. So, now n flag will not be set. So, you will see that 0 flag is 0 because the result what you get by shifting it is actually f of f of e that is this value is 1 1 1 0 ok because it is back filling it with a 0 and you shifted it by only one bit. So, 1 0 will enter in the value. So, whatever is the shifted value is moved into R 1 that is why you see that R 1 is having all f only with the e the lower nimble is having 1 1 1 0 that means, the L is bit is 0 ok, but R 2 is and it is not disturbed it is same as what was there earlier and this flags are set because this result is MSB is 1. So, negative flag is 1 and it is not a 0. So, it is 0 flag is 0. So, I taken so much time here to explain this I hope you will you are able to understand it then let us we can go little faster in the nextset of examples ok. Now, let us see I want you to hold on to this presentation and try to interpret it yourself what you see is correct or not then may be listening to me will be better. Now, what is the position here also the instruction says I want this to affect the carry flags or 0 flag or negative flag and then R 2 is filled with the 0 1 and that is the operand R m and left shift logical shift left by 2 position that is 1 is moved to 2 position that means, 1 0 0 it will become right. So, what is 1 0 0 it is 4. So, nowone R 1 is having 4 R 2 happens to be same 1 and then carry flag and 0 flag I am not going to explain further I hope you will understand this ok. Let us go to the next one one more thing for a you know this particular format you are supposed to give the conditional thing if will if that is required first and then followed by a yes. So, this is not accepted as a valid instruction in our assembler also in our simulator also and I think this is the standard format followed. So, operand what may operation it should be performed and then if conditional things are there e q n e or a l whatever give that and then s flag if it is accepted. So, this is all optional if you want to mention the condition and then whether you want to impact the conditional flag you have to mention this yes ok. Now, there is some unique thing LSL 0 if you say logical shift left by 0 that means, you do not want to do any logical shift at all in that case what happens is the previous carry flag is carried forward that means, it is kept as a same and then it impacts the other flags ok it is a special condition when you say 0 you do not want to really do any operation on the R 1 it is a short circuit barrel shift it is not doing anything with your operand. So, it will interpret it as a no no operation to be performed. So, take an example R 2 is the operand to the barrel shifter. So, R 2 is built with all 1. So, when you do no shifting it will pass through the same. So, when it comes into R 1 it is same as R 2, but carry flag was 0. So, it keeps the same value and then s was there. So, it is disturbing the other 0 and negative flag because the result happens to be s of 0 flag is 0 and n will be more ok. So, when you have a hash 0 that means, you do not want to do any shift is of left operation. So, it is a pass through to the barrel shifter and carry flag is preserved and the rest of the 0 and negative flags are modified ok. So, whenever you mention this kind of instruction in your course you should know what exactly what you expect the processor to do otherwise you will have and you will not be able to understand what is happening in the processor ok. So, these are all about logical left shift. Now, let us see logical shift right ok. It is very simple you do the shift operation to the right side of whatever R m comes and then back fill this values with a 0. So, when you are right shifting you are reducing the value which was in R m. So, by reducing it by 2 if you are right shifting it, but it could be some bit pattern also may not be a value value value you may be doing it going to create a pattern in your you know register value. So, you may do a right shift, but whatever the last bit going out may impact the carry or not based on the yes. So, this also has the same condition as LSL 32 31 0 31 as a constant value you can mention LSR as the operation to be performed and the loss with this correct bit is either affecting the carry flag or not based on the yes bit set. That means, whether you mentioned s or not in the with this instruction. I hope you understand this is the same replica of left shift only it needs the bits are now moving to right. Now, see let us see an example the n is mentioned here LSR 1. Now, take an example the R 1 is initially filled with 1 and then it is shifted by right 1 bit. What happened this 1 bit what was 0 0 1 goes out as a carry flag and yes is set. So, it will impact the carry flag ok, but now back filled with 0. So, R 1 has only 1 bit set. So, it is gone out now. So, R 1 will be left with all 0 which is copied into R 0. So, R 0 will have 0 R 1 please understand R 1 will not be considered. So, R 1 value is same only thing that value is taken and then shifted right ok. So, now why carry flag is set because that 1 bit which went out is supposed to impact the carry flag because s is there. So, carry flag is set now why 0 flag is set because you are having the result which is in R 0 happens to be a 0. So, it is set now why n flag is set 0 because there is no n must be set. So, this is the outcome of LSR. Now, let us see one more example you have R 2 which is one of the operands for the one only operand to the out barrel shifter which happens to be 4 that means, 0 x 4 please remember. So, that means 1 0 0 now when it is shifted to the right 1 0 0 will become just 1. So, that is why that shifted value which is moving to R 1 happens to be 1 and R 2 remain same and the carry flag why it is becoming a 0 because what was shifted out was a 0 loss shifted out was 0 1 because it was 1 0 0 which 2 0s went out. So, so that 0 flag is set 0 coming out of the shifting is sitting in the carry flag because s is set. So, that is 0 and then 0 flag is 0 because the result is not a 0 value and n is 0 that is it ok. I hope you now understand how to mention LSR or LSR in your code and how to perform it on the R M value register what you have ok. Now, let us see some special interpretation of LSR 0 please remember LSR 0 means what you do not want to do any shifting at all but I also told you LSR 0 which did not want to do any 0 any shifting operation. Now, when you do not want to do any shifting either left or right how does it matter whether you put LSR 0 or LSR LSR 0 both are same. So, the the ARM processor community the designers have had a you know every innovative idea that they wanted to use the LSR 0 as to be interpreted as something different that you were interested in doing because as a programmer if I do not want a bit pattern that I have in the R M to be not to be disturbed I would have mentioned LSR 0. So, I do not have to have 2 options to mention the same thing. So, they use this LSR 0 that is logical shift right if you say it is 0 they do not want to interpret it as again ok I do not want to do any shift left right operation and I want to pass on the same value of R M into the area value. So, they used this pattern for some other purpose. So, in internally assembler will put a 0 only in the constant value, but it will say that it is a LSR operation then the processor understands when I have this the processor is supposed to perform a 32 bit of right operation bit position. What does it mean? It will perform a right shift by 32 bit positions ok what happens? When you it moves all the bit positions by 32 values and it is backfilling with all 0 it will wipe off the whole value bit positions in the processor and make it as a 0 right. So, which has a 0 result ok. So, and then what will happen carry out will be the bit 31 coming out. So, if the the instruction had a S bit set then it will take out that bit and put it in the carry path. So, what ARM designers have done is if you really want to do this operation I want to right shift the whole bit and I want to backfill everything with 0 and then this inverse bit I want that to be impacted by carry it know that should be written into carry flag then you are supposed to generate a right accord with S there and then say I want to do LSR 0 ok. Let us see an example if I say LSL 0 it is same as what I explained to you it will not have any impact on the parameters it will cross on the same thing and then carry flag whatever was there it willreflect it and 0 and negative flag it may change it based on the result. So, you have to use LSL 0 when you do not want the parameter to be not the ARM values to be not to be disturbed before passing on to the ALU, but if you want LSR 32 to be performed then you write LSR 0 there you may wonder why cannot I write LSR 32 because you cannot write 32 because 32 is not cannot be fitting to the 5 bit value allocated for this constant. So, assembler will crib. So, you it will give a warning or error support it will give a error. So, if you write LSR 0 it will interpret internally the processor will interpret internally that you are interested in performing this 32 bit of right shape and it will do this. Now, take an example suppose if R at R 2 was filled with all ones and then I am calling this move S R 1 comma R 2 LSR 0. For a simple programmer it may look like I am not doing anything no shift operation right I do not want to do anything shift 0 and I am supposed to get R 2 as R 1, but you are not going to get it. It is internally performing a 32 bit of right shape and it will fill all the values that we had once with the 0s. So, R 1 will be having a 0 R 2 will anyway be intact and then the last MSB bit which was happens to be 1 went out of the register and because it is saying I want to impact the carrier it will be written into carry flag. So, carry flag will become 1 and result happens to be 0. So, that 0 flag will be 1 and n will be 0. Please remember you should know the difference between these two they are not same and why they have interpret put it in a different format because they do not want to waste one combination which is that is the same job job as the LSR. So, this is a very innovative encoding of instruction ok I hope you understand this difference. Now, let us switch over to arithmetic guide ok. You will represent this as arithmetic shift right ok. Now, I mentioned to you in the beginning it will whatever is the sign flag that sign bit ok MSB bit will be copied on that is why it is shown like or the same thing is coming here and then whatever goes out either the last bit going out will be affecting the carry flag based on what you want to do with the carry flag. If you want that to affect it then you have to mention yes. Now, let us take an example here. So, that you make this concept is clear I have not put S here that means, I do not want this bit going out of this right shape to be impacting the carry flag. So, then what I want to do whatever is the content of R 1 this is the content of R 1 I want to do a arithmetic shift right by one bit. Now, what is C? C is 12 ok XR decimal 12 is represented by how 1 1 0 0 please ok. You should be able to just when you see the assembly XR decimal value you should be able to just get the value ok C is 12 that is 8 plus 4 is 12. So, 1 1 0 is the last enable. Now, when I do arithmetic shift right by one bit this will become 1 and this will be 0. So, what is this value it is E right. So, your R 1 shifted value is moved into R 0 which happens to be f f f of E because why it is f f because it is doing a sign extension. So, it is arithmetic shift. So, it will be filling it with the ones. So, you will get f f of E and R 1 you will see the same and flags are not affected because there is no yes. I hope you understand this if you do not please listen again once again let me erase this ok. Now, let us see one more example. So, that you understand it fully R 2 is filled with 4 and I am trying to do a arithmetic shift right. Now, what is the MSB here what is the sign flag of this R 2 here it happens to be 0. So, when this is copied and then shifted right it will be back filled with a 0 and it is shifting it by 2 position. So, 1 0 0 will become just 1. So, R 1 will become 1 R 2 will be 4 and the flags are not affected because even one the yes here. So, this is not going to impact the flags. I hope you understand this arithmetic shift right and arithmetic shift right ok with a RM value ok. Let me tell you there is one special condition again here similar to LSR that is in being they wanted to make use of this pattern ASR 0 again if it conveys that you are not doing any operation with the shifting you could have used LSR 0 right. So, ASR 0 is again interpreted as ASR 32 it is same as the previous one what I showed you LSR also ok. So, ASR what does it do? If you have mentioned ASR as 0 it will do a 32 bit of arithmetic shift because it is different from 32 bit of logical shift ok. Let us take an example suppose you have mentioned R 1 happens to be 8 all 0s 8 means what 1 0 0 0 that means MSB is set to 1 this is the RM. So, that is the parameter operand which is passed to the barrel shifter and it says ASR 0 actually it is not performing a 0 arithmetic that means no shift at all it is performing a 32 bit of arithmetic shift to right. So, what is arithmetic shift right it is supposed to backfill it with the carry flag. Now, because carry flag is set here it will backfill it with all 1 and it will do it for 32 times then that that 1 would have propagated all through the register ok and it would have had all all will would have become 1 now ok and this carry also will come out, but because I had mentioned as no s here. So, it will not impact the carry flag, but R 0 will be filled with the 0s ok it is a very easy way of doing a 0 here ok. So, when you have this value and then when you do a arithmetic shift right 0 it is doing a 32 bit of arithmetic shift right ok. So, why ARM has decided to use this hash 0 as 32 bit shift because 32 cannot be written into it and a 0 if you write it is same as LSL 0. So, they made use of that particular combination to perform this operation ok. Let us see one more example if suppose MOVS is there and R 1 is filled with see please remember I am taking only R 0 R 1 it does not mean that you can do only with R 0 you can do with any register please remember, but R 15 is always a special thing because it is a PC, but you can free to use R 3 or 4 or 5 or any operand it could also be the same operand you can say R 1 comma R 1 no problem why it is always before doing any arithmetic operation is copying the value from register ok. So, you can as well write into the same register only thing is the previous value will be over written, but if you are free to use the same operands here the R 0 comma R 0 is a valid instruction. Please remember that you try out multiple combinations so that you understand that andnow ASR 0 you have mentioned then what happens is this 1 1 0 0 C is again 1 1 0 0 which will go through all in the bit. So, it will all become 1 and finally, that MSB bit is coming out as 1 which will impact the carrier flag because I mentioned yes ok because earlier it was 0 it will become 1 and other things are you can interpret it because R 0 is this value. So, this will be the state of the carrier flags and the negative flag. I hope you understand this uniqueness of this instruction let us go to rotate right. It is another logical operation where you still know what we were doing is a shifting of the bit it all all the bits were going out and then the last bit which was going out was either impacting a carrier flag or not, but suppose if there is a need for you to rotate the bit that means, you want the LSB bit to come back into 31 then there is a provision for that. Now, only rotate right is there because you may wonder why rotate left is not there because it is not needed if you want to do a rotate left by one bit you could do the same performance by rotate right bit 31. So, you know you can always do the same what you want to do maybe you may have to do so many rotations, but it does not matter. So, you can do it with a only rotate right. So, there is only rotate right which is supported and please remember one more thing the uniqueness of barrel shifter is that any of these operations are not performed in multiple clock set it is all done in single phase itself. It does not matter whether you are rotating it by 2 bits or 5 bits or 10 bits or 30 bits ok. Everything is done in a single phase of clock every single clock set. So, it it does not take more time to perform more rotation please do not think that if I do 10 bit of rotation it will take 10 clock set. If I do 5 bit of rotation it will take 5 clock set please do not think that way it is all the barrel shifter is designed such a way that any number of bit rotations can be performed in a single phase of the 2 phase clock cycle ok. So, within a cycle this barrel shifter does the job and then fees that value into the ALU for ALU to perform the operation. So, this constant what you mentioned does not impact the number of cycle the instruction takes. This is very important point which I am not mentioned so far I thought it is the right place to mention it please keep in mind this ok. Let us see an example of rotate right. Suppose you have a R 0 with a 1 and you want to do a R O R with 1 bit that means, you want to rotate it by 1 bit what happens this 1 bit which is LSB has to go out and then shift in the 31 bit position ok. So, when you do this operation R 1 which is at destination register becomes 80000 why this 1 bit which LSB came out and sat as a MSB bit because there is no yes I am not showing a flag otherwise it would have set a 2 things it would have set a carry flag also because this 1 bit which was going out will impact the carry flag and because it comes and sits in the MSB bit it should have set the negative flag also n flag also would have been set, but 0 would have been a 0 because the value is 1 it is not a 0. So, because yes is not there the flags are not impacted so, rotate operation is performed ok. I hope you understand this let us see one more example to make your understanding clear I have put a move S here R 1 comma R 0 R O R 0 2 that means, this bit position 1 1 sorry 0 0 1 1 with the nibble lower nibble which is rotated by 2 bit position that means, both the 1 1 will come out and then they will enter into this bit it will become 1 1 here. So, it is effectively a C here so, the result R 1 will be C all 0s and then the flag will be 1 because carry flag will be set because last carry with last bit which went out happens to be a 1. So, it will be set and any set because any set and 0 ok. So, this is all about rotate now again in rotate R O R 0 again you know you can mention that I do not want any rotation at all which is you know by mentioning 0, but again on interpret this as a separate instruction it is a unique instruction which is called rotate right extended ok it is same as LSR ASR and R O R for all of this instructions there is a 0 is interpreted as a separate instruction. So, what does it do R O R 0 X is interpreted as extended and what I mean by extended means it will take this 32 value of RM into you know as 1 32 bit value and then the carry flag as a 33rd bit and then it does a rotate right. How many bits it does it does only 1 bit it is basically to bring in the carry into the value ok and and throw that value which were which was LSB into carry bit. So, it is basically carry bit is also considered as along with the 32 value and then it does a 33 bit of rotation actually this bit going out the sitting in carry flag and then carry flag comes into it. So, you can call it as a a 33 bit of quantity of right, but it is just only 1 because you cannot you have only one constant and you cannot mention that I want to do this you know n number of time where there is no place for you to code it for the assembler to encode it. So, you can it will only interpret it as a 1 bit 33 bit of right shift rotate ok. So, take an example carry flag was 0 and C 0 0 1 was there this 1 will go on sitting carry flag ok and then this C is 1 1 will move into 0 1 1 because carry flag will come in. So, it will become carry flag will be 1 and then it will become 0 1 1 all 0. So, that 0 1 0 is a 6 actually you know if so, R 1 will become 6 all 0 and carry flag will be set because this 1 m L S B went out as a carry bit and the result will be like this. So, this is called rotate right extender. So, if you want to mention this you have to mention this R o or hash 0 if you want to perform this operation in your assembly for some purpose ok. So, this comes to a end of all the rotation. So, 1 1 0 0 becomes 0 1 1 0 which happens to be a 6 ok. Now, let us go back to our original operands how they are interpreted. So, far what we have seen is this part of the story ok this part of the story we saw we saw all the logical left or logical right arithmetic right rotate right and then unique hash 0 was there in each of them how they are interpreted as 32 bit values or right rotate extender we saw for this part of the interpretation of the code. Now, what is the difference between this and this? In this case the barrel shifter was getting the shift operation anyway part of the instruction both are actually shift operation what needs to be performed is anyway is part of the instruction itself, but it was interpreting this as a 35 bit constant value which is coming in as in into the barrel shifter through the instruction and then it was operating on the RM value based on this how many bits has to be rotated or shifted left or whatever. Now, suppose I want to do more than a 31 bit of operations ok, where it had a restriction that I cannot give a rotation or a shift left beyond 31 bit values right I if I want to rotate it by say 45 bits you may wonder why is it required, but there may be I will tell you how it can be interpreted, but if I if that needs to be performed this instruction format does not allow me to do. So, there is a way to do it means you you have to use one more register which is called a RS a shift register. You can mention that one of the register such as shift register and then put this how much of shifting or rotating you want to do in the that shift register the lower LS byte of that shift register you mention the value then the processor will read it from that and then perform that many kind of operation. So, it will perform all the operations that you are want to do, but only thing is it will take the constant shifting operation how many times it has to be shifted it will take it from the RS register and that also from the lower byte of the register please understand this ok. Now, let us see the different combinations of this let us go little faster because it is simpler. So, you can mention any register as RS except for R 15 of course and then suppose if you say RS if it and the RS has 0 suppose you mentioned as R 1 and then R 1 LS byte was 0 it will not perform any operation it will just quietly come out. That means, it will pass on the value of RM without any making any changes to it ok and then if value is better than 1 and 31 it will be similar to whatever we have seen so far ok. So, it will be behaving the same way only thing is you will be using up one more register for your for this operation. Now, where is this format is useful only when you want to do some operation which is more than 31 let us see some examples for it and how to you know how to mention it. Now, here here again move is a single operand instruction because it it only takes R 1 RM as an operand, but only thing is R 0 is actually for the barrel shifter to operate on R 1 and then pass on the value to R 2. Now, assume that R 0 was having a value 1 ok. Now, R 1 is having a 0 2 this is the value. Now, what is this instruction is saying the processor is take the value which is in R 0 the lower byte value ok and that many times you perform this LSL operation ok on R 1 content ok. Take a R 1 content and then do a left shift logical shift left by as many times that is mentioned in R 0 and then write the value into R 2. Now, for this combination of the value what is it supposed to do? It is supposed to do a one bit of logical shift left which of this value because R 1 happens you have 2 if it is logical shift left if it does become 4. So, R 2 becomes 4 R 1 and R 0 are not changed ok. Please remember these are all treated as a inputs to the barrel shifter they are not modifying them. So, if you write the instruction like this instead of immediate constant you are mentioning a register then it will take the value from the register. So, this R 0 can be any register again and now it could be same as other operands also, but you should be aware of what you want to do ok. I in I assume to change these parameters give all of them same or different and then you know initialize these registers with the previously some values, known values so, that you understand what is happening with the instruction. You have to try out multiple combinations there are so, many combinations available. So, you try out all this so, that you understand what happens with the different instructions. Now, another example I have given you LSL R 0 now R 0 is filled with F 1 F 1 is what it is a huge number ok. So, that many times it wants to do a right shift sorry left shift logical left shift. So, it is equivalent to doing it over and over again. Now what happens R m when it is copied the R 1 value is it happens to be 0 to 2 to start with, but once it does a logical left shift it will be filling it with all 0. So, effectively it will be performing a rotate operate left shift operation you know so, many times, but actually inside the processor it there is no point in doing that rotation blindly more than 32 times right. So, it will effectively give you the value which have what you will like that likely to get when you do this many times and then it will reflect the value. So, in here what happens it will be all 0s and then flats are not impacted. So, that is all you will get now what happens here another example arithmetic shift right which is it R 0 happens to have a 1 F 1 that means, this 1 1 will be filled with all bits. So, you will get effectively all F you know F f in the R 2 ok that is what you see. Now there are some unique combinations LSL by 32 has a result 0 why because it will be filling all the bit position with the 0. So, you will have finally, land end up with all 0s in that bit position ok and LSL by more than 32 has result 0 and carry out also 0. The difference between these two is the carry would be 32 bit the MSB bit will be carry bit or if you do it more than one time then you will get all 0s carry will be 0 there. So, I want you to try out all these combinations and see it yourself what happens LSR 32 has a result 0 with the carry which is coming out of the 21 bit as up of rms will set the carry based on whether you have put a SR not in the instruction LSR is the same as the LSL only thing is all will be 0. ASR will have of the sign bit extended to all through the bits and the loss will also be based on the carry in a bit MSB set or not you will have a carry bit set or not based on S flag also rotate right that is the same thing, but it does more than 32 times ok. So, what effectively when you write a value which is more than 32 in a register and then give it as a parameter it actually does a n mod of 32 ok effective what you see will be after one rotation is done it will be n mod. So, please remember it will do the 32 bit of operation and then n mod it is not just a n mod. So, it will do completely 32 bit times and then the result will be what you see. So, effectively it will be all 0s are carry bit ok maybe I should remove this n mod because you may think that you know it will do only n mod actually you know please remove this n mod. It will do 32 times and then whatever is remaining bit is there it will do the communication and leave that when it will be either all 0s or all 1s based on the carry flag the MSB bit was set ok. So, these are all about the combination which was mentioned as 0 that is one of the operand was coming from RM. Now, another combination is when you have everything is mentioned as a immediate value. So, it is a special condition that means, this RM is not used at all because if you see in this combination there is no RM mentioned here and this one is actually I bit ok. If I bit was set to 1 this 12 bit is interpreted as some rotate operation on some immediate constant which happens to be a 8 bit value and all of them is coming from the instruction as an immediate value and no RM is taken that means, no register contents are taken for the barrel shift operation and then it will perform the operations based on the bit positions which are mentioned here. Now, let us see how this is interpreted this 12 bits are interpreted as lower 8 bits are for immediate value. So, the shifting operation is taken from this value whatever you mention it as a this byte value and then how much to do a operation is a always rotate here please remember that it is always rotate and that is also rotate right ok. So, I will tell you how it is interpreted this value whatever is mentioned is multiplied by 2 and then taken as a rotation and then used as an operand 2 for the ALU. So, if you do not understand now please wait you know in the nextexample you will be able to understand it. Only thing you have to remember that this is another format based on this bit position it will be interpreted in a different way ok. So, there is no RM here is a immediate value with a rotate some 4 bitcontent saying that how much to rotate. Let us see the first of all let us try to understand the problem here and orbit 32 bit value suppose you want to fill a register with a arbitrary 32 bit value you cannot do it because you have a restriction that the whole instruction itself is 32 bit how can you fit in yeah another arbitrary 32 bit value into it because then instruction cannot go beyond yet one 32 bit value ok. You cannot have a 8 byte instruction you can have only 4 byte instruction that means, instruction length cannot be more than 4 bytes because it is a risk architecture and we did not want to complicate the ARM processor decode logic should not be complicated where because varying length of instruction is similar to assist instruction right. So, if you want to pass on a huge constant into an instruction that cannot be done because you cannot fit in a 32 bit constant into a 32 bit instruction. So, there is a restriction that you can give a 8 bit value and then say some bit rotations. So, that some value of 32 bit constant can be copied into a register let us see how it can be done. So, the instruction allows 12 bit of location. So, you use the 8 bit value here as an immediate constant and then use a 4 bit to give some instruction to the barrel shifter say you do some operation on this immediate 8 bit value so that I get the pattern that I want ok. So, what is that rotated rotate I want? I want the rotation to be performed on this 8 bit value ok and when you are doing it please 0 extend this immediate value ok do not do any sign extension because I am giving only this 8 bit value. So, the barrel shifter needs a 32 bit input. So, extend this 8 bit value into all 0s. So, the L you know m s part of it you know most significant part of it will be built with 0s and take only this 8 bit that I give you and then rotate it by this many number of times as I mentioned to you. So, suppose it is not the same number of bits position I give this 4 bit position suppose I say 1 please take it as a 2. If I say 2 multiply it with the 2 and then understand it as a 4 bit rotate ok and do the rotation on this 8 bit value that I have given you ok. Still if you do not follow do not worry with the next example you will be able to understand. Now, suppose I want to write this constant into a register suppose move r 0 comma hash 0 x 0 0 0 ff. Now if this is a 8 32 bit value ok actually it is a 32 bit value. Now what does assembler do? It looks at the value and it knows that ok the most significant the information is in this ff only the 1 byte of value is you know is very important. So, let me take that immediate value the 8 bit value into this location and then say I want to rotate it by 0 times. So, what the barrel shifter does? It takes this ff internally 0 extends this value to 32 bit value and then does not do any rotation. So, effectively you have got a 32 bit value getting as an operand to the ALU andif it is a move instruction it will be just passed on to R D and then it will move into the register R 0 what I mentioned to you. So, effectively you are the as a ARM assembler allows you to give a 32 bit value, but there are some restriction it cannot be anything that you think you want to do. Now suppose you want to do this constant value. Now how can this be constructed internally? Because you are giving this ff, but when it is interpreted into the instruction it will put this ff and then 0 extend it with all 0. That means, this ff will sit in the LS byte of the barrel shifters input, but it will say in the rotate saying that I am giving a e, e is what actually it is a 14. So, it will put e here that means, this 14 will be multiplied by 2 that is 28 and then it will do a rotate right this ff rotate you remember this bit position whatever comes out 32 bit will come into the MSB part of it. So, this ff will pass on and then come back like this and then passes 28 bit why 28 times because only 4 bits are left here. So, 28 times if this ff moves it should have come here please you know try to do it with a paper then you will understand this. So, what the ARM assembler has done is it has effectively allowed you to mention this pattern with the restriction that only 12 bits are 12 bits are allowed for the constant ok. So, but all patterns cannot be given, but some patterns can be and it is able to do this. Now, you may wonder can I give instead of ff can I give something else yes of course, from 0 0 to ff you can give only thing is it should be a right right ok. Any pattern you have should not be more than a byte it can sit anywhere because you have a flexibility here you can rotate it by double the time of what you have. So, you cannot do it odd number of rotation you cannot perform, but even number of rotations you can perform because I tell you whatever value you are giving here is multiplied by 2 and then that many rotations are done. So, only whatever values you get will be a powers of 2 ok ok. Let us say take one more example if I have a I want ff to be loaded effectively you will be as a programmer you will be mentioning it as this constant and internally assembler then did this pattern and put it into you do not have to do this. So, in assembler will put the 4 here and then ff here what does it mean 4 into 2 that means, 8 rotation to the right. So, it will effectively sitting the ff will be here to start with in the barrel shifter and then it will go 8 bit rotated. So, it will say you know come back into the MS byte of the value and then goes into the ALU ok. So, you can effectively get this pattern also implemented can I do this of course, you can do, but what you do you only rotate it by 4 times. So, ff will be rotated by 4 times. So, this one will be here and agar 4 f will come back you know into MS nibble. So, you will get this pattern. So, you can see that some patterns are possible instead of ff you can put any value, but you can do only some patterns. Now, I have done for this pattern. Now, I will give you an exercise for doing this pattern write out for some time then listen to the lecture again ok is it possible to code them like this ok. If you have all concluded that it is not possible you are right it is not possible because first of all this pattern is more than 8 bit wide. So, you cannot fit into this immediate constant whatever rotation you do if you cannot fit in that 8 bit value anyway you cannot generate this constant. So, now, if you say in your code if you use this constant assembler will give a error that it is not possible. So, you may have to use some other way of passing this value and then rotating it and only to prove registers and then do perform this operation you cannot do it in one single instruction can you do this can you do this none of these combinations are possible ok. So, I hope you understood this I want you to try out different constants and then see the instruction generated by the simulator and see whether you can map it to this value whether you can you understand what it is doing if you can yes you have understood this concept pretty well. So, I am sureyou will be able to follow this thing. So, let me just summarize this an assembler will convert big values to a rotated form impossible values will cause an error. Now, assembler may also in know if you give move and then it may change it to m v m if you remember m v n I said that m v n is what the value what you passed is negated and then passed on to the value. So, if it was 0 it will negate that to f f f and then put it into r 0. So, if suppose you have mentioned move r 0 comma this it is not possible to do it with the previous format or it showed you, but assembler will understand that ok I can do the same thing with the move m v n instruction. So, it may try to do this and it will not still given warning ok, but it it will not be true if you output some other pattern ok. So, I am giving another example if suppose you have given know this constant to be put into r 1 it will be 4 and f f will be put into the constant value and then it will perform the operation ok. And if it happens to be a EE 0 0 0 this EE will be put here and then how many times you have rotate EE will be here it has to 16 times it has to rotate right then the EE will go out and come back again and sit here. Now, 16 can be represented by 8 here. So, it will be multiplied by 2 and then it will do a rotate I hope you understood this and if you try it out multiple times I am sure you will be able toappreciate this process. So, I am sorry for taking more time I thought these are all related topics it is better we cover it in one section I hope you kept your interest alive throughout the discussion. And I am pretty sure if you try out all these things you will be really enjoying this ok. So, this will not be covered later on ok this will be appearing in any kind of operations either AND or NO or any data processing instruction you will see this. Whenever you see this you have to remember that it is on the RM operand which is coming and then the barrel shifter is performing the job and feeding it to ALU this you should remember always. And then apart from that ALU will perform some other operation, but this is what you are preparing the operand for the ALU. So, what all you can do is what is has been discussed now. So, we are ready to now go into other part of the instructions I am sure you will encounter a lot of interesting aspects and understanding this way things how it is interpreted inside of you know implemented inside a processor gives you a lot of idea about what you write in a high level language like C or C or C plus class and how it is converted into an assembly and how the processor is interpreting it. So, it is a very nice feeling to understand this I hope this lecture was useful for you guys please try it out I am sure you will be you know having a good understanding of this ok. Thank you very much for your attention see you in the next session with this we come to the end of the session 7. Have a nice day enjoy your lunch session. Thank you very much for your attention.