So let's begin with the last phase of the compilation which is machine code generation. And what we're going to look at in next remaining classes, whatever remains there, how do we convert now into a different equation of how it's the next of the machine. Now, the only issue which is left now is that we have already done all the code generation. We know that here this code is going to be very close to whatever machine we think of. We'll pick up a symbolic machine which will be close to almost all kind of risk-insist architectures. And we are just going to convert that into popular syntax except one thing, and it is the register optimization. So what we also simultaneously do is we'll see that with the activity variables. We want to minimize all the number of categories we have in that all the categories, as far as possible, anti-capital registers. And if in case it does not fit into register, then we also have to see how to spill the register and then load it back. What we are not going to do is look at register optimization problem, because that is something which goes really beyond this, and which is an independent activity. And there are a lot of graph based algorithm which are available. Graph does we can get from the register optimization. So we'll look at functional correctness, and we're not going too much about as far as register problems are about optimization itself. So this is really what you see here as the specifications that we have this front end. We have seen an intermediate port generator. We have all the information at the symbol table. And now we want to take information from the intermediate port generator, which is the theater score. We want to take information from the symbol table, and we want to give the complete syntax of the machine. And what are the functional requirements? Obviously the output port is correct. That is the biggest functional requirement we have. Also the port must be of high quality. And then the port generator itself should run efficiently. It should not happen that port generator takes so much time. Then whatever gains we have in terms of an efficient port, those are lost. So these are heightable functional specifications of what we want to do. And what are the inputs and outputs we have? So input is an intermediate representation with symbol table. And the assumption we are going to make here is that input has already been validated by the front end. Because if the input is not correct with respect to the language specifications, then even the intermediate port generator would not work. So process would have been terminated right there. But at this point of time, it's unlikely that we'll find any kind of error scale. But there are other issues which we'll talk about and we'll address those issues. Now what about the target programs? Target program could either be an absolute machine language. Now this is very fast for small programs. And you have already seen that how to be actually generate machine port. So we have seen that patching. We have seen to generate the numbers there which are PC values. And we can now generate absolute machine port. We can also generate relocatable machine port, which is normally what we do. Because the advantage with relocatable port is that I can have multiple functions and that I can link them. In case of absolute machine language port, so absolute machine language port, even the linker has been absorbed in the compilation phase. That is not something which is desirable in the little world for very small programs. And then we may have an assembly output which obviously will require assembly linker and loader support. So normally most compilers either we generate this or we generate this. But we'll not go for this unless one is really, really the retoy compiler. And I don't know how many of you have used programs like Turbo-C compiler. Have you ever installed Turbo-C compiler on your machine? Some point of time? How many? Any kind of turbo compiler. Most people do it at the level of school, not even in the graduating school. So not in IP. You must have done it in some time, class 10, 11. And if you recall, by installation, it asks for two, three options.  And if you select the option tiny version, what it installs is a compiler which actually generates absolute machine port. It will not permit you to write multiple functions and multiple files and it will allow you to do it. Just remove all that. The compiler becomes very fast. But then you can only handle small programs. So we are only dealing in this space and we will not worry about the absolute machine port. So what are the issues we face? Now these are the issues I am flagging so that when we actually start looking at the algorithm, you will realize that why these issues are important. So first issue that comes is the uniform. Now since we have done a similar language program, if I pick up a typical, say, assist machine, then I am not dealing with this for the timing, this is just maybe too trivial for this. But assume that you have a assist machine and you have off-codes. So typically, how do I equip this machine? I have off-codes and I have addressing modes. Now can I take all addressing modes and leave them with all off-codes? Have you seen whether there is kind of problem in doing that? How many of you have the experience of extensive assembly time program? Extensive means at least you have written, say, 100 to 200 lines of code. That is all the small for assembly. But about 100 to 200 lines of assembly code. Anyone? No one. Is that interesting? Even in CS240, you will do that? Or you have power to do that? Power to do that. Graduating in forget the beta also. Come on. CS240 was only last year. So what happens normally in off-codes is if you see addressing modes, most machines have a lot of off-codes. But there is off-codes to not work with all addressing modes. So for example, if I say that I want to do addition. Addition will say that it will work only with registers or it will work with indirect registers, for example. Or if I say store, store will work with index offset. May not work with registers. So normally, you will find that if you look at machine specifications, there, they will say that certain off-codes are not going to work with certain addressing modes. That immediately brings an issue of unique. Or if you say that if I pick up an operation, what are the access modes? Addressing mode is nothing but an access pattern. Addressing mode is the one which is telling you that how can I store the variable and how can I pick it up? This immediately says that you have to be careful while choosing off-codes. Because all addressing modes may not be applicable on this. All access patterns may not be applicable on a particular address mode. So this is one issue. You have to be aware of that when I'm picking up an addressing mode, it means an access pattern. Then I need to pick up the right kind of off-codes for that. And vice versa. Similarly, when we talk of completeness, and this question has not been answered, as yet even in the research community, how do I prove that the intermediate representation I have generated can be completely mapped out to the machine? Will I get into a situation where I cannot find a machine off-codes? I cannot find an addressing mode to map that intermediate representation to the machine? So this issue came up very early in the game, and machines did not have, for example, multiplication and division. So on architecture, you don't have an off-codes for doing multiplication and division, and suddenly you found that if you had to do multiplication and multiplication and division, you had to do completeness. Somebody was able to write a macro and saying that a multiplication can be done by a sequence of additions. Can I get into a situation where I say that something just cannot be computed? Is there a proof for that? My experience, we know that we're not getting into a problem, but at least from the search point of view, completeness still remains an issue that there's no guarantee that compilers will always be able to generate the functional code. Instruction speed is another issue that comes up that I can write multiple programs for doing the same computation. That means I can generate multiple codes at the target machine and which will do the same computation. Now which one is better? Sometimes you see that some programs are going to be faster, some programs are going to consume less number of memory cycles, and there are more issues like if you, again, go into the research direction, it will even talk about that which is a speech program. That's a program which will consume less energy. So can I generate instructions which are power sensitive and which will consume total less energy? That is, again, an optimization, but we'll only look at optimization with respect to resources and speech. We'll not go into the power mode, at least not in the solution. Then register allocation becomes an issue for us that instructions with register offerings are going to be faster. So the variables we are going to store in registers, normally the variables which have long life times and which have very frequent taxes. Now long life time may be determined by saying what is the start time and what is the end time, but I may be only accessing it once in the beginning and once in the end. That is not really the long life time. Long life time should be coupled with, yes, it's a variable, not just the time. So all long life time encounters which are frequent variables are going to be in the registers, and then they are also going to be every location than on some machines. I'll also have to worry about clearing of even and not registers, typically to take it to machines and fit. Almost every machine has an internal processor. You'll find that if I take a long word, then you have to pair it in certain way. I cannot say that take register three and four, and load this word, I may have to take certain payout for registers. So even when I have more registers available, I may not be able to load certain variables into the registers. Evaluation order of instruction again remains an issue that if I have a large expression being evaluated, what is the evaluation order? On it says that I must compute from left to right. Once you have converted that into some kind of abstract syntax tree, and for optimization reasons, you may find that it may not be beneficial to compute from left to right. It may be beneficial to say that if we first compute the other side, store the result somewhere, and that may compute fewer resources. So again we'll see an example of that. So you'll see that as we keep on moving, all these issues will be at some point of time raised and addressed. So let's look at four generation or what I call as instruction selection, because we have already been four generation at this point of time. What we are looking at is concrete syntax of the machine. So what may happen is that if I take something as trivial as saying that two assignments, A is being assigned B plus C, and B is being assigned A plus E, then I can generate very trivial code for this. All I need to do is that for the first three address instruction, I generate three machine instructions, and I'm using a generating syntax. This is not taking any of the machines. You will recognize this as soon as you read it. So this says move B to a register, add C to the register, and then move register to take. I'm not using again addressing words of A, B, and C. Assuming that is address removal permissible, then I just use them, and then I say that when I come to the second three at the store, I'm saying move A to register, add E to register, and again move register to B. So somewhere you will find that this move would be equivalent to load, and this would be stored. So again symbolic names may be different from different machines, but this indicates that in which direction I'm moving my data. Now you can see that I can do some very simple optimizations, and I can do an optimization saying, oh, I remember that A is already in the register, so I don't have to have a load again. And I can immediately eliminate these instructions and reduce instructions from number of instructions which are here, six to five. Is that a big gain? Six to five instruction reduction? Yes. Yes, so if you count with some percentages, they look like it's like a 16% gain on the speed. But actually what may happen is that if this is part of a loop and that loop operates a large number of times, then this cumulative gain can be very high. So one is not really talking about only programs which will have six instructions because six instructions absolute time will be so small that it really doesn't matter, but one is talking about overall program optimization. And if I have an instruction like this which says that I want to increment A by one, then I may have an instruction says move A to R zero at immediate one to R zero and then store R zero to A, but many machines will also provide me a single instruction to say increment A. Now what may happen on some machines is that when I'm trying to increment A that A if it is in memory may not be increment instruction, may not be allowed, only if A is in register then increment is allowed. So normally what will happen is that if I have a loop going on and this is really the loop counter, then assumption is that at first time I must have loaded this. So if it is just this and I say that instead of add I use increment that doesn't give me much gain, but suppose this was already in register and every time I say I need to increment my loop counter by one, I mean this is typical form loop one is going to write, then instead of using add I can use increment and this increment is going to be much faster, okay. Why? Because not only this is a single instruction, it has fewer fetches, at least I mean it does not have to worry about the number of sites we say. And this, how do I know the cost? How do I know the cost of each instruction who provides me that? You can look at an architecture manual and that will provide you the how many micro, four micro cycles each instruction is going to take, okay. In fact they provide a lot more information like how much power each of these instructions is going to consume, okay. So if you really want to optimize you can look at all those parameters and then you can find out that which is the fastest possible code. So you can find that we'll get into situations where if I do very trivial code generation I may have generating sequence like this but then I can optimize. Now what should I do? Should I generate this code and optimize? Or at this point of time I do the analysis. So most of the compilers will take an approach that first generate trivial code using a trivial algorithm which is functionally correct and then optimize it using a technique called equal optimization, okay. So here it will say that people optimization will again look at people optimization but will people optimization will say that I have sequence of slow and load and therefore you can eliminate second load and the first load is one which will slow the value but value always remains in the register and then just reuse that, okay. So this way I can do straightforward code generation and efficiency is not an issue but efficiency can be adjusted by an optimization. So you can see that if you now recall overall compiler structure I gave you there was an optimization phase between the front end and the back end and then there was a post-code generation optimization, okay. So at every step, so I talked about optimization which was at the level of algebra where we said that in three address code if you have additions with zero, addition, multiplication with one and so on you can eliminate that and then post-code generation we had an optimization which was people optimization and those are the ones that we are going to address. So let's assume certain target machine, okay. Now what we are assuming for target machine is if you want to really pick up complicated examples that we have five addressable machine and four bytes are forming a word and it has a sequence of registers R0 to Rn minus one, depending on the machine you may have eight registers, 16 registers, 32 registers, one pair registers and so on, okay. And two address instructions are in the form that I have op-code, source and destination. So I don't have three address instructions but two address instructions and machines which will provide you op-con, op-to, destination, okay. So that machines like this where you actually have to give three addresses but we are assuming that I have two address machine source and destination so it also is this is op-con and op-to and one of the op-prenses also is a target of the instruction, okay or target of the computation of the instruction. Then we have standard op-codes like move, add, subtract all the arithmetic and logical operations, okay. And what are the possible addressing modes I may have? I may have absolute addressing mode where I say that take this content of memory location or I may say take the value in the register or I may say that I can use indexing where I say that my register has an address and I take that address, add some constant to this and then fetch from memory location the contents of that particular memory location or I may have an indirect register where I may say that my register contains an address and then I'm trying to find the contents of the memory location whose address is stored in the register or I may have indirect index where I may say that I apply one mode level of indirection or I may have little where I say that add this value immediately or use this value immediately like I said add immediate one, okay. Now just to give you non-uniformity things you will find that if I have add instruction you will find their machines which will say that if this operand the first operand is up to can be stored in three bits, okay. Then this opcode is different but it needs to be stored in four bytes, okay. Then this is going to be different, okay. So there may be instruction like if you look at Motorola instructions that it will say add immediate, okay. Now add immediate means that this whole instruction so what they did was something very tricky, okay. This said that normally your opcode is going to be stored in four bytes, okay. But since add immediate we know that operand can only be fitted in three bits that the reduced size of opcode and the part of the operand was encoded in that opcode byte, okay. That means in a single fetch you'll be able to get both the opcode and one of the operands, okay. But it cannot, so now and why this instruction is provided you can see that most of the time what is going to happen is that if you are incrementing your loop counter you increment it by a small number, right. I mean you don't say increment it every time by 100 you may say increment by one or two and normally these kind of instructions therefore will work much faster, okay. So architects normally will provide you different kind of instructions which will do the same thing but on different data sizes and different address inputs, yes, okay. So there's a kind of machine we'll assume, okay. So you can see that this is a generic machine and you can actually take any architecture or any opcode, any instruction set and you can sort of find a mapping from one to one map, okay. So this is my machine model. Now let's look at starting of the code generation and the first thing I want to do now is assuming that I have generated free address code I want to break this free address code into what you know as basic log, okay. What is a basic log? A basic log is a sequence of free address code which can have a single entry and single exit. That means I can jump only to the first instruction and once I start executing the first instruction all instructions in that basic log must get executed and I can exit out of this basic log either by naturally falling through the control or by having an explicit jump statement, okay. There's no way that I can have a basic log and I can say that jump into middle or exit from the middle. These kind of situations are not permitted. So there's a reason for doing that, okay. The reason is that this gives me a structure where I say that I can do certain optimizations on this without worrying about how control is going because I know that how control is going control is always going essentially, okay. And only the last instruction can be a jump statement and within log obviously then I'll not be able to jump, okay. I'll have to go outside the block to jump back, okay. So sequence of statements in which close control enters at the beginning and leaves at the end. So what is only permitted is a situation like this, okay. No matter what's in the middle, no exit's out of the middle, okay. And how do I find out now what are the instructions, three address instructions which form the basic log? How will I do that? I'll give you some remains very simple. Just from the definition what I can do is I can start scanning my three address code and mark certain instructions as leaders. And what are the instructions which are the leaders? First instruction obviously is going to be beginning of a basic log. Then I say that anything which is target of a jump has to be beginning of a basic log. Any instruction which follows a jump instruction also is a basic log, beginning of a basic log. So all these instructions I, in my three address code I mark as leaders. And then I say that start scanning instructions from a leader up to the instruction prior to the next leader. That gives me a basic log, right. So basically what I'm doing is I'm taking my three address code and within this three address code I say this definitely is a leader instruction. No doubt about that. That is the beginning of a basic log. Then I say that target of a jump, the target of a jump instruction has to be beginning of a basic log, okay. Aren't do anything about it. And what is the third thing? Instruction next to a jump.  So next instruction was always the beginning of another basic log, okay. So once I mark all these leaders, okay, then what do I say? And these are the leaders I mark during this logic. Then I say every state starting from the leader up to the next instruction is a leader and they give me all the basic log. So first thing I do is I take this three address code and break it into what we know as basic log. And once I have constructed a set of basic logs, then I say let me add now control flow to this, okay. So what do I do now? Okay, so just finish this slide. So first statement is a leader, any target of a go-to is a leader, and any statement that follows a go-to statement is also a leader. And each leader and its basic log consists of leader and all the statements are put the next leader, right. Now how do I add control flow? So now I say that I'm going to now actually convert this into a graph where I'll say nodes are going to be each of the basic logs. And how will control flow go? Control flow will say that if there is an explicit jump from a log V1, so suppose I say these are high basic logs, V1, V2, V3, and V4. If I say that there is an explicit jump from V1 to V2, then there is going to be a range from V1 to V2 in this graph. And if there is a natural flow of control from V1 to V2, then there is going to be a range from V1. Okay, I will hurt his neck. Why don't you wake him up and ask him to go through this one? You'll hurt your neck the way that you're filtering. You can go back to your room and sleep there peacefully. You don't need to come here, right. Any other edges I can add here? So basically what you're saying is that in the control flow graph, in the flow graph, I'm taking all the basic logs as nodes. Nodes are the basic logs and if there's a directed edge from V1 to V2, then V2 can follow V1 in some execution order. Or if there is a jump from the last mentioned statement of V1 to the first statement of V2, these are the only edges I'm going to add. Do you need an example for this? So if I just say that, look at a situation like this. So what are the kinds of graphs I can get? I can get something like this. What may happen here is that the last statement may not be a jump statement. Still I may have an edge from V1 to V2 because there is a jump from the last statement of basic log 2, the beginning of this procedure. That means this instruction becomes a leader and this follows it in the natural execution order. So if I have a jump or a conditional test here, I can construct my control flow graph. And all further code generation will be done on control flow graph. And why I'm doing the control flow graph? The idea is that as far as the basic log is concerned, I'll be able to generate straight line code for that. And as far as the last instruction, if it is, if it happens to be a jump instruction, which is either a conditional or unconditional jump, then I'll be able to generate a different kind of instruction for that. Because jump instructions, free address jump instructions are going to be mapped on to machine instruction in a slightly different map. So this, taking a free address code and converting this into a basic log and then a control flow graph makes sense. Is it to understand? Any problems? Any questions there? So then let's move on. And what we want to do now is we want to now do the register optimization. Register optimization to the extent, saying that if some value is already there register, then I want to use it. I want to use the same location. And for that I compute what we know as next use information. And next use information is going to be contributed for each of the basic blocks. And why I'm contributing for each of the basic blocks? Because it does not have control flow. Control flow is strictly sequential. I can scan all the instructions. And I know that I don't come across a jump instruction. So what we do first thing is we actually use some rotation and say that if this is the kind of instruction I have, then I say that this is IF instruction. It is defining variable X and it is using two variables, Y and Z. This is the normal clicker value. So basically we are saying that I want to now optimize registers and temporary allocations. And I want to remove variables from registers because they are not going to be used. So suppose I take some temporary value. So X, Y, Z could either be two defined variables or they could be temporary variables that can be generated by the compiler. And when does compiler generate temporary variables? So whenever I'm generating the address code, you will find that compiler generates all the T1, T2, and so on. Those are temporary variables. These are not the user defined variables. So compiler is going to generate that. And hopefully I'm going to put all these temporary variables into registers as far as possible if I have sufficient registers. Or I optimize that. I minimize the number of temporary and then use fewer registers. Where did we see that earlier? Somewhere did we have an example where we were minimizing the number of temporary and doing some optimization. There was that. Type checking syntax translation. When I was looking at saying that I can keep all these attributes somewhere and rather than keeping attributes for the lifetime of the program, I said I want to keep attributes only for the lifetime of this attribute only. And then if you recall one example we had in the type checking where I was trying to define declaration of an array, I reduced all those attribute equations into three locations. And I said I can use only R1, R2, and R3. And then we realized that some of them were copies of each other and I could reduce the whole thing to just two registers. So we have already done some kind of resource optimization. Now what we want to do is, we want to systematically look at each basic law, look at how many temporaries it uses and minimize number of temporary. So that I can reduce number of registers I use. I don't have to do register screening because if I use too many temporaries then I will not have sufficient number of registers. So what do we do? We say that this statement which says x is signed y of z is defining x and is using y of z. And we say that any variable from register is going to be removed if it is not going to be used in. So what I do is systematically, suppose I have this instruction x being designed y of z and suppose x is in a register. And beyond this point x has no use. So if I look at a sequence of instruction and I find x is not being used here, I can immediately free all the resources which are found with that particular x. Now when I say free, what that means is that the same resource can be now used for another temporary. That is what free means. So scan each basic law of records and you will see why we are doing this. And assume that all the temporaries are negated. So register allocation and register optimization are only going to do across the basic law. That means when I enter basic law, no variables are going to be registered. And when I exit basic law, no variables are going to be registered. Now there is another technique which you will learn in some other course not in this. Where you say that I want to do optimization across the basic law. But optimization across the basic law requires a general technique called data flow analysis because I do not know which paths may be followed. So to reach this particular basic law I may follow this path or sometimes I may follow this path and I have to optimize it across all the paths. And idea of the basic law is that you have only one path so I do not have to worry about data flow analysis at all. That is what makes it simple. So what we are going to do is we are going to assume that all the temporaries because we are doing optimization only within the basic law. That all the temporaries are made on exit and all user variables are live on exit. User variables have a live time which is the whole program but temporaries have a live time which is limited by the boundaries of the basic law. There is an assumption I am taking. And if we do data flow analysis we can extend this and say that these temporaries are going to be live even across the basic blocks and they can be live anywhere but since we are not doing data flow analysis we will not worry about this. So are boundary conditions clear? What we are trying to do here? No. Say something now. So what we do here is that for each basic law now I will make a small symbol table. They are very simple symbol table. All it says is that I will keep status of each variable available in this symbol table. And this will say that whether a variable is live or dead. Live or dead means whether it has a future use or it does not have a future use. Any variable which has a future use is live any variable which does not have a future use is dead. So what we do is that suppose I am scanning this instruction then what will I do? I will say that 2 i's I am going to attach information in this symbol table about variables x, y and z. I will only worry about temperature I will not worry about user variables. And then I will say that beyond this point I will say x is not live and it has no next use in symbol table and I am going to say y and z to be live and z to be live and has a next use in i. Now first conceptually understand what is happening. And then we can go through the cellular then I will pick up an example and then take me to an example and explain this. But conceptually I am able to see what I am doing. So suppose I say that I am scanning this and let's say I am at this point. See I can only get points which are either next to instruction So suppose I am at this point. Now when I am at this point what does this point mean? At this point it is saying that x and y and z are going to be used here. So this is what I am saying that y and z are live at this point and they have a use in i. They are going to be used here. And this is saying that x is not live and it has no next use in the symbol table. That whatever x is being created here whatever x I had prior to this is no longer going to be true. From this point onwards this is the x which is going to be live. All prior axis are going to be now dead. This is what I am saying. So if I take any instruction and I say that let me find out status of each of the variables at this point. Just before this instruction passes. This instruction so basically at this point my information is that whatever definitions of x I had prior to this is valid because beyond this point this is the only definition of x which will be used in a basic law. And at this point I am saying that y and z are still live and they are being used here. And obviously if I come to this point then what will I say? What can I say about y and z at this point? Whether they have a future use or not? So at this point after this instruction has been executed what can I say about status of x, y and z? So at this point is x live. We are scanning that way. Yes. We have already scanned that way. So exactly the point I am trying to break out is why I am scanning backwards. So if you just scan forward at this point you cannot say anything about x, y and z unless you see the instructions which follow it. And scanning backwards I will be able to see that information and that is the reason I actually scan my code backwards and not forward. So what is the use of a variable and then I find the most recent definition of that variable. So what I will do is I will start there for scanning in this direction and at some point of time I say that x is being used then I immediately set x to live and say this is the definition I am going to use in an instruction and then I will try to find out the most recent definition of x and say this is the way definition of x which must be used here. And that is the reason I do not scan forward. Because in forward scan I cannot really determine anything about x, y and z till I scan everything till the end. So that is unnecessary long questions. So it is logic clear why I am scanning my code backwards and why I am setting this kind of status. So what we can do is we take an example I take you through this algorithm and actually show you how do we optimize. So let me write a piece of code and let me copy this on the board and then I go back to the previous point and what is the example of. So that both the algorithm and the example remain in front of me. This says that we just copy here this says t1 is is star k. So this is clear this code t2 is is star v t v is t2 t4 t1 plus t5 is star v and t6 is t4 plus t5 and x is sine of t6 and what I have asked this is instruction 1 this is this is what my instruction is now what I need to do is I need to create a simple table and how many variables I have for which I need to have empty different table. I am only worried about the temporary variables I will not do any optimization of the user variables. So a, b are user variables and p1 a, b and x are user variables and p1, p6 are the temporary compiler variables. So what I say here is that I have 6 entries here because only 2 p1 p2 p3 p4 p5 p6 and then I say that let me scan variable status at these points these are the points in my program. Now first thing I have said is that at this point all the variables are dead nothing is left because I am not looking at life of p1, p6 beyond this point so assumption I gave was that all the variables are dead. So what I do is I set in my simple table that all the variables are dead and now look at what I am doing here. So what I am doing here is that when I scan this instruction I say attach to i information in simple table about x, y and z. So now I am saying that I am attaching to 7 information about p6 and information about p6 what is the information about p6 in my simple table this p6 is dead. So here I attach information saying so let me write it here but I think this is the case. So p6 is dead there is only information about x as I said x is a user variable so I don't even worry about it. And once I have done this then I say that set x to not lie and load x2 in the simple table. Now what is x? x is the left hand side which is a user variable which is not a category variable so I don't change anything in the simple table and this says set y and z to be live and it says x2 is in i in the simple table. So on the right hand side I have p6 so what I do is that I set p6 to live and I say use in clear what I have done so what I have done is something very simple I started with my simple table saying that all the variables are dead which was the status here then I just followed these three steps I said to 7 I am going to attach information about p6 and I said p6 is dead that was in the simple table and this order is important and then I said set x to not lie so x is not a user variable I don't do anything about it I am not even in my simple table and then I say that set y is that to be live and say it has an exclusive simple table in i so I have set this to live and I say this is now as a user itself so I am actually at this program okay now I go to this program okay so I am standing backwards I have done this I have done this how about about this okay I am at this program so first step clear because the first step is not clear then we have to get lost in the remaining class clear the first step is clear to everyone okay now I say again I just follow this okay then I say that I am going to attach to 6 information about p4, p5 and p6 okay so what is the information about p4, p5 and p6 this is p4 and p5 are dead and p6 is live and using not sufficient so let me write it on this okay so this is p4 and p5 are dead okay and p6 as in 7 this is the information I have in simple table but I will just talk with this information and I will attach to it okay and then I say set x to not live so what is my x here p6 okay so again I say that I remove this and I say that this is set okay and then I say that set y and z to be live and x to be in simple table so now I say that p4 and p5 are live at this program point and they have used in 6 so p4 and so I say they have used in 6 everyone is comfortable up to this point okay then I go back okay and I am at this program point now so I have done this program point and when I come to this program point what do I do same thing okay to attach to 5 information about the variables in the simple table p is a user variable so I cannot worry about it but p5 is now a variable which is definitely variable so I say p5 is use in 6 this is the information I attach to 5 okay and then at this point okay then immediately I go and start changing information and what do I say that set x to not live so I say p5 is not live p5 becomes dead here okay and there is nothing that I can go about right inside because it says y and z and this happens to be a user variable so I just pick out this okay then I have done this so I now come to this combination okay and what is this combination now this is saying that attach status of p1, p3 and p4 to this statement so p1 and p3 are dead and what are the status of p4 p4 says it has a use in 6 so I attach that information I say it has a use in 6 okay and how do I change my symbol table at this time I say that look at the second part I say p4 is not live okay so p4 is again going to be set dead and then p1 and p3 are live and have a use in 4 okay so p1 has now a use in 4 and p3 has a use in 4 this is the information I put in my symbol table okay so I am now done with this one okay now I come to this statement and I am again trying to attach status of each variable so p2 is the only variable compiler generated variable I don't worry about the envy and this says p2 is dead this is the purpose of I have skipped one so I have to now come to this p3 design to start p2 okay so now I do this attach information it says p2 is dead and p3 is what is the status of p3? p3 is using the information okay and then I come to this program point and what do I change? okay look at this so I say p3 is not live so I am getting dead and then I say p2 is live and has a use in 3 okay so p3 has now a use in 3 okay then I come to I am done with this program point now I attach information about p2 to the statement and I say what is p2 now so p2 has a use in 3 okay and then what do I do? after this come to the second step and say p2 is dead and A and B are user variables so I don't worry about it okay and then I come to this statement and I attach information about p1 to this so I say p1 has a use in 4 and then I come to this program I am done with this I come to this program point and now what do I do? I say p1 is dead and A is user variables so nothing is here okay so now what is my symbol table? you can see that in my symbol table all the variables are dead so I started with an assumption that at this program point all my categories are dead and when I enter again my categories are going to be dead but what it has captured is something very interesting it has captured lifetime information this is saying that p1 has a use in p4 that is the last use that means lifetime of p1 is only up to this this is where it is defined and this is where it is used beyond this point p1 has no use okay and this says that p2 is being defined here and has a use here beyond this point p2 has a no use okay similarly this says that p3 is defined here and has a use in 4 so the last use of p3 is here okay that is defined in the lifetime okay and then this says p4 is being defined here and is being used in is being defined here and is being used in 6 okay so that is where the lifetime of p4 is and here I say p5 is being defined here and is being used in 6 so lifetime of p5 is here and this says p6 is being defined here and is being used in 7 so that is where the lifetime of p7 is Now, if I say I want to bind registers or certain resources with this, for non-overlapping lifetimes, I can bind the same resources with this. So, how is this look now, that if this report I had, and if I attach now all this information, so we have already gone through this. So, let me skip this part and straight away take you to the final situation. Final situation is something like this, that even has a lifetime which starts at 1, which ends at 4. And then, T2 has a lifetime which starts here and ends here. And T3 has a lifetime which starts here and ends here. And T3 has a lifetime which starts here and ends here, which is 4 to 6. And T5's lifetime is between 5 and 6. And T6's lifetime is between 6 and 7. How many resources do I need? Do I need 6 resources now for this? So, you can see that this is non-overlapping. This is non-overlapping. I can actually do with only 2 resources. So, if I now to register a location, I know that actually I just need 2 registers. I don't really need 6 registers to do this computation. And what is it that I have actually have computed this? The computation is saying x is assigned a square plus 2 a v plus b square, x plus b whole square. Look at the computation. I have computed a square. Then I computed a to b and then I multiply that by 2. So, that is 2 a v and this is b square.  That is what I was computing. And now if you see, I mean logically you can see that as soon as I compute the first one. I can store a square in a register and then I can do computation of saying that compute now 2 star a star v. Keep that in register at the 2. And I am left with one more register where I compute b square. And then whatever was the first one that will match. So, basically now I can rewrite my whole code by saying that let me reduce number of countries.  So, p1, p4 and p6 can be in the same name. So, and p2 is a star v and p2 is 2 star p2 because beyond this point p2 has no use. So, I can reuse p2 here. So, p1 and p2 are non overlapping and therefore I can use the same variable. And then I can say beyond this point p1 has no use. So, p1 can be reassigned as p1 being assigned p1 plus p2. And then I can say p2 is assigned b square. And then I can say p1 is assigned p1 plus p2. So, this gives me a square plus 2 a v plus b square and x is assigned p1. So, basically p1, p4 and p6 have to be mapped out to p1, p2, p3 and p5 have to be mapped out to p2. So, instead of 6 resources I can do with only 2 resources. And what I have done I have just computed the lifetime information of each of the variables. So, basically next to the information is saying how do I compute my lifetime information and then minimize this information. But actually we will find registers and we will see that when we do code generation, we will use this next use information and then using this next use information I will generate code where I will be using the same register again and again. Because I will say that this register has no use and therefore can be used for this computation. So, is it clear what we went through? What we went through was by doing next use information over a basic law. I have computed lifetime of each of the variables and once I have lifetime of each of the variables all I need to do is find out which are the non-overlapping lifetimes and use the same resource for that non-overlapping lifetimes. Clear? Questions? How do I find the lifetime? How do I find the lifetime? So, this is saying that p1 has a use in 4. This is giving me the last use. So, p1 is starting from here and is being used here. This is the lifetime. That beyond this point, it starts immediately after 1 and ends with just beginning of the 4. So, this line is giving you the lifetime of p1. Why does this seem to be very, very, very useful? Yes? Use twice. Use twice. So, that is why I am scanning backwards and I know what is the last use. So, suppose I had a use of p1 here. Then this I would have attached saying that p1 is used in instruction 6 also. So, that is the information that would have come. I would never have made it that. So, that is why I am scanning backwards and looking at the last times and finding out what was the definition. Just coming to say a simple activity. Just insert one instruction here which uses p1 which is the same value. You will find that when I am scanning by simple table I will say p1 and p1 will never be set to that. p1 will be set to that only at this point. So, my lifetime of p1 will be, I will say p1 has a use in say instruction 6.5. If I insert something between 6 and 5, p1 has a use in 6.5 and therefore that information will be carried out on the way. So, let us wait here today and in the next class we will continue to use this information for portability. So, our next class is now on Q stick. We do not have a class over the weekend. So, that was our next class.


Welcome back and good morning or good afternoon depending where you are at what time you are listening to these lectures. We are doing continuing from the last lecture on the theory of liquids which is a big subject. There are books written on this chapter and it has been an intense area of research for the last more than half a century, aided very much by computer simulations. I will give a name of the few books along the way where you can take a look into it for more details. In addition to the book that we have here the statistical mechanics of the liquid that we have here there are several other books. In this book what we have been trying to do and I am telling you repeatedly the whole idea is to get kind of a statistical mechanical starting point or statistical mechanical view of physical chemistry and also materials and materials chemistry. So as I repeatedly tell that in undergraduate physical chemistry you have if you pick up a book say Castellan mood or Atkins you will see huge number of chapters, you will have liquids, you will have phase rule, you will have phase equilibrium, you will have chemical potential, you will have kinetic theory of gases, you will have binary mixtures, you will have polymer, huge electrolytes chapter after chapter and much of them the chapters are given you graphs, certain results and certain equations like Debye-Hooker-Lonserger equations, derivation is done in a rudimentary way. Things like solidation are described in terms of pictures, liquids are told you that is the density between the gas and the solid but they do not give good job even it do not describe in the properties of liquids which are so important for us for our chemical industry for biology. So the theory of liquids that have been developed in last 50 years with this theory it is based on statistical mechanical theories and aided heavily by computer simulation nothing would have been possible if computer simulation well not much would have been possible if computer simulation did not play the important role that it played which we will talk about more in detail. As I said in a last lecture that all it started with J. D. Bernal at Cambridge the famous extra crystallographer and J. D. Bernal got into his whims to really find out the local structure short end structure of liquids and this is what we already talked so what do you mean by short end structure? We will go back to Ising model again the famous our starting point Ising model we introduced in the spins up and down we introduced the quantities two important quantities n plus which we call long range order but there is one short range order n plus plus what n plus plus does if now if a spin is up here and the spin up there n plus plus tells me the number of such pairs now when the spins up and two up spins the next to each other that gives you a short range correlation that is why it is called short range order we use short range correlation in many places the short range or local correlations are very very important so short range and local correlations. So more quantitative way of telling of the liquid in addition to saying that the density is between gas and the solid and I already described everything should be in terms of rho sigma q sigma is molecular diameter then rho liquid is typically rho liquid is typically is star liquid is typically 0.8 is a wonderful number semi quantity which is not fully quantity but it is far better than saying density of liquid is between gas and solid density of gas is about 0.1 in this unit dimensionless in rho star density of solid 1 liquid is sitting next much of a liquid is sitting next to the solid. So as a result of the close proximity and the hard sphere kind of repulsive interaction you already talked about the potential that we repeatedly using that because of this part that determines structure of the liquids in the interaction potential as a part of this we have molecules touching each other and as a molecule touching each other they have a lot of short range order that is exactly like the n plus plus in Isaac model the short range local correlation. So my new definition of liquid would be liquid is has considerable short range order but no long range order but at solid has both short range order and long range order a ferromagnetic system lattice spins are aligned most of the spins are aligned and there is a very large degree of short range order of course there is a long range order non zero magnetization. So you need to now think of liquid as something which is ever unique we do not face this thing in the solid state phases the presence and the importance and overriding importance of the short range order that is not in crystal that is not in solids. Solids are characterized by long range order and that is enough the gas on the other hand neither short range order nor long range order. So liquid in then a new definition of liquid should be that it has a short range order okay and that is like in Isaac model n plus plus now we can go back doing next of our things. So how do we talk of this short range order how do we talk of the liquids I impress upon you or try to tell you that liquid is very unique is unique because of its this short range correlations that are in the liquid state that is what defines a liquid but then we do not have the average density does not tell me of that then we need a new language to develop this short range order and that language comes in terms of distribution function which has been described in detail in our book whole chapter is on distribution function. So what we actually want that at the simplest level that one if one by molecule here in the liquid then what is the probability of finding another molecule at a distance r that turns out would be primary importance that tells you locally at the nearest level level how molecules are packed that is the quantity that is picked up by neutral scattering in static structure factor and how the local caging that means the central molecule because of the high density as a very important quantity of liquid the density is large like the Rho star even water which we call low density liquid because of the open framework structure even that has Rho star is 0.72 and without all or a Rho star is about 0.88 or something like that go close to 0.9 as tonight tile is close to again 0.89. So you see molecules are densely packed or every liquid at a main conditions of temperature pressure are densely packed so this is very important to realize that as it is densely packed then what is happening we call a each molecule is each molecule is caged by its nearest neighbor and the strength of this caging determines to a great extent dynamics and static properties of the liquid like specific heat all these things are determined partly by this property okay then how do we describe it we start in a grand way we said okay I want to have not just two particles how the distance I want to have many particles what are this so this particle is at position R1 then say R2 R3 R4 I want to have n particle distribution so that is now defined by by very very simple by one is the partition function configuration integral of mere number of ways of picking it up then I integrate out all the ones which are not in my n so this is a n particle distribution function small n n particle distribution in a in an n particle system so capital is the total number of particles in the system and small n is the number of particles among whom we are looking at the correlations okay so now so basic this is the picture then that we are very ambitious we are trying to look into many body correlations and these terms out to be extremely important in disorder any these languages just this standard language of all many body systems whether it is glasses liquids liquid crystals everywhere this is the language that is so there is a flow flow chart given in the book and to how to go about it how to go about getting this rho n this quantity that we just discussed the n particle n particle correlation I want to know that how n selected particles are correlated that means if they are not correlated of course this probability of n particle will become rho n become will it out to the power n as we discussed in the last lecture the independent so this is a joint ball distribution this rho n that I am talking here this thing is a joint ball distribution and if they are not correlated at all that is the gas phase then I will say okay what is the probability of one particle in one position and the second particle in a position that we just wrote very weak correlation but in crystal not at all if I know one particle position I know the other particle position uniquely in the liquid that is in between but there are certain correlation have you go on particle here the probability of having another particle in a position can be more it can be less how do I talk about that that is what distribution function comes in and we do that but let us go back in the very beginning how it all started it started with the grand equation of statistical mechanics almost the equation of statistical mechanics that is level equation we will talk a little bit about it but we will not do a full job on the level equation that is that is that could be a lecture by itself and we are working on a series of time dependent statistical mechanics a book and probably a course and there we will work little bit more on the equation this equation is in chapter the derivation is given in chapter 4 chapter 4 of my stat mac book so you can look it up there is a not a bad job done there but usually as one of my student was telling today that usually it is in most of the stat mac books it is not a good job has been done but that the it actually had good job was done in the beautiful book by tall man Richard tall man in the statistical mechanics that is that is an ancient book and that is a beautiful book okay so we start in the floture everything starts the level equation then you go to a bbg equation equation born born green car could you have on five big names born max born boglio bog very famous scientist and very big famous stat mac guy and then he is involved in many many things including superconductivity he wrote a beautiful book on statistical mechanics which I used to have hard bond copy then green one of the father figure and stat mac then car could and you have one these are time dependent equations we will just discuss slide them and they can be then made into a time independent equilibrium for equilibrium that at equilibrium that become you have one born and then certain approximation is done to get the born green equations that we discussed little bit so so the level equation as I said the grand equation it work or full n body distribution n body full every particle in this system not it is not n body distribution it is both position and time dependent this is dependent it is same as the Hamilton's equations of classical mechanics essentially same at Newton's equation but this you know the difficulty of Newton's equation in theoretical work that it is in terms of momentum and momentum and positions of the particles that is great to compute a simulation many other things but when one tried to do analytical work in the kind of distribution function you have to put in the terms of delta functions and you have to go to a probability distribution that means equation Newton's equation of motion as such is not useful it is transformed into a probabilistic equation we will do that thing we do that thing very routine in time difference statistical mechanics we write an equation which we stochastic equation and then we transform into probabilistic equation that is a very common game we play that this game went back to a long long ago and the person who did first time is Leoville and Leoville derived this beautiful equation so fn here that I have defined that fn depends on is it depends actually on f as position of n particles momentum of n particles at a time t so fnt related in a shortcut version actually depends on positions and momentum position and momentum all the n particles very very important all the n particles and this is a commutator which comes from Hamilton's equations you know one can give a very simple derivation we will sketch the derivation in the next page but this is a commutator or Poisson bracket in quantum mechanics that become commutator because double equation is a quantum exactly quantum version you can write but in classical mechanics this is the Poisson bracket Poisson bracket with Hamiltonian as this and you can easily see that d a these are just the squares are just dot that d h d p i and d f d q this is this we know in Hamilton's equation but d h d p i on the other hand we know that this is nothing but this kinetic energy term of the Hamiltonian momentum gets a momentum here and this is the potential energy part of the Hamiltonian that gives to the force term so this should be the force acting on a particle i and that would be then come from interaction delta v term all right and this part remains the same these parts remain the same and one can again go back and say okay let me find out the one line derivation of Louisville equation is that let us see that in a here in a in a cylinder what is the change total change of the density this you now remember this phase space density the very first or second class that we talked about phase space density means in my 6 n dimensional phase space a point I can now talk in the 6 n dimensional phase space what are the number of particles in a small volume element in a phase space and now that allowed me divide that number of particles number of points in a phase space point that is number of microscopic states of the system in this small volume element that gives the density of the phase space and that time derivative now I am total time derivative I am trying to get however in that small volume element in phase space particles cannot be created or destroyed so they can just move through like I have shown this picture here they can moving through so there is no sink or there is no source term then when I write that that the molecules moving through then density into velocity then then the way they get is the density into velocity streaming out velocity of the momentum will be the derivative of will be the first term and that is now now this is the phase space density has to be conserved these goes to 0 and what is left here is stated is nothing but and these can be shown that these terms are nothing from Hamiltonian equations comes to these things so this is a one line derivation one can be a little bit better job on this but we are not going to spend more time but this is the level equation so level equation is fine we are we love level equation but level equation was then not it was used in many purposes but it was brought to theory of liquids in by this five distinguished scientists and they showed that the force that is there which is this term now I can try to get that force in decompose the force such that I have n particle distribution function so I have say a four particle distribution function then I have the other particles which are here I want to have these four particle distribution function then I have I can separate the part the acting from the force among themselves internally and between themselves and the one that without sight and that is what is done here that one is within that up to some is up to n other one is from n to small n to capital N all other particles when you decompose that then you can say okay I know I in order to define f n I have to integrate over d r n plus one d r n into the with a f f a full r to the power n I have to integrate that to integrate over n plus one to n those extra coordinates in order to get my reduced description that is done here exactly that thing has been done here so BBG guy if so from level equation BBG guy equation is you know one step process but the important thing to note in BBG guy that in order to get n I am connected to other distribution that means I cannot eliminate this I cannot eliminate that so my n particle distribution gets connected to higher order distribution function this is called higher entry so BBG guy equation is an exact relation with n particle and the n plus particle reduce for each so they you get when you integrate that these other ones then you can here you can show by separating out it goes to n plus one so we are landed up in a trouble that in order to find in order to find n in order to find in order to find n particle distribution we need n plus one this you can understand easily if you want to find in a say you know system where there is an external field to creating in homogeneity and I want to find what is the probability that one at R1 then in order to know that I then see I need to know the force coming from all other particles and I can integrate out and I can show this is connected with two particle distribution function because the force are coming from all these particles so when I integrate out in order to do one particle distribution I need to know two particle distribution then in order to know two particle distribution I need three particle distribution like that so this is called a hierarchy is that we are doing a slightly going at a first phase and slightly going but but you basic idea is to give you the flavor of the subject and the books are there particularly my own book and you can look into that okay so how what do we do now what is the next step dynamical approach of dynamics through BVGK hierarchy is exceedingly difficult and has not been much done very early attempt to do these kinds of things was the Boltzmann famous kind of equation approach Boltzmann tried to do this actually f1 rp r1 p1 t and you found that just like we found here through binary collision it is connected to f2 r1 p1 r2 p2 t so the first BVGK hierarchy was attempted in a little bit limited form by great Boltzmann himself and he landed up that he could do it and so he made the approximation of what is molecular chaos so the that he was heavily criticized for that this is very sad story now however we are now doing here equilibrium statistical mechanics we are at the structure of liquids not the dynamics so we now at equilibrium the time dependent of the distribution so the solution we are looking at is the time invariant that means there is a class of solution which does not depend on time we are not interested how distribution of functions are changing with time and that is done by put in BF equal to 0 when you do that then one can go to make certain change of variables and one is done here equilibrium fn is now talked in terms of you this equilibrium classical mechanics classical mechanics is very important to note here classical mechanics that position and momentum separates out so momentum goes out and so we have left with the equilibrium of the the end particle distribution so this is nothing but a definition or a nomenclature this is the condition of equilibrium when you combine these two go back to BVGK hierarchy we get an equation another formidable equation that now derivative with respect to first particle GN that gives you now separated again just like in BVGK hierarchy we separated out one particle with the others so if derivative with respect to one is now with respect to all other particles so this is the force coming from this is the force which is coming on one particle one from others now I just like in BVGK hierarchy I separate it out I separate it out that one particle thing from the higher particles so when I do that I find that nth one gets connected to n plus one it really makes sense to write down on this one that means G1 or row one then what you will find that KBT let me try to do that that KBT delta one row one R1 plus this term J equal to 2 to n so but I have one so I have now plus plus I have a delta one of G1 U1 is nothing but row one so this is row one then what I find that on the right hand side I have now on the right hand side I have del 1 U R1 U is the intermolecular interaction the total potential energy of the first particle so then I get terms which is dr2 drn and then I have G2 here and then del potential acting on the one particle this comes from all other particles so I have one tax particle here and I am looking at that distribution of probability of that particle here and but I need in order to get that I will see this earlier equation showed that I will be have G2 so this is in a nutshell a this equation for G1 and G1 is row one so row one depend on G2 G2 is the radial distribution function so this is the equation I have left out certain details but you understand that this is the way this is going to go so we are in a we are in a soup we are in a soup because so in order to find row one I need G2 you have to find G2 I need G3 very similar to what Benjamin found many years ago is better to get that perspective that is not even told much of the time that this is this is something exactly what Benjamin paid and he made an assumption which is very similar to what we are going to make now.


We're here with the elders bash team captain Stewie Chapman. Stewie back for the 25th anniversary bash. You guys absolutely love this thing, you've done exactly the same amount of bashes as me. What keeps you coming back mate? Just what we see when we're getting around the traps. All these people, all the kids that we give some money out to, raise some money, put it back in the community. Good for us because we're paying back to what we take from the community we put back in. Awesome. Absolutely. The crew this year, Stewie, I've noticed some changes and then some familiar critters from the past. I noticed you had a couple of newbies today. Oh yeah, well we had to trade a few in, they weren't playing ball, but I'm not sure about these guys either actually. They just need to get the ship together a bit better. They're actually just tame a bit, not doing enough bucket shaking. No, no. It's hard to get a good crusher. It is. Yeah, I mean we've worked on this for 15 years trying to put a good team together and we still haven't got a right. I noticed Mickey and Minnie in the back seat of your car before. Yeah, that Minnie, she's a sweetie, isn't she? Isn't she, eh? Oh man, she's all honey. And Tall, who would have thought? I know. Amazing. All the right dimensions. Stewie, Stewie, talk to us about the vehicle itself. What have we got here? Oh yeah, well it's a true bash car. It's been on more bashes than I have. It's a 64, fair lane, 500, 289 in it. Had a bit of work done on it. She goes real well. She's got all the gear inside. There's not much else she can put on it. Awesome to have you back for the 25th bash, mate. Thank you, Mark. It's only awesome to be here. And we'll be back for the 26th, eh? Back for the 26th. Absolutely. Two right, mate. It's probably a new team, but we'll be back for the 26th. Blood brothers. Yeah. I'm Mark, and that's the profile.


Outrage that the two people who, the two Republicans who refused to certify the election, they got an earful, and I'm just wondering, in the fallout from the local people when they report back to us either later tonight or tomorrow, how much of an influence did those act, those citizens, it was just regular everyday citizens, how much of an influence did they have on those two, um, electors there? Look, I love that all politics is local, and I think people should and must put pressure on the people they put in power. What if it hadn't been for those Michiganders and Detroiters who decided to yell at these people? It is all local, but imagine those local folks having the influence, they could have had a very big influence on a national election, on who was president of the United States, how history is going to look back on this, and I think a lot of people are going to be embarrassed over time when they look back and say, how did I do that, how did I fall for that, what happened to me, what was I thinking in that time? Unfreaking believable! You can guarantee that at no point during this scripted gaslighting segment did Don Levin ever at once consider for a millisecond that he could be talking about himself. This latest gaslighting segment from DNC TV focused on two Republicans, Monica Palmer and William Hartman, who had not voted to certify the election for Joe Biden due to voting irregularities that they wanted to see investigated. But as we all know, like I talk about on this channel all the time, the only legitimate voting irregularities would be those that are against the Democrats. And so we have to pretend like this election was perfection, it's like as long as Democrats winning, the all clear is given, there was no election fraud, there was no foreign interference, no no no, that's only if Republicans win. I mean damn, it's almost like somebody has been predicting that for the last few years. So Don Lemon and Chris Cuomo and the media at large in fact are spinning this story as a group of community citizens coming together to convince these two Republicans using American values and good arguments. To look the other way when it came to the voting irregularities and just confirm it for Biden. Which really leaves one wondering what convincing arguments to these community citizens come up with to convince these Republicans. And what that tells us is you, Miss Monica Palmer from Gross Point Woods, which has a history of racism, are deciding to enable and continue to perpetuate the racist history of this country. And I want you to think about what that means for your kids who probably go to Gross Point North. Who are a disgrace as it relates to the ability to have a free and impartial election in this nation. You have dishonored the legacy of veterans, the legacy of seniors. Just know when you try to sleep tonight that millions of people around the world now on Twitter know the name Monica Palmer and William Hartman as two people completely racist and without an understanding of what integrity means or a shred of human decency. That's right. Just get in a big hearty whiff of those American values. The time honored American tradition of threatening people's children and their livelihoods unless they vote the way you want them to.  I particularly love all these claims that not certifying the election, which still had plenty of voting irregularities that should be investigated, is tantamount to being against civil rights and being a racist because they say Trump is a racist. Meanwhile, back in reality, Trump achieved justice and prison reform unlike Barack Obama and Joe Biden. Trump funded black colleges for the foreseeable future. President Trump set a record in this election by attracting the highest percentage of non-white vote of any Republican presidential candidate in the last 60 years at 12% of black Americans. Based on these facts, if Trump is a racist, he's doing it wrong. Anyway, I want to get back to the clip where Don Lemon starts lecturing Trump supporters that if they don't fall into line, their grandchildren are going to hate them and they will be on the wrong side of history. How history is going to look back on this. And I think a lot of people are going to be embarrassed over time when they look back and say, how did I do that? How did I fall for that? What happened to me? What was I thinking in that time? You know, whatever it is, whatever they call it, liberal tears, you may want all of that. But your grandchildren and your kids will look back and say, ooh, what did grandpa did? What did dad do? What did mom do in this moment and realize that you were on the wrong side of history? I see these people as having no shame in their game. Yeah, well, you'll be surprised what happens to people as they get older and sadly when they're on their deathbeds. These guys were supposed to believe that they're on the right side of history. The guys who said that protests aren't supposed to be peaceful. The guys who promoted and inside it and Tifa extremists to attack ICE facilities. Well, I'll give them this. History is in fact written by the victor and they clearly see themselves as the victor. I can't deny it. They control all the flows of information and they're locking it down tighter on a daily basis. Look, it seems really bad right now, and it is, but we have to keep this fight up or we risk being snuffed out with no good ability to challenge this DNC establishment media complex. You can support me in this fight by using one of the links listed in the description or pinned comment. As always, thanks for watching, keep coming back.


Much has been talked about ethical standards, ethical principles. Now we are going to see that how can we resolve the ethical issues. Resolving ethical issues is a section which is broadly designed to guide psychologists to a variety of ethical issues. The first one is misuse of psychologist work. If psychologists learn of misuse or misinterpretation of their work, they also know that their work is being misinterpreted. Their research is being misused. They may take reasonable steps to correct and minimize the misuse and misinterpretation. As soon as it is identified that a researcher or a psychologist's work is misinterpreted or their work is being represented in a wrong way, it is very important to take action. A conflict between ethics, law, regulation and other governing legal authorities. In such a situation, where a conflict arises, between ethics, law, regulations and governing legal authorities. For instance, what can such a situation be? An individual, during the therapy, reported his self-harm impulse. He says that I have a very strong impulse to harm myself and I want to burn myself in this place. Now this is a situation where the right to keep the situation in confidence or to keep it in confidentiality or to break the protocol of consent is important. Rather than saying confidentiality and not reporting it, when he will burn himself, he will also be harmed. The people who are affiliated with him, his caregivers will also be harmed. The way he will burn himself, that place can also create a problem for people. And a nuisance can be created in the surroundings. So here, informing the law agencies and informing caregivers, informing the state will be a responsibility. Rather than it comes into the breaking the confidentiality rights. Conflict between ethics and organizational demand. In such conflict, if such conflict arises, where the psychologist should clarify the nature of the conflict, made known their commitment to ethical code and to the extent feasible, resolve the conflict in a way that permits adherence to ethical code. Like an organization's code, an APA's ethical code. You feel that they are conflicting over a certain standard. So there, in front of these ethical principles, a psychologist before working further will be sure to resolve them first. Let's say, if an individual is taking therapy in an organization and he is taking medication with him, in which side-effects, drowsiness is getting too much or he is having too many hunger-pangs or other symptoms, then the drowsiness may conflict with his organizational work. Let's say, if he works on a machine where a very vigilant worker has to work and because of that effect of medication, he is feeling drowsiness, then his work demand cannot be fulfilled. So there, a psychologist's job is to take in writing a written letter that you should provide in your institution that you are not capable enough to work with this machine for a certain period of time. And the organization should respect it rather than stigmatizing the other person that they should stigmatize him that you are unwell, you are unhealthy and you cannot work in our company. Until and unless we are going to break these barriers, psychological consultation that could not be improved. This scenario will only be seen when these ethical standards are to be fully utilized. Then reporting ethical violation. If an apparent ethical violation has substantially harmed or it's likely to be substantially harmed a person or organization, psychologists may take further actions like referral to the state or national committees or professional ethics or state licensing boards or to relevant institutional authorities. For instance, an individual is working on a workplace and he is telling in therapy that my workplace ethics is very bad. I take things from here and steal things. I misuse the machines here for my personal work. This has become my habit that I keep doing this and I can't control myself with therapy. Now, besides providing him therapy, it is very important for the person to inform the relevant people so that he can improve his conduct so that he can keep his procedures under control so that he can do minimum stealing so that he can do fabrication. So it's on both way because it's for the wellness of a person. His purpose is to improve. Now, this standard does not apply when an intervention would violate confidentiality rights and when psychologists have retained to review the work of other psychologists whose professional conduct is questionable. For instance, a researcher who published a lot of research on the data that is very unethical. So the other professionals who reviewed their work to resolve this ethical issue they decided that that person is falsifying the result. Similarly, if we were not questioning someone's professional competence then a reality would have been public. In such a situation, we will not call it violation, but we will call it raising the ethical standards. So this should be interpreted according to the situation given to us. Otherwise, if we are only looking at it in a specific limitation then maybe some ethical standards would not be able to understand their interpretation in such a way. The situation-based scenario-based or context-based explicit explanations are very helpful for understanding the ethical standards.


I have a new games console. This is it. It's a NES on a chip handheld gaming device. They are incredibly cheap and utterly ubiquitous. They're based around a re-implementation of the Nintendo Entertainment System as a single blob chip. They typically come with a million pirated NES ROMs and weird ROM hacks. They're actually pretty good for what they are. The NES implementation is decent. They play games pretty well. This has got a good battery, an excellent screen. The controls are kind of terrible. It does composite video out. It's actually a reasonable device for what you get, particularly for the price. But I'm not interested in that. I'm interested in this. This is the Player 2 gamepad, which plugs in the top. And certain games will allow you to use it as the second player. It'll allow you to have two people playing at once. And it does actually work. I am the top player in this one. The gamepad is vile and spongy and generally horrible in every possible way. But it does actually work. It connects via USB, except of course they put the wrong plug on the end. So let's get rid of these things. I'm not going to talk about it. And let's talk about this. Because I have a new Amiga. And Amigas need joysticks in order to play games. I have a joystick for mine, but I hate joysticks. I'd much rather use a gamepad. And here I have a cheap and nasty gamepad for a system which I never use. So let's try to turn this into an Amiga gamepad. So I'm just going to quickly take the back off and show you what's inside. So we take the lid off. And this reveals a single PCB with some contacts on it. A, well, let's get the right way up, OK? A conductive rubber mat, which has got pads here. When you press the button, it pushes the pad down onto the contact. So this goes roughly here. So pressing one of these things closes the switch. And here we have hard plastic pieces that the user actually presses. And this in turn presses the rubber mat. Now this is USB. So the USB cable is connected to the contact here via this, which is a blob. It's a chip on board. The silicon chip is bonded directly to the PCB and then covered in this black resin to protect it. It's the cheapest and nastiest way of getting a chip on a PCB. The Amiga uses a parallel system for its joysticks and mice. I've got here the Amiga mouse. And here is the connector for it, which is a completely standard 9-pin sub-D connector. These wires, if it were a joystick, four of the connections would be for the four D-pad directions up, down, left, and right. There's two for the buttons, button A and button B. You've got five volt and ground and a couple spare. So to turn this into an Amiga game pad, basically all we need to do is to disconnect the blob, connect five volt from the sub-D connector to the common side of all these switches, which is this big pad here, which you can see extends around to all the various sets of switches. Then we connect the other ends to the appropriate wires in the sub-D connector and profit. So let's give this a try. Now, in order to connect this to the Amiga, I do need something that will plug into the game port on the Amiga. Luckily, I've got here a 9-pin serial cable. This is just a simple straight-through cable. So one pin from here is connected directly to one pin from here. So it won't care that there's not been connected to serial. I can plug this end into the Amiga, and then I can plug this end into a 9-pin female connector, which I can mount on the side of the game pad. So this means that we don't actually need to solder up a cable, which is nice. We do need a way to get this mounted into the game pad itself, which will probably go here-ish. And we do need a way to wire up and modify this PCB. So what I'm going to do first is just do a little bit of mapping. However, I think that because this wire is being annoying, let us just quickly remove that. So I'm going to unsolder it. Come on, this is hot. I'm sure this cable will come in useful one of these years. So we can get rid of that completely. Because what I want to do is just make sure that all the switches are using the same common ground. So the continuity tester is working. So this obviously connects to here. Does it connect to one of these? No, it doesn't. It doesn't connect. It's a little bit weird, actually. That's not ground. This is ground. This is connected to here, here, here, here, here, here, here, and here. Now these two buttons, marked TA and TB, are a little bit different. They are turbo buttons. The NES only had two buttons, which is A and B. So TA and TB actually produce repeated presses suitable for shoot-em-ups. So they're wired up a bit differently. OK, so they are not connected to the common ground. That's fine. It'd be nice to turn this into another B button, to be honest. So we've got our common ground ends up here. That's a nice big pad. OK, I've used a sharp tool to scrape through the tracks here, which isolates the USB chip completely. It's still connected to its terminals here. But as they aren't going to be connected to anything, the chip should now be completely dead. We could, if we wanted, scrape it off the board. I now need to think about where to solder our wires on. The obvious place to do that are these test pads, because they don't have any solder masking, but they are underneath the rubber mat. Now we might be able to get away with it, given that the important part is the conductive bit here, which needs to press onto the middle of the interleaved tracks. But I would rather not. For cases like this one, as you see, the track actually runs here to the chip. So there isn't really any space other than over here. We could solder on a wire here, but it looks a little bit tricky. Let's just give that a try just to see what it's like. So we gently scrape off the solder mask like so. And then grab the soldering iron and just see if we can put a bit of solder onto it. Is it going to stick poorly? But it is sticking. OK, and let's put the meter back into continuity mode. Do we actually have electrical connection? Yes, we do. And how is that on the rubber mat? So our piece of solder is under there. I think that's OK actually. So let's grab some wire and see if I can get a piece of wire attached to that.  So let's try to tin the end. What would be great for this is magnet wire, but I don't have any. Magnet wire is solid core copper wire that's been coated with an insulating enamel which burns off when you apply solder. So it is both very thin and quite easy to work with because you can just solder a bit of it onto things and it just works. Yeah, that was no trouble. Right, so let's now try this piece. This is for the right pad. So again, we scrape off the solder mask. And in fact, while we're at it, I'll do the other. Pads to so this one is left. So you see it connects here. So this one is up and is rather thin. Here is ground or five volts. I need to go look up. What connection needs to be made, to be honest. And so we've done right. Down. Left. And up. OK. So let's go over this side. And we've got B and A. OK, now let's see if we can get solder on these. This one. OK, that does actually seem to be working. And here is not the right solder joint. It's a little bit of silver on the track. I think these two need a bit more work. I don't want to scrape too much or I will take the incredibly thin and cheap copper off completely. Yeah, I can just see it wicking down onto the track. So I think that's working. That's better. OK, so we've got some orange wire for that direction. Let's just have just going to cut some lengths of other colours. So you've got purple, red, white, yellow, green. So let's go with black as the common. So we tin the wire poorly at not my best joint, but it does seem to work. Let's do the connections, the directions, rather. That's good, giving the wires a bit of a tug just to make sure they are firmly attached. This one goes here. I think I may have slightly screwed this one up. No, that's fine. I just need to make sure that the wires don't end up running underneath the rubber mat. I do have a plan for getting rid of the rubber mat completely, but let's see if we can get this to work first. That is not sticking down. So we now have one more directional wire. I'll use another colour for that. OK, that's much better. So let's just route all these north and see what the map does when we put that back on. Yeah, no problem. OK, and now we have A and B. That was my multimeter turning itself off. Those all seem like decent joints. This last one. Oh, yeah, I need to tin it. Good. OK. So let's just reassemble things. This is the bottom, so let's put the. Let's go this way around. So the plastic buttons go into place. Then we put the rubber mat in. Then the PCB, just making sure that I have actually sort of wired up the right pads like so. The big bundle of wires can, for now, go out the hole. Don't think it matters which way up this goes on. It does, but this is the right way. OK, so this feels just as bad as it ever did, which is right. OK, so let's just bear a couple of these and do some testing. OK, so that should be hooked up to one of the buttons. That can lose.  I hate that. Yes, yes. Let's investigate Plan B. Plan B might be easy. It might not. OK. Give me a second. OK, so Plan B involves these. These are microswitches. I've got three different sizes. These are the big ones. These are going to be too big for this use case. So put these back in the bag and put them aside. But I've also got these, which are much smaller. This is the thinnest. It's a simple inverting fingermajig switch. I can't remember what they're called. Castanet switches. And but they are about a millimeter thick. But I've also got these, which are significantly more robust. These are about two millimeters thick. Now, my thought was that I can simply solder these across the contact pads like this so that now we either have the plastic button pieces. These push directly onto one of these switches. Or now I'm thinking we could leave the rubber mat and have the rubber mat push these. Yes, I think that is preferable. So is it across? Is it this way? I think it's this way. Yes, it is. So here we have the two interlaced sets of tracks. We want this to go in the middle. So if we we will fit very neatly in the middle, set diagonally so that it connects from here to here. OK, let's put this on. So we put a blob of solder here. I said a blob of solder here. The switch then sits diagonally. I think this is going to need tweezers. Like this. We want it to be in the middle, but with one pad sitting on top of that solder blob, like so, it keeps falling off. OK, that's not really the middle. Let's see if we can adjust that a little. We'll do so we now solder this side on like so and reassemble. So it's now nice and clicky. It's much more positive. So let's just try the continuity test again. So we want this one and this one. That feels great, actually. It's quite loud. If I lift it up a bit, it's still just as loud, but way more positive. Yep. OK, I like that. Let's do the others. So back with the probes. And let's do some testing. Good. OK, I'll do the rest in a bit. Just thinking about the A and B buttons. If I want to turn this into an A button, I need to connect from here to here. This is the signal for A. No, I want to turn this into a B button. So that's awkward, actually, because it's connected from the signal from A to something else. So I think that we need to cut. No, we can't cut here or disconnect A because that's connected up there. I don't think we can to easily turn this into an A button. So the way it's set up is A here and B here. I was wanting A here and another B here so that you can use it this way around, which is the way I'm used to for the N64 style layout. So I could cut to here. OK, that is no longer connected. So if we connect this to ground, that's this pad here, then this can become another B signal, which is here. So we want to connect a wire there and a wire there. OK, so let's open this up. This is our ground. So that's going to go over to here. OK. And we've got a handy pad here for B, which is going to go to here where there is also a handy pad. Right, let's get a few lengths of simple wire. We don't have to worry about the rubber mat anymore, of course. OK, so this solders on here and we want to cut it about there. OK, now we strip this end. That will go here. And this then needs to curve around. Let's put that here. Sorry, it keeps drifting on camera off camera like so. OK, so now if we take the probes and stick them here, that is across B and press this, either button works, fabulous. The other thing we could do is since this is ground is to stick a piece of wire from here to here that would make this into an A. Yeah, why not? Since we're here goes to there needs more solder to there. Right, and now if we test these probes, we should be able to press this one or this one. But these do something else. Excellent. I think that bit's done now. So let's reassemble that and see how it feels. Hey, what have we got? They're a bit spongy, recently clicky. That doesn't feel quite right. Let's just do the backup, which will make all the tensions even. It's possible that I haven't put them properly in the middle. That will cause problems as I'm relying on the rubber mat to the middle of the rubber mat, the hard, conductive bit to press the center of the switches. There's a little stud sticking up in the middle of each switch. OK, that's not very good, actually. The tension on each one is very different. Also, I am not convinced by the squishy rubber mat. So let me just try that with the mat removed completely. I think this is not going to work very well with the mat removed, but I'm going to give it a try anyway. OK, well, it's very rattling, as you might expect. The deep pad doesn't work at all. I think, actually, the PCB is not so it's designed inside to have the rubber mat in place. So I think the PCB is not being held tightly against the switches. So I've actually hold that in place myself. These buttons work, but these ones don't. Now, I know why, which is that these buttons have the round thing in the middle that pushes up against the the actual studs in the middle of each switch, but these don't. So this is supposed to go on like so in order to push the switches.  They do actually seem to be roughly in the middle. This switch here has a solder spur sticking out, which may be why it feels a little bit different. So let's just get rid of that better, I think. OK, let's just put the rubber mat back on. I think that is better than without it. It's an interesting experiment. One thing that might be worth doing is adding plastic pieces to the deep pad itself to push against the studs. That's quite feasible. I can either bodge it up or attempt to 3D print something. But I think this is electrically working. So let's just leave this for now. OK. So I think this is most of the game pad itself. The next stage is to wire it up to the Amiga. It's not quite as straightforward as I originally posited because you've got to push way too hard to make the deep pad work. It needs to be more sensitive. It needs a shim of some kind, also with these buttons. This button is much more sensitive than this one. These two are all right. Yeah, this is going to need some careful tuning and shimming. Yes, the Amiga.  Then this. All right, I've lost the sub nine connector. There it goes. So that will fit in in there. This will then plug into it. This end plugs into the Amiga. Unfortunately, the Amiga is rather cramped on space. This has these two wings with the screw terminals in it that fasten the connector into the socket. The Amiga doesn't have those. I'm going to have to chop them off to make this narrower. So that will be exciting. So I'm going to leave it for now and come back next time and try and do that.