 so try to answer this question when we execute a program on a computer where does the program reside so write down your answer on your notebook now you know what to do swap your notebook with your neighbor so you have to do two things if your answers are different you have to convince your neighbor why your answer is correct if your answers are same you should both discuss why that answer both of you think is correct how many of you are convinced that your answer is correct raise your hands large number of alright so you tell me what is your answer main memory one answer okay anybody else who is who has a degree of disc register there is one more choice left anybody alright so if you are convinced that a program when it is executing cannot reside on an IOU device not on your keyboard and not on your screen that much is sure alright the people who said disc so please tell me why the program should be on the disc alright so go back to the DUMBO model in your mind when we describe the DUMBO we did talk about an instruction being executed by DUMBO but we saw what DUMBO does in response to executing that instruction we did not talk about where does that instruction exist at the time when DUMBO is executing we did not talk about it really okay so this is sort of a fresh question now look at it this way what is the program it is a set of instructions says law of text for example we presume that this text is translated into some kind of an internal machine language so it will be a sequence of zeroes and ones of other but it is still a large amount of text first of all let us rule out registers because registers are really meant for holding some information temporarily which is relevant for doing a specific computation in response to a particular instruction being executed so that cannot be the resting place for a complete program comprising of all the instructions what about this indeed the program as we write it in C++ or something in the text form will reside on the disk just as large data may reside on the disk but disk is an external device just like your IO devices so when DUMBO is executing the program DUMBO can be going to the disk looking at one instruction executing it going to the disk looking at one instruction executing it DUMBO as we shall see later is capable of reading a whole lot of data from disk but bring it to the memory or push a whole lot of memory data from memory and push it on to the disk in that sense the disk is similar to an IO device except that it is not meant for interactive input output but for bulk input output so whatever DUMBO does DUMBO has to do with its internal tools which are a card used only for IO registers used only for scratchpad kind of thing only thing that remains in memory now notice that so far in the DUMBO model we said that memory is used for storing data values with names and so on but since there is no other place accessible to DUMBO while executing the program obviously the program itself must stay in the memory it will not stay in the labeled names that we have for the drivers so imagine that the memory is very large by then so some memory is used by computer for storing numbers and values and characters etc. that you give but some part of the memory is used to store an executable program so there are instructions, instructions, instructions we imagine now there are ten instructions in a program all these instructions first translated into its own machine language are actually stored in some part of the memory that's a separate part it has nothing to do with the part which stores the data corresponding to your program in that part the instructions are stored and actually when computer executes your program it actually goes to the memory fetches an instruction that instruction is decoded by the logic unit and then it is executed while executing that instruction the computer may fetch data from your data storage bytes bring it to scratchpad, do some computation, throw it back after executing one instruction computer will go to the next instruction stored in the same memory now at this juncture we are not very clear on how exactly those instructions will be stored but the fact is that the instructions are also stored in a memory, in the same main memory but in a separate part is that clear? this is the second question why have registers main memory and why not with the cheapest, that is this see this can store data you can read or write data from it registers can store data you can read meaning you can get data into registers and put them memory can also store data you can access data from memory and push data into memory so all these three devices conceptually serve the same purpose for the computer the data can be pushed in and data can be pulled out if that is so and we have already seen that the disk is the cheapest device storage device memory is far costlier and registers are still more costlier so why have all that, why not just use this no, write down the answer now this time it will be sentence one or two sentences we are all frugal people right we don't want to waste money unnecessarily so economic sense tells me that this would be ideal sastra or sundar cheap and beautiful you have to now write why this are not suitable as the only storage device of information program after all I just mentioned that your program as you write in c++ will anyway be stored in the disk the translated program by the way for the first time it will be actually stored in the disk when you execute the program that executable program is brought from the disk into the main memory and then executed the question is why do this jamela use the disk only now for everything everybody has written down alright now discuss with your neighbors alright you are discussed so what is your answer somebody that side yah you tell me so his answer is the disk is slower than the other items and therefore if I use only disk then my program will run very slowly how slowly alright any other answer yah he is attributing some greater flavor to a disk he says most of the disks are only they are read only disks you are saying nah we are talking about this on which you can read from which you can read and on which you can write so in that sense they are exactly the same capability as registers and memory we are not talking about CDs not compact disks oh these disks are other kinds they are magnetic disks so now for this question it is an answer which says that the disk is like a book lot of information so it will have not only this program which is executing but many other programs many other things and that is a big book whereas memory is like something which what you need is recently stored there ok and registers are not really capable of storing large amount of so therefore so that means the disk therefore should be used only to store bulk information like a library however if I tell you that this have the capability of being accessed in a very pointed fashion so I can actually go to a disk and say I want to read next 27 bytes from this point to this point and I can directly access it the disk actually have that capability so in short the capabilities are exactly like what you have memory also you have multiple locations and just as we said that dumbo can go to any location and we have just saw that dumbo can go to another location which has the next instruction well the L you can go to a disk to a specific location also the conclusion is that the only reasonable and right answer is actually the speed difference I can use disk to store everything I do use disk but reading from the disk every instruction and executing it execution may not take time because L you is fast but disk is slow it's a mechanical device so let me expand on the example that you gave except that calling it a book I will say memory is like a piece of paper in my hand whereas disk is like a book in the physical library which is our library let's say after the computer while executing an instruction what would you prefer go to library, read one instruction come back, execute it go to library, read one instruction come back and execute it you would like to copy all instruction in a piece of paper keep that close to you and execute one after another the instruction so that is the only reason why we do not use disk only we use disk we use memory we use registers in fact if speed is the criteria I want the fastest speed then what is the fastest of the three registers so ideally I should have only registers and nothing else cost say if I am rich enough or if I am willing to sell all my clothes then I can have registers but no clothes I have some registers reasonable size of memory and a very large disk later on in your subsequent years here you will come across what we call main memory databases memory is becoming cheaper and cheaper and cheaper every year and therefore there are computers which have such huge memory that most of the things are stored in memory only the other problem with memory memory is volatile power goes off all contents are lost but disk typically retains all the contents even if there is a power failure so is that clear why we do not use disk many of you might already know binary representation and decimal representation but some of you might be seeing it for the first time but the procedure is very simple you require binary school arithmetic division find quotient, find remainder divide the quotient again find quotient, find remainder keep doing that you will necessarily get 1s or 0s because you are dividing by 2 the remainder will be only 0 or 1 collect all these 0s and 1s in the ulta order from the bottom up and you will get the binary representation so first the quiz is the other way round given a binary representation convert it into an unsigned integer so this is a binary representation you are not converting a decimal number into by this way it is not one lakh one thousand ten it is one zero one zero one zero what is its equivalent in decimal number one hundred you are supposed to calculate so how do you get forty eight forty two has everybody got forty two now let me ask the negative question is there somebody who could not get forty two as its value yeah so what value did you get sorry eighty four so you can you recalculate so you have to multiply each binary digit by an appropriate power of two what is that appropriate power it appears to me that you have got one power extra somewhere alright anybody else so this was a bit heavy stuff right how many of you have understood hexadecimal representation completely you might have heard about it earlier no smart I couldn't understand it if somebody explained it so quickly to me meaning I can understand what is hexadecimal I can understand what is octal but I don't think I can quickly figure out how to convert a decimal value into hexadecimal or octal quickly or vice versa but the method is not namely what is the base to divide if you want to convert from decimal to hexadecimal or something find a reminder but to deal with a b c d e f as digits is not psychologically easy very fortunately we don't have to deal with either binary numbers or octal numbers or hexadecimal numbers when we write programs we deal with our favorite decimal numbers most of the time but it is important for us to understand what happens internally and this whole effort of this lecture is to tell you about what is happening internally so just to practice a bit more on that this is the quiz this is a signed integer so imagine whatever was described as signed integer what is the equivalent decimal number 1 0 there is a difference between a signed integer and 2's complement representation in a signed integer the most significant bit is used to represent a sign if it is 0 it's a positive number if it is 1 it's a negative number the number itself comprises the remaining bits some people are doing it very quickly why won't each one of you to actually calculate that what we normally do exchange your notebook with your neighbor and check whether you got the value alright so let us now take a majority poll how many people think that the value is minus 10 how many people think that the value is minus 22 so let's have argument between these two groups these seem to be the majority of the groups but let's analyze what it means first of all if this is a signed integer then the most significant bit has to be considered to be representing the sign if it is 0 it is plus if it is 1 it is minus so clearly the number is negative so 17 or some such answer is not possible because if the most significant bit is 1 it's a negative number now once we know it is representing sign and once we know it is negative we take it out now what remains is 0 1 0 1 0 that is actually the number the most significant bit of that number is 0 so 0 now first of all how many bits are there in that number 0 1 0 1 0 5 bits there are 5 positions so you will multiply each position starting with the least significant bit by 2 raise to 0 2 raise to 1 2 raise to 2 2 raise to 3 and 2 raise to 4 0 gets multiplied by 2 raise to 4 that is still 0 1 gets multiplied by 2 raise to 3 how much is 2 raise to 3 8 so you got 1 representing 8 next is 0 multiplied by 2 raise to 2 0 next is 1 multiplied by 2 raise to 1 how much is that 2 8 plus 2 is 10 the last is 0 multiplied by 2 raise to 0 still 0 so what is the number now minus 10 please note the question he says as suggested earlier in the 2's complement method the representation would be different but please note what the question says this is a signed integer signed integer is different from 2's complement if you interpret this number as 2's complement representation then the value will be different but the question says if this is a signed integer what is the value asking how do we give a command to the machine to say do this as signed integer rotate this as 2's complement etc well we don't every computer when it is built when the circuits are built the internal representation is pre decided if you want to deal with an independent representation you will have to do some jinx and write some long programs ordinarily most computers use 2's complement but here is a question for the purpose of our understanding of what is signed representation what is 2's complement etc in that context the question is being asked if you get signed integer there is exactly one number which has 2 possible representations and that is 0 in a signed representation signed integer representation only 0 can be plus 0 or minus 0 so 1 and half 0's and 0 and half 0's still represent 0 but every other number will have a unique representation so minus 10 cannot be represented as a signed integer in any other way try to work that out whatever you say write down those bits take out the sign and convert the remaining number into decimal will not get 10 that we are talking about is a 6 bit number is a 6 bit number where the first bit is signed bit if you had a 32 bit number where you wanted to represent the same value you would have worked 0 0 0 0 0 0 0 and the last few bits will be like this so it is the capacity of the memory location which decides how many bits will go into that representation so this is the 6 bit number and if you are dealing with 6 bit numbers you will get all sequences with 0 and from 0 0 0 0 0 0 to 1 1 1 1 or 1 0 0 0 0 0 and 1 1 1 1 1 1 these are the various possible numbers for a 6 bit representation thank you