 video session on peak instruction set for byte oriented file register operations, myself Mr. Vipul Kondekar from Valchin shop technology Sholapur. The learning outcomes for this video session student will be able to describe these different byte oriented operations and operation of instructions for addition, subtraction, then clearing the data, incrementing, decrementing, moving the contents, so these are the contents of this session where we will talk about what these byte oriented instructions are and then we will see operation of these different instructions with reference to their syntax, what operands are required, what exact operation is carried out, which flag bits are affected and then with one example we will try to understand these instructions. Now before starting instructions what are the different byte oriented operations possible with the peak microcontroller? So peak supports operation for addition, subtraction, these are the arithmetic operations possible, logical operations like ending, inclusive or an exclusive or these are the operations possible, it can complement the byte, clearing the contents, incrementing, decrementing, rotate and move these type of operations are possible by using peak microcontroller. Now when you talk about byte oriented operations, the up code for that byte oriented operation will invoke two things, one will be the file register which you want to deal with and D which is the destination bit. If D is equal to 0 then whatever is the operation, the destination of that operation result will be available in the, result will be available in the working register, if D bit is 1 then the destination is what? File register and EF can be a file register that will be the 7-bit file register address. So you have to mention the file register prior to that you have to make sure that the bank in which that particular file register is there that has to be selected because 7-bit address you are specifying in the instruction 2 bits from the bank so you can talk about total 9-bit address of the data memory location. Now what is the difference between bit oriented and byte oriented instructions? Now talking about the bytes, now let us go for understanding different byte oriented operations where we start with first arithmetic instruction which is addition. Now what this instruction does? This instruction is used to add the contents of working register and file register. So file register can take value from 0 to 127. Contents of working and destination D bit can belong to 0 or 1. Working register contents are added with the file register and whatever is the result goes to the destination. What is the destination? If D bit is 0, destination is working register. If D bit is 1 then the destination is file register itself. Here you are doing addition again the status register flag bits are there carry flag, digit carry which is analogous to the auxiliary carry flag of 8051 microcontroller as well 0 flag. So these are the flag bits affected because of this particular instruction. Let us try to understand with one example. If I take add wf fsr comma 0 so what you want? You want to add the contents of working register and fsr register. fsr has value c2, working register has value 17, c2 plus 17. So whatever is the result where it gets stored in the working register. So you find that that c2 plus 17 takes that result into D9, fsr value will be c2 as it is. So this is how I get the addition and result here is available in the working register. Now if I consider another example add wf indf here what you are doing? You are adding the contents of working register but indf is used in the instruction means definitely it is a indirect addressing mode. So if working register contents are 70, fsr contents are c2 and contents of address of fsr are 2 0. So what addition is carried out here indirect addressing is used here where the contents of working register are added with the contents of memory location pointed by fsr and those are what we can say 20. So they are added and whatever is the result is available where in the file register means the location which is pointed by fsr. So the contents of c2 are going to change. So this 17 plus 20 so that comes out to be 37 whether 37 will go to the memory location pointed by that fsr register. This is how what we can say indirect addressing works. Now like addition you can have ending this is the logical operation supported by the peak microcontroller where you can have bit by bit ending. So working register contents are ended with the file register and whatever is the result that goes to the destination. This ending operation effects the 0 flag bits. So result of ending if it is 0 then this 0 flag bit will be set. Take one example add and wf fsr. So what it does contents of working register 17 convert into binary which is available here and c2 are the contents of fsr. So bit by bit 1 ended with 0 result is what 0 1 ended with 1 result is what 1. So like this you get the result as 0 2 and this 0 2 will be available in the destination here you have not mentioned dbit means you have not written 1 or 0 here default value of d is 1 indicating by default the result is going to store in the file register itself. So here you find the result is available in the file register. Now another operation possible by using microcontroller is clear a particular file register. Many times whenever you are writing program you are using some counters or some variables and you want that these variables should be initialized with 0 values. So this is useful instruction in that case any file register contents can be cleared or you may say initialize to 0 so 0 0 will go to the file register and as the result is 0 that 1 goes to 0 flag bit means 0 flag is affected whenever this instruction gets executed. This instruction is again single word single cycle instruction. So if I take example clrf flag register before execution of this instruction the contents of flag register are let us say 5a after execution what you are going to get is contents will become 0 0 as well 0 flag is set after execution of this particular instruction. This is one more instruction available complement. So complement is what it is once complement so if bit is 1 it will become 0 0 bit is there in the before execution it becomes 1. So like this all 8 bits of the file register are complemented. So contents of file register are complemented and it goes to the destination and again if after complementing the contents if the result is 0 then 0 flag is again affected. So this is how encoding is will take place for the opcode and again single word single cycle instruction. So before execution after execution if I take you want to complement reg1 and store the result pair 0 means working register itself. So 1 3 1 3 you convert into binary then wherever you have 1 convert to 0 where you have 0 convert into 1 what you get EC so that EC value gets stored in the working register itself. This is how you can do the complement operation on any file register content. Now many times whenever you have counters or loop counters you want to either increment or decrement that counter. So yes this instruction is useful in that case decrement file register. So decrementing file register is what? So that file register value gets decremented by 1 and result goes to the destination and after decrementing again it is possible that the result is 0. So 0 flag is affected single word single cycle instruction. Let us take one example for decrement. So what I am doing here decrement file register and which file register? File register I have assigned name to that file register address as CNT. So CNT value you want to decrement. So before execution the contents of that CNT file register are 0 1 and 0 flag is cleared and then what happens after execution? So this CNT value will get decremented by 1, 1 decremented by 1 will be what? 0. So the result is 0, 0 flag will be set because of execution of this particular instruction. This is one more instruction for decrement where you are doing you are taking the decision about skipping the next instruction decrement file and skip if 0. Let us try to understand what this instruction does. So this instruction decrements the file register by 1 and it stores it to the destination and if the result is 0 after decrementing what it does is it skips the execution of the next immediate instruction. If the result is not 0 then sequential execution will be carried out so next instruction will get executed. So decision about whether to skip or not it depends on whether the result is 0 or not after decrementing. You will understand it better with one example. Here I am executing decrement and skip if 0 count whatever is the result after decrementing I want to store in the file register itself and then go to loop. Let us take one example where before execution the PC value is address of here means next instruction which gets executed will be this particular instruction and CNT value is 0 1. So before execution this is 0 1. So after execution of the instruction it becomes 0 and if the result is 0 what you are going to do is you are going to skip the next instruction means when you are executing this this instruction will get skipped. So in that case what will be PC? PC will go to the address of the continuous means the PC will change to the instruction whose address is continue as a label. Now again before execution suppose the contents are 0 2 so if you decrement it becomes 0 1 so it is not 0 so that will be sequential execution. So which instruction gets executed address of here plus 1. So this is how you are deciding whether to skip the next instruction or not based on the result what you get after decrementing a particular file register. Like that you can have increment in the file register decrement is subtraction by 1. So increment is addition by 1. If count value has ff if I increment it by 1 ff incremented by 1 will be result into 0 and as the result is 0 0 flag will be set. Like that you can have instruction increment again file register and skip if 0. So again after incrementing it is possible that result is 0. For example if the contents are ff before execution and if I increment it what it becomes 0 0 and if the result is 0 what you are going to do is you are going to skip the execution of the next instruction. So pc here also will change to the address of continue means this particular instruction gets skipped when the result is 0 and if the result is non-zero before execution if the value is 0 0 itself if I increment it it is going to become 0 1 so where it goes it will goes to for the sequential execution. So next instruction will get executed. So now next instruction is for moving the contents. So move f so move f what it does the contents of file register goes to destination. So if dbit is 0 you can understand that file register will go to the working register. But interestingly if dbit is 1 what is going to happen the contents of file register will go to the destination and destination is file register itself. You might be thinking what is the use of this instruction. So file register contents are moved to the file register itself. But you can find this is one interesting thing that this can affect the 0 flag. So whenever you are moving the file register contents you can check if those contents are 0 or not means if 0 flag is set then you can say that that particular file register contents are 0. So this can be used for checking whether the file register contents are 0 or not. So this is move f instruction and on the same line there is one more instruction move wf where you can move the contents of working register to the file register. So working register contents are copied to the file register. So before execution if I take one example move wf option register option register is ff working register is 4f. So what it does the contents of working register are moved to the file register. So hence working register contents are written as it is but file register contents becomes 4f. So this is how this move f instruction works. So these are the few byte oriented instructions we have seen in this video session. These are the references used for this particular video session. Thank you.