 రోwwww ఎమిర్.. ст Course 2 ప్ప్ intermediate ట౗ా ధ్వౄఎ లో estiverచౕగా 1攻 unit అఖ్ప క్ను నైదకికూ xbox вал begging 分eol ప్న్ let సిందఅ సిస్కమ ఱిందోం చ్వచంపద Lawrence on the ARM core and they build their product around it also supplies not only the architecture core it also supplies all the tools compilers assembler and the debugging tools for the vendors to purchase the core and build the system system on a chip SOC and use the ARM software tools chain to build a end product. Now in this session we will be covering a little bit about NDNS and the conditional flag that are available in in in general in any processor and in specific to ARM we will be covering in this lecture. So, this is the detailed plan for this session 2. We will know though we claim that ARM is the risk based design there are some deviations and we will see why there are some deviations and what are there and what is this. And we will just touch upon embedded system hardware and software because ARM is based for this market and we should have a clear idea of where ARM is used and how the software developed for the ARM runs on the embedded system. Now to understand the architecture of any processor the basic requirement is that if you should know how the processor is used at the end in a system. So, as a developer most of us will be writing in a high level and we would like to be a C++ or draw up which could be, but why do we need to know processor architecture and assembly language. The reason being if you know the architecture and how it runs and how it executes its own instruction then we will be a better programmer to write our software either in high level languages like C++ or there there are some critical part is of course is there which needs to be developed in assembly that could be done also and integrate with the things of ARM or C++ course. So, having a good idea of the software to chain and how various tools work together to develop a built and executable and running on a hardware is very very important to be a successful embedded software. So, both the hardware and software mean in this embedded world. So, people who are in this area to have a good knowledge on both to be a successful engineer. So, my intent here to give you a overview of the embedded hardware and software we are not going to detail of this, but it will give you some flavor and which will help you to understand the processor architecture features and how they map on to the hardware or software part of it. And then we will go into the details of stack where this is the most important part of any programming programing. So, let us see how stack is implemented in ARM and the engineers is also a very critical piece of information that all the software should be aware of and of course, the condition course when you will do an arithmetic operation what are the results of that and how to interpret them is the most important thing as well. So, let us see how ARM deviates from a few of this design. If you recall in the earlier session this processor are fixed in section size and the every instruction runs in a single title and they have plenty of registers to operate on and all the arithmetic operations work on only register operands and most of the instructions run in single type. This is what we learnt about risk, but that is not true in ARM some of the deviations are done for some reason. One is to make sure that ARM is suitable for embedded applications because finally, the ARM has to be used in some embedded application to be successful in the market and the designer thought about that and took some deviations from the risk phenomena to incorporate what is needed for embedded application. The most important thing is that whatever the code it generates from the compiler from the assembly, it needs to be come you know small form and footprint that it occupies less number of bytes. So, that it can be put into a small ROM or flash without occupying most of space in the embedded hardware. So, that you know we save space as well as we save the bit of materials for the hardware. So, apart from that ARM also includes some high level application specific instructions too and also it needs to support real time where I will tell you what are the instructions that are there, but we will go into the details of them when we study about inducing instructions of ARM. So, as I said risk is a very you know single type instruction is most of them, but some of the ARM instructions are variable type type execution. It takes variable number of cycles for some of the instruction. And one of the example is that load store multiple instruction which is actually helping you to store multiple register contents into memory or recover multiple contents multiple 32 byte 32 bit values from the memory into registers. So, single instruction takes more cycles based on number of registers are there in them. And swap instruction is another example where your memory read and write happen one after the other without any break in the cycle. So, if the memory cycle takes more number of instruction cycles then it could be a instruction cycles to complete the cycle. But why is it required? It is required for supporting 10 of 4 kinds of operation. We will talk about that when we come to the swap instructions in the electrical section. And some more is another 16 bit mode of ARM where the core instruction bit is instead of 32 bit it is a 16 bit. And conditional execution is another feature where every instruction assembly instruction are executed based on the status of a particular conditional path. So, at this moment I do not want you to know about everything what they mean, but you need to be aware that though we claim omniage of fuel with there are some deviations to support the embedded application academy. Now, let us discuss upon what is inside an embedded system. You might have seen so many examples of embedded system. And I could say if you are entering into an office and there is an access card in the you are having a ID and you are swiping back the dose. So, it is an embedded system where it reads your card and understands whether who is the person coming into the office. And then it sends the data to a persistent central server and when it says that you are the person and you have the credibility and access permissions to enter the office, then it actuates the door lock so that you can open the door and come into the office. So, to do this a system like this is required. It needs to sense when you swipe the card and that information what it needs from the card has to be processed by the CPU and then it needs to send it to the central server through a Ethernet port or may be a IO port and then verify that you have access permission to the office and then actuate the door lock so that it allows you to enter the office. So, this is typically a example where a spot of a code is written to understand the card what is the contents of the card and then send it to the server and get it back. So, in this case the embedded system needs to be reliable and it should operate on a minimum power because it should not be consuming more power to operate and there are so many restrictions and conditions for this software to work reliably. One example would be that suppose there is an emergency then the door should be the people should be able to unlock the door and it is known in the office. So, this kind of evens it should be able to handle and reliable that is very important. Now, some of the requirements that the CPU which could be on and it should be able to read the sensors from the environment and it should be able to actuate the different server relays or any other control engines or motors or whatever and then it should be reliable and fault tolerant and this is a very important whenever you see embedded system they say that it should be able to even if it stays that should be a faithful degradation. Now, the even if suppose the access card of the office as fail it should fail it is a given that it keeps it you know if it is to a lock of the room may be it should keep the door locked where very confidential documents are kept or if it is to an office may be an emergency if it should be able to come out. So, it should make sure that the door is kept in the open state even during the failure. So, this kind of things need to be taken care of in the real time system and the real time system could be say you know type control to a car engine control to ZR even a pacemaker which it will you know wear it in their body. So, it will be so reliable and it should be able to react will cause these are the requirements and the person develops right now developing a designing a processor for this kind of environment we need to make sure that it supports all those features as well as as a programmer embedded designers we need to be very cautious about what we write how we write our course so that how it runs most reliably in the embedded system. And this is a typical example of embedded system where on processor could be there and then it is connected to memory to a memory controller and then it could be connected to a serial port or to a Ethernet to a control server and then we have other peripherals to keep the system running. And our course what we develop is running here and the whole thing is powered by now let us talk about embedded system software. How do you develop a number system or it could be any software, but we are very particularly concentrating on developing software for embedded system. Here the first step is to write a software and it could be a C file or a D C plus plus file or a assembly file and it goes through a compiler or an assembler based on what is the input that we give to those tools and then they are linked using a link there there may be a library files provided by the processor developer vendor or the tool vendor to the processor and then the output is loaded into the particular memory and then the CPU starts and it starts using this code. Now this is the order then let us see what this indigates tools do to make a variable running. Take an example of a C code here. I have given you a small tool in set mode and one count variable is there which is of type int here and we are interested in it. Now when we compile the C code this what are the source type instructions just expanded to this one is assembly instruction. As you see I have given the ARM instructions here because this is a C compiler meant for ARM. So, it is compiling the C code and generating a ARM assembly. Now suppose if you are using an Intel processor and when you are compiling you are having a compiler for Intel processor it will compile the high level language code that you have written and then generate Intel specific instruction here. So, compilers are always specific to which processor you are compiling the source code part. Now there is another part of this also you need to remember that the compiler could be running on a system or it could be running on a unit system or it could be running on a Mac. So, compiler asset is running on any of these operating system and then generating for a particular target processor. So, if suppose if you are running the same code in the same platform then the compiler is meant for that particular platform that is when I say platform it could be a Windows or the Linux platform, but when you are developing a compiling a code for ARM and then you are trying to run this code on a ARM processor development board or embedded system then you are not running it on the PC, but you are running the executable on target hardware. Then that kind of a platform is called crash platform because you are compiling it on one platform and then develop you know generating an executable which is meant for running it on the target platform. The code that you develop you know generate here cannot run on the PC that you are having because PC could be an Intel based PC or AMD processor running there. So, this code can run on only the ARM processor. So, that is what it means by crash compiling the you know C compiler runs the compiling the code and then generates a OBJ file. Now OBJ file is understandable by the tools, but for a human being to read and understand what exactly this OBJ file means, we need to give as a special option there minus S or some option based on the tool to generate assembly code to see what exactly instruction it has put in. So, let us not go and try to understand this instruction. Now we will be spending a lot of time in understanding the assembly code in the coming courses in the coming sessions. What I want you to remember that you know we should be comfortable with reading through assembly that is the first important criteria for taking a course like this, but you will find it very interesting and you know there is an analogy to begin from P and how it converts that you know gets converted to assembly will be very interesting part of this course. Now after this OBJ file generated you may have multiple post files and then you want to generate only eight files and then an inter is required to invest or more and then generate the next issue. So, this is the flow of a C program. Let us see how C program finally gets converted to executable and then it runs on the target hardware. Now this is the typical memory space of ARM processor where there is some part of the memory this is the memory which is outside the processor and the CPU is accessing this memory through address and data bus. So, this memory is taken to multiple spaces code, data and heap and stack we will see what each of them we need. You can make out that code is for whatever executable that you have made that the core part of it will sit here and then if you have a initialized data that will sit in this portion and then we will see where stack and heap are required for your work program to run. Now as we have given a small peak code we do not have to understand what is actually this is being done. The thing is here two functions are called one is accepting it both are accepting into the variables and then they implement it do not bother about what they do with the implemented value, but that is to give you a flavor of how a peak code gets done on that hardware that is the intent of this layer. Now this portion now we have some memory is load for stack. Now you see now what happened is the program is loaded, but not running. Now what happened is you will use the loader to load the executable in the memory. Now this is the code part of the executable and this is the data portion of the program that you have written which is loaded into the memory. We could use you know different tools the type or any other tools to download your software into hardware you know the memory. It could be you can assume that this is a development code which is on base and it has got a memory space like this and then you are downloading the code into this memory. Now let us see when you start running this code the execution as you know any C program starts executing from main. Now you may wonder how will this processor know that the main code is sitting in this particular router. So that is the job of a library which is given by ARM or any other processor vendor so that when you write a C4 and you put a main then the function comes to this main and then the processor starts running from that instruction. Now when it comes here you know the static variable as well as the global variables are already there. I am not showing the initialized value here only the variables where they are placed in the memory. Now the control is here what does it mean is the PC the program counter of the CPU is pointing here. Actually when it is pointing at this void place it is pointing at the instruction the assembly instructions which have been generated by the compiler understanding this C code. So then the control now is here you can see that these variables are placed here and the local variable which is created here the main is also placed in stack. So I will explain more about stack now you can now for that moment you can understand that any local variables are placed in stack. Now let us see what happens now. Now after when the control goes into function the local variable is a parameter here is also generated a space is created for it. So stack is going downwards as you see that it is going downwards and then generating space for the new variables that need to be created based on the control. Now after executing from this function it comes back to the main and then it is about to enter the function to here. So as you see when it comes back the space is over for j is gone. So the j is no longer visible you know and it is not there the space created for it is also gone. Now again when this function to be is called it goes into this function and then generates k where it is placed for space for k in the stack space and then control comes here with still the int variable id is visible so that the stack space is still not gone and then when the program it sees the stack is has come back to the old state but you may wonder why it is executable and the variables are to be here because that job of OS or maybe some other tool to take care that this code is removed and some other input is not shown is that that is why it is not removed. So when the program is running only there is a life for the program and then there are variables around and then when it is standing sitting at the code it occupies space in the memory but it does not have any state associated with that. So this is a simple example of how a program see program or any other available language program that you have developed for a processor and how it runs on the development way hardware ok now let us see how stack by telling that stack grows and then again strings based on the need now this is a typical example that I have taken from this on a socio-architecture book this is similar to what I have shown you earlier only difference here is the function 1 is calling function 2 again and then function 2 it goes into function 2 now so as you see at a different point in time see first here it has just not even called into one into function 1 and when it is inside function 1 at p2 the stack is used for the function 1 and then in p3 when it function 2 function 1 calls another function 2 the stack is going down again because you may wonder why the depth is more here less here that is based on the amount of space that is required for local variable or parameters in the individual functions that stack accordingly so the size is increasing as the depth of the function calls increase and then when they come back from the function 2 here at p4 this space is placed and then when it comes back to main at p5 even the space reserve for function 1 is gone so this is the kind of stack space growing and coming down coming down after the flow of the program now why am I talking too much about stack this is very important because every processor needs to support a stack utilization because as you all know there is every program as the subgroupings and then parameters and many high level language needs local variables space for local variables all those things design in stack so a stack is that means what you put into the stack last will be the first one you will take up but that does not mean that you cannot access the other elements in the stack but if you know the location of other variables in the stack you will be able to access them from the stack and operate on them only thing is when you come out of a function all the variables space is gone but you will be able to access all the variables inside the stack in a function without any restrictions because you are accessing the stack by using the memory addresses of each of the variables that are occupied by those variables as I showed you about high and low key variables in the stack so this the stack provides space for local variables and then whenever a function is called new frame is created as you saw in the previous item it went down by fixed amount based on the number of local variables in the stack parameter so when they come out of the stack they loose now release the space now let us see that as I told you every processor needs to support the stack pointer so the R13 is a register which is used for pointing at the address where the parent top of the stack so this is normally used and it is the convention that R13 is the name of the register in the processor we will talk about it more in the subsequent lecture so R13 uses for stack pointer here and then whenever the data item is pushed R13 is incremented or decremented based on how the stack grows and then the value is removed the stack R13 is not there now the heap this is the data area stack is based on the local variables and parameters for the function and this is heap is used for any memory that you need for a program dynamic memory allocation using MLR for speed this you would have heard about in your C program courses so the heap space is used and they also grow based on the need based on the program requirement and whenever the MLR is used that particular space is allocated and then when it is speed the space is feed up and the program cannot use those ones as well and then stack space is typically in a home space home programming environment stack and I am going back stack goes downwards in the memory and the heap goes upward in it so these are all dynamic requirements of memory of a program based on the usage and when they meet each other that means there is a case crunch and the program points so this is the heap space which is required for dynamic memory allocation and then in runtime library is used as I mentioned in the earlier case how ARM processor or need processor knows that there is a need program starting in the memory so that kind of support is required you know we do not want developers to you know write a code for MLR so these kind of memory library functions are already implemented for a particular processor and given along with the tool and linker and compiler the library for which is implementing these functions also provided and even to startup program the entry to the main is also some program is startup code is given along with the library and then if there is a heap and stack space are interfacing with each other that limit is also verified by software functions and then there are other additional functions also provided along with the library now let us see how stack is implemented in a processor the address to be used to store a data value in a stack is not known at the time of the program so stack is usually implemented in a linear memory space and I told you that stack can grow but it can have two options it can grow towards a higher address or it could grow towards a lower address so both options are available now those some typical processors may implement it in hardware and then support it in only one and one good example is 86 family where the process the stack is always going towards a lower memory and that is the implementation of the processor now as I told you R13 is one of the widgets which is used for pointing at the location which is the top of the stack now there are two options available anywhere it could point to a place where already a value is stored in the stack or it could be pointing at a place where empty space is there so as to be an example here this is called attending means the stack is growing towards attending higher address and the stack point is pointing at location in the stack which is full already it is filled with some item and now when the next stack operation is done on this you can imagine how it will move so it has to it has to move towards a higher address and where will the next item which would be in the memory here will it be here or here as I told you stack grows contributing space so it has to be in the next location so in this context now what happens when another push or another data item is pushing the stack the pointer moves to this location and another item is pushing now what happens to attending an empty this is implementation where the R setting is pointing to a empty location so this is you know very specific to a process for example which is better you can follow any convention because you can see that the number of operations that are done to push an item into the stack is the same because even you increment the pointer after pushing this item or you increment it so based on whether it is pointing at a empty location or the full operation the incrementing of what needs to be done anyway for every push or so later it is incrementing or decrementing it also takes the same cycle as for the architecture but it has an implementation specific and we can do it in any way but ARM processor as I told you this ARM is like a IP so you know ARM is integrated with any other processor they have provided all the options so that when it is integrated with a particular another code it could be from another processor or it could be working for a particular application then based on the need the IP code can be configured to program the stack in any so in this case attending empty when the next item is pushed it pushes to this location and then it again points to an empty location now what happens and a pop is done that means when you are taking out an item it has to decrement the R13 and then take the item out and then keep pointing at the empty location so whatever was done putting a data the reverse has to be done in the same way now there is another way of implementing it which is towards the lower addresses which is resending and full it is pointing at a full location where the item is already there so it pushes another item into it the fourth option will be very simple now you can see that this is the descending and empty now you may wonder when the processor is coming up in a research location what is the stack it follows so there are some instructions push and pop specific to the stack and they assume descending and full you know this configuration as a default and then it could be used in any way and ARM has given different instructions for all these four types of stack now let us see how who decides which type of stack to be used in ARM it is determined by the grammar of some other somewhere by choosing a suitable instruction so but the thing is once we decide on a particular implementation for the whole application it should be the same we cannot use one instruction which assumes empty and descending and then while taking the data out you assume that you use the instruction which is meant for ascending and full then what you push you may not be getting it from the stack so the flexibility is there but needs to be taken with a pinch of salt and we need to make sure that the writer especially if you are writing an assembly code you remember that you are using a proper code for both cushioning and copying the values so this also supports multiple register transfer instructions and you could use the any of the four type of stack on that now as I told you we can while storing and retrieving the data we need to have the same setup same type of instructions to be used and then these are the instructions which operate on no stack pointer which are related to stack pointer and we will talk about these instructions in the subsequent lecture okay now we have talked about stack now let us see what is ndn destiny all of you have heard about base ndn and ndn now take an example a cpu is there and there is a register inside the cpu we always consider a little bit content 7 and it is a specific register inside so this is typically a 32 bit register these are the bits 0 to 7 and 7 to 4 to 31 and these are the values given in XR December now there are two ways in which your register content can be saved in a memory see the memory that we use there is a byte address of memory that means you save the unit of memory location is byte by a bit of byte so address of 1001 is pointing at a 1 maybe I should have 1000 and 1 to 3 I will be 60 in here because it should be aligned to 0 for a better reading and writing so I think that the address is at 1000 and then 1 and 20 for the address then from the higher the MSP part of the register is stored in the first location and then as an increasing address the other bytes are stored now this is one way of storing it this is called bit-anion model and then in bit-anion what we do the processor does this and then byte of the register and then that it saves in the addresses so starting from this address and towards the increasing address it shows me starting from this byte now which one is better there is no concrete rule that now this will be for other one but there are some the application perspective I will tell you how these two are different and how which is useful so this names are called as bit-anion we want to remember that it means that if you see the particular register value which has more sometimes because this byte is having a more value so compared to the LSD bits so this is stored first then it is called bit-anion if the lower bytes are stored first it is called a meeting now let us see we have our own question here and I suggest you please the presentation and then try to answer this before seeing the option which is correct so in this question what we are trying to say is if suppose a CPU is writing register content it wrote in a bit-anion mode can it read back that memory content into a register if it has which are options are correct when the new content in the register will be different from what was written or the content will be the same irrespective of what ndns is used or the content may be same or different you are not sure whether it may be the same or different the fourth option is ndns may not be the same while writing and reading content into the memory so multiple options could be correct I want you to and choose one of them before seeing the correct answer to this question option A is correct the reason being if the value what is there in the register was written in one ndns and if it is not written the same way you will be seeing a reversal of what was written so effectively if you are writing into a memory in bit-anion if you are writing it in bit-anion if you are writing it in bit-anion then get it in bit-anion so then only you will get the correct value in the register now let us see how different processors in the market implement this ndns these are the products processors from different companies use the bit-anion mode of values from register to memory and these processors do a written ndn way of saving it there are some processors our ARM is also here it supports both now why a processor like ARM is to support both as I told you ARM is a IP4 which is given to different processor vendors to make build their system along with ARM 4 so there is a requirement which is specific or it could be tied to another processor which is there in the system and ARM is part of it so ARM should be able to support both the ndns so that in a multiprocessor environment if some other processor from this family is used in a single board and ARM is part of it and then you should understand the big ndns way of writing and reading from the memory for any of these processor family then you should understand the written ndns so it is configurable and ARM and even it could be changed while the program is running but you need to be very careful when you know what you store the ndns used for a storing a value is used to read it back so that you the correctness of the program and the correctness of data that is written on the memory achieve now what are the advantages if at all in any one of the modes in big ndns way it is easier to determine a sign of a ndns as you know in a typical binary representation the sign bit is at the ndns speed 31 which 31 is the sign bit so if you remember as big ndns so stores the higher part of the byte first in the memory so you can just read the first byte of the value and then easily find out whether it is positive or negative so it is easier in terms of big ndns if it is followed and it is a comparative number because the value if it is an unassigned number and you see that some of the higher bits are one that means that value is more than some which are having zero so if you start comparing the bits from the higher nds you will be able to compare two numbers and division also starts from the top so it is easier in big ndns it is easier to print because we read it from MSB value so of course 4028 the forth might be part of the higher part of the binary representation so please do not understand you know please do not conclude that you know these operations cannot be done in this ndns it is only easier in this implementation but both equally good in terms of supporting other features and shared multiplications are multiple multiplications position numbers are easier in ndns so let us now jump into other important area of process of architecture which is arithmetic condition course all of you but have seen and not be aware of this I thought I will take the amount of time in this course I am not sure that the understanding of these flags are very very well understood so that in the subsequent lectures we could proceed further without any problem so let us start with the explanation for each other flag just to have our continuity zero flag as you are aware any arithmetic operation if it results into zero then this flag is set in a sign flag so if you are aware of sign magnitude form or a two component form in any form any way the msd bit is meant for a sign bit so if that is set the sign flag is set and the carry flag is if suppose you two binary numbers are added and if there is an overflow from there carry flag is set and overflow flag is different from carry flag so overflow flag is meant for sign measurement let us see how they differ in the subsequent course please go through this question here we are saying that there are four flags in the system control flags are there this is negative and this is zero and this carry and overflow flag of course it is a four bit i and u and then it is performing the four bit arithmetic I want you to this is a presentation and then spend one minute of moments to do this and then see which are the flags are set are here and then choose one of the options based on what you think is the right option now the correct option is this now let us see how these flags are set when these bits are added now the same problem given here these numbers are the same let us try to interpret these numbers what they mean as I told you this is the four bit number it could be equivalent to 8 bit or in bit by the simply copying this sign bit to all the higher bit positions so whatever you understand from four bit is applicable to 8 bit or 15 bit or 30 bit also if these values for each of this if it is unsigned it will correspond to 30 because you will consider this to be a 8 plus 4 plus 1 but if it is a sign value how do you convert it is it a negative number or a positive number because this msb because it is a four bit remember that so this is a msb bit if it is one this is a sign bit actually so it is a negative value all of you are aware and may be I have not mentioned it now in this processor especially ARM processor and most of the processors use this complement as the representation for sign number so in this case it is represented in this complement so how do you convert this into a negative number what is this correspond to it corresponds to minus 3 how do we do that you complement all this bits and add 1 what you get is because this msb is 1 you put a minus 3 here now similarly you do this also you will get 11 and minus 5 now when you when we add these numbers either it is added as an unsigned number or it could result in a sign value now just you are binary arithmetic you will get this value now I want you to just on this and same here 0 is clear why the result is not completely 0 all 4 bits are not 0 so 0 flag needs to be clear because the result is not 0 now why should the carry flag be set all of you have done arithmetic you would have seen that there is a carry flag going out of this addition so it is quite natural that now what does it mean carry flag is set means this unsigned arithmetic cannot be accommodated within the 4 bits because you know the setting just level cannot be accommodated because maximum what you can accommodate will be 4 bits between so it cannot be so the carry flag is set that means it is the unsigned overflow now you see here the 0 flag is clear 1 and 0 is already 0 you have seen that and also flag is clear that means the signed arithmetic can be represented in this 4 bits which is minus 8 now how do we know most of the metal got it right or some of the metal got it wrong this overflow flag how it is set let us see how it is done the answer is here correct and here you see that this answer is correct now the explanation for overflow flag is that it indicates whether the signed result that signed arithmetic after the operation can be fit into the available bits or not here V is clear because minus 8 can be accommodated within 4 now let us see how it is computed in a typical hardware when you do arithmetic if it is a 4 bit arithmetic this is MSB and MSB on the one bit which is closer now next to the MSB it is also considered a carry flag carry coming from this addition is also taken as an input apart from this carry now these 2 carries are absorbed to come up with a overflow flag so this is the way overflow is flag is set now anyway this corresponds to the correct value but now this is the way to see whether overflow flag will be set on now let us see one more example where you see that the overflow flag is set here so take an example I want you now because I have seen the previous example you will be able to free these values and then the result is including this flag and then you can check whether what you get in your computation is same or not and if there is some misunderstanding that will you can clear it here all of you might have got it right both the values whether it is time or time value both are same because MSB is 0 so both are positive numbers so it can be just the same way now this results in 10 whereas let us see why do we say this time value is minus 6 now we have to see that the difference in interpreting the number whether it is time or time is difference in time we consider this also a positive value and then we say 2 to the power 3 here and then add this value to 8 plus 2 10 whereas if it is interpreted as time value we consider it as a negative number and then we do the extract this number from the two complementation of the process how to get the minus 6 value now if you do the arithmetic and then apply the XOR operation that I told you in the previous slide you will be able to get the values of overflow now you see that overflow that is dead here so the result what you got 7 plus 3 is 10 in time representation here you can go up to 7 you cannot represent more than 7 in time representation representation and what you are getting is minus 6 it is not 10 so it is not interpreted as 10 so overflow flag is dead so basically overflow flag gives you indication that whether signed arithmetic was done properly or not whether you can interpret the result correctly or not in this case if overflow of the flag is dead what you have here as result for overflow arithmetic is done so this is signed arithmetic and these numbers are interpreted as unsigned overflow flag is irrelevant whereas if it is signed overflow flag is to be considered now how signed and unsigned numbers are interpreted if it is in a C program you may write signed ink or unsigned ink and based on the variable whether it is a local or local in data segment and then when the arithmetic operation is to be performed the variable contents are copied to registers and operation is performed instead of CPU now when the CPU is performing the operation it does not know whether it is operating on a signed value or unsigned value it depends on the programmer or the compiler it knows when a particular variable is moved it knows whether it is the and then it looks at a proper flag whether it looks at carry flag or overflow flag to see whether the result what was you know got after the arithmetic operation was correct or so this is the base and signed and unsigned and signed integers are handled in a protocol so I assume to these are the various conditional codes and we will talk about this in the subsequent lecture but these are the flags which are checked for a particular condition whether it is equal or not equal or whether unsigned lower or same so I assume to verify whether these flags are correct based on this condition and which will make your understanding better so in this lecture what we have seen is to this design and then how they are tested upon numbers or whatever software and then we saw implementation in ARM and we test upon NDMS as well as the condition codes so we will be having some graph section associated with this to give you some exercises on how to interpret this flag and whether suppose in a program if you output greater than n or equal to j if both i and j are unsigned then which is the comparison we need to do unsigned higher or unsigned higher or same this is the instruction or this is the condition we should check that means carry has to be set if it is true the value that we are comparing if two values which are being compared unsigned then this is done if suppose two values which are compared are signed then one of these conditions are checked you can see that overflow flag is seen wherever there are signed operands are compared and then you see the carry flag is used where there are unsigned operands are used now you may have a question whether can we compare an unsigned number with a signed number that is comparing unsigned and unsigned because it is like comparing a person so we will see how these comparisons are used in the assembly programming and how the compiler uses these comparisons for including variables that you are using so what you need to understand now is that how these comparisons are used and if you understand this then when we talk about branch based on conditions or after the arithmetic operation there is a overflow or not when you are comparing those flags understanding of this will make your programming easier and if you need to write assembly code it is very very imperative and important that you understand these flags so I think we are through with this session I hope to understood the basic concept that I have to explain here and in subsequent lecture also we will be testing upon this concept but this understanding will help you to understand the programming of the form architecture we will be able to understand and thank you very much for your time and hope to see you in the next section and see you next time