














Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!















Computer Architecture Prof. Anshul Kumar Department of Computer Science and Engineering Indian Institute of Technology, Delhi Lecture - 8 Architecture Examples
We began understanding instruction set architecture by taking an example of MIPS processor which is conceptually very simple. In the previous lecture, we tried to go beyond MIPS and saw in what directions architectural developments have taken place to bring in different variety of features. I also mentioned about RISC and CISC styles of architecture where in one case the emphasis is on simplicity and efficient implementation whereas in the other case the emphasis on providing powerful features for the programmer.
Today I will take some specific examples. It is quite time consuming to take any architecture and study in detail. But what we are going to do is just look at a few salient features, particularly those features which are different from what we have studied in case of MIPS.
(Refer Slide Time: 1:57)
Just to recall RISC or the reduced instruction set computers basically deal with instructions which are very simple and emphasis on uniformity of instructions. There are very few formats and all instructions are expressed in terms of those; the instruction size is generally the same. Each operation tries to do one simple thing at a time and there is no attempt to do many different tasks within same instruction. The architecture typically provides several registers and each instruction performing arithmetic typically takes three operands; two for sources and one for the destination.
Some of the examples of RISC style of architecture I mentioned are SUN’s SPARC, HP’s PA-RISC, Motorola’s power PC, DEC’s alpha and even one earlier machine of 1960s namely CDC 6600 followed that kind of style. So out of these we will look at some more details of SUN’s SPARC and also Motorola’s power PC.
(Refer Slide Time: 3:22)
On the other hand, there are numerous examples of CISC particularly machines of earlier times 70s and also some of 80s; some of the 70s machine which grew to later machines. VAX is the climax of such development where the attempt was to have very compact code; minimize the code size and make it very easy for assembly language programmer. The variation in instruction size could be as much as 1 to 54 bytes. Another example is of Motorola 680x0. Again there is a series of processors starting with 68000, 68010 and so on and Intel’s 80x86 starting with 80286 onwards and these machines have their origin where the idea originated from earlier 16-bit, 8-bit and 4-bit micro processors. So we will look at VAX and Intel 80x86.
(Refer Slide Time: 6:48)
So like MIPS they have 32 registers, apart from that there is a condition register. So condition register is essentially a register where different bits have different meaning and they are set or reset depending upon previous arithmetic or logical operations. In case of MIPS we have seen that there is an instruction slt which does comparison and the result is put in one of the general purpose registers. But in power PC and several other machines the result of instruction for example comparison or even arithmetic is put in special bits of a register or flags.
For example, when you are comparing one bit of the condition register would carry the information about the result whether A was less than B or not less than B or even if simply subtraction is done or addition is done whether the result was positive or negative or whether the result was zero or non-zero, whether the parity of the result was odd or even so there are lots of such conditions which are defined and they all combine together in a special register called condition register.
There are two other special registers which are worth mentioning one is the link register. So, unlike $ra which we have seen in MIPS there is a special register where link addresses are stored and this has a double purpose not only for procedural linkages it can also be used for loops. So for example, when you are beginning the loop, with the help of the instruction you can have that beginning of the loop address stored in this register and at the end of the loop you can simply use this information to jump back so you do not need to specify explicitly the address but you can simply refer to link register so it is also used to jump back to the beginning of the loop.
Then there is another register called count register which can be used to store iteration count for a loop. So there are special instructions which will allow this to be incremented decremented and tested so that facilitates execution of loop where the iterations are
driven by a count. So let us look at some of the instruction formats of power PC and also associated addressing modes.
(Refer Slide Time: 9:22)
So you would find again lot of similarity in the sense that there is a 6-bit opcode and 5-bit register fields. So, the first one which you see here is quite similar to the immediate addressing or base addressing which we see in MIPS, so it is exactly the same format. Again the base addressing is used for memory access and immediate addressing is used for arithmetic and logical operations to provide an operand. Then register addressing is slightly different in terms of format; the idea is same but the format is different.
Once again since the main opcode field is 6 bits you often need to extend this you need to have another few bits which will actually help you in expanding the number of instructions. So a group of instructions will have same opcode and they will be distinguished by opcode extension so that field is here and the size of this is…. you could see 16 minus 5 and minus 1 so this is a 10-bit field here.
Now in this you notice a 1-bit field R which actually controls whether the instruction is to make an effect on the condition bits or not. it is the same instruction, you can enable condition setting or you can disable condition setting by choosing one or zero in this particular bit. So what might happen is that you may set condition by some instruction and you may not be requiring to test it immediately there may be a few other instructions and then you may test it later. So what you would like is the instructions which are in between should not change the value of the condition codes. Therefore you need a control where you can precisely allow or disallow an instruction to modify the condition bits.
There is an additional mode which is used for accessing memory called indexed addressing. You would recall that I mentioned in context of MIPS that base addressing and index addressing could only be a matter of different interpretation. Basically you
So basically transfer of control can be made to a subroutine by any of the branch instructions unconditional as well as conditional by setting this bit to one. So, as you have seen the difference between j and jal the only difference is that the return address gets saved in a specific register. Now, this facility is available with any of the branch instructions. For example, even with beq so you may make a call to a procedure if two values are equal or unequal. You may actually check a condition and make a call to a procedure. So this is indirect jump (Refer Slide Time: 15:36) if for example we had jr there so here you make a control transfer based on the contents of link register and count register. So count actually also..apart from having count in some context it can also be used as address. Here are a few examples which will show how some of these instructions will shorten the code which you write.
(Refer Slide Time: 15:58)
So, on the left side you see sequence of instructions in MIPS and on the right side corresponding instruction in power PC. In MIPS, for example, we often require address to be computed by adding two registers and then we use that in lw. So here we are typically we are wasting this constant field we do not use this in any case because the lw instruction does not have a mode where two registers can be added but with this index mode you can have a base and an index both added by the instruction itself.
Then next is the example of update. Here, for example, in MIPS you will say that you are accessing memory with s3, offset is 4, result is brought to t0 and then you update s3 by 4 possibily for the next iteration. But here with lwu which is update version…. there is lw and lwu means lw with update so this I am sorry this is $s3 (Refer Slide Time:: 17:30) so s3 is being used with this offset and that offset also updates it so next time s3 will be four more than what we have in this.
Here is an example of using a counter. In MIPS you will have a counter maintained in a register let us say t0 which you update and you are checking, for example you could start
with a negative value and you could increment till it becomes zero. You are testing it and if it is not zero you go to beginning of the loop. In power PC there could be a single instruction which has branch on count to loop and the condition being checked is whether the count is not equal to 0. So, again lot of conditions could be specified here but this instruction in particular is saying that branching is to be done when counter is not 0.
(Refer Slide Time: 18:46)
The next example of RISC I am taking is SPARC architecture. The term SPARC stands for scalable processor architecture and scalability here means that the same instruction set could be implemented in different ways with different technologies and the architecture would scale. So with same instruction set you could get different performances, also, scale to a higher word size. In fact this architecture also has been scaled to 64 bits and this is an open architecture which is implemented by several companies; Sun was the main one, then Texas instruments, Toshiba, Fujitsu, Cypress, Tatung etc. This has again a limited number of instruction formats but certainly more than what we have seen in MIPS.
(Refer Slide Time: 22:09)
The most interesting feature which was brought out by SPARC architecture was the concept of register windows. what they have is there is a large number of registers which could be as much as 128 to 256 or even more; in different implementations actually the size differs but a program sees only 32 registers at a time so to say it has a window of 32 registers at any time which can move up or down as you go from one context to other context.
We have seen that in MIPS when a procedure call is made you have to worry a lot about what register is used by caller, what register is used by callee so somehow you have to share the registers. If you have a larger requirement then you need to do lot of transfers to memory, save them and restore them. So it is this problem which is addressed by register windows that when you make a call to a procedure or function you get a fresh set of registers so that the caller and the callee can work independently on their own set of registers. But this is another extreme; you also want some linkages some flow of data between caller and callee in terms of parameters. So therefore the two windows are not totally disjoint they are overlapping and overlap is in a very regular fashion.
For example, suppose you are in the main program you will see total of 32 registers and these are divided into four parts: input, local, output, global. So as the windows change the global registers eight of them remain unchanged so you see same eight registers which are let us say out of array of 256 registers and the first eight are always part of the window and local are those which are totally exclusive to a given context whereas in and out are overlapping. So when, for example, from this context you make a call to another function then the set of eight registers which was out here become in for that. Essentially this is a way you pass parameters.
Whatever information up to eight values which you want to pass on you can load into these eight registers and then when you make a call the window slides, you get these 24
registers, the global remains the same and what was out has not become in because these are the registers which have carried information into it and what appears as out will become in for the next level. So out of these 24 registers 8 are used for getting information….. 8 are purely local, 8 are used for getting information out to the next level. Of course this is the convention. Once you have got some values in registers you can use them for local usage also. So at any given time you have these 24 or some other 24 registers and 8 global registers.
Now, to keep track of current window you need a current window pointer or CWP. Suppose CWP or the window pointer is pointing to this window next it will point to that window, when return occurs it gets back to the same thing. so suppose you have 128 or 256 whatever be the number there is a finite set of windows which are possible and if depth of calls become more than that then actually windows act like, I mean, this set of registers acts like a cyclic buffer. So you can keep on going deeper and the window keeps on sliding but of course as it loops back the old window the first one will have to be saved in memory otherwise it will be overwritten. So that saving and restoring has to be done but when you go to a depth of let us say 8 or so then you will have to worry about saving or restoring.
For most practical purposes the depth would typically not be more than 4, 5 or 6 and often these windows suffices so it is only in rare cases that you need to spend time and effort in saving and restoring the windows. Otherwise call to a procedure is speeded up by this facility.
(Refer Slide Time: 27:11)
Next we take example of VAX architecture which was developed by DEC or Digital Equipment Corporation in 1977. This was a successor of PDP-11 a minicomputer which was let us see the most successful minicomputer and all the PDP-11 was 16-bit machine
(Refer Slide Time: 27:11)
The data types varying from 8 to 128, it could deal with character strings where 1 byte represent a character or string of decimal digits one digit coded in 4 bits; there are lots of addressing modes, there are 6-bit constants, 8-bit constants, 16-bit constants, 32-bit constants, they are register addressing mode that means register carries the operand or you would find the term deferred with many of the addressing modes. Deferred refers to some kind of indirection. That means what you are getting is only an address and then you take that address and make access to memory to get the operand. So register mode means that register carries the operand; register deferred means register carries the address and you carry on one memory access cycle.
Displacement: Displacement with respect to registers and one of the register is as you know is PC, one is SP. PC relative and register relative are not two different modes, you could have 8, 16, 32 bit displacement with respect to any of the registers and its deferred version. That means register plus a constant can give you an operand it can also give you an address. So indexing is there, indexing with scaling that means the index which is getting added can be multiplied by 1, 2 or 4 depending upon operand size; autoincrement autodecrement with deferred so all these addressing modes are available;
(Refer Slide Time: 27:11)
You could see peculiar things like operations which work on polynomials directly or operations which do insertion in queue. So here is an example of instruction. For example, addl3; 3 refers to three operands here. Well, when I say operand it actually means we are also counting the destination and this l stands for the datatype so l implies 32-bit long integer, integer here means 16 actually so 32-bit they call as long integer and the three addresses are R1which is a register addressing mode, this is a….. you could say a base addressing and this is immediate addressing so each of these could appear in any mode.
(Refer Slide Time: 33:28)
the other gives the starting address so you could add long you could take a long numbers and not necessarily can find two 32 bits or 64 bits there could be long strings of digits and single instruction could add these.
(Refer Slide Time: 37:28)
Finally let us talk of Intel x86 which has a very very long history beginning with 4-bit, 8- bit, 16-bit, 32-bit. Of course there were major breaks 4 to 8 and 8 to 16 but starting with 16-bit processor 8086 which was introduced in 78 there has been a reasonable amount of compatibility which has been maintained. So 8086 was announced in 78 which was essentially 16-bit architecture then few years later its companion floating point processor coprocessor was added, in 1982 80286 was introduced which increased the address space to 24 bits, earlier it was 16 bits.
With 16 bits you have addressability of only 64 kilobytes, as the demand increased the space had to be increased. With 24 bits you get sixteen mega bytes and also some instructions are added. With 80386 this series has got 32-bit architecture and more newer addressing modes were defined and also paging in terms of virtual memory was introduced here. Then, after that we have 80486 Pentium, Pentium pro, Pentium 2, 3, 4 so the whole series and the emphasis has been on adding more instructions; all the compatibility is maintained but more instructions have been added for higher performance. MMX, for example, multimedia extension then there are SIMD instructions for again performing operations on arrays so all those additions have taken place but the core instruction set has remained. So let us have a look at that part but before that I would like you to read some interesting comments. These are from our textbook.
(Refer Slide Time: 39:48)
The history illustrates the impact of the golden handcuffs of compatibility. What it means is that to maintain compatibility the architecture has got tied up and you are sort of constrained; you can keep on adding features but you need to maintain what is there so that baggage has to be carried and adding new features is something like adding clothing to a packed bag. It is an architecture that is difficult to explain and impossible to love. It is a very complex architecture; it is very difficult for a programmer to be sure that, yes, out of these instructions I am using the right ones; I am using them in the best possible manner. Even for a compiler it may be very difficult to make best use of all possible instructions and all possible variations which are there with the instruction.
But on the other hand, what this lacks in style is made up in quantity. So, because of compatibility it has been a commercial success which means it is widely used and available in large quantities.
(Refer Slide Time 43:21)
On the other hand, there is a saving grace that the most frequently used instructions are not too difficult to build and compilers have learned to avoid the portions of architecture that is not very efficient so the compilers also focus on a small subset of all the instructions and those instructions can be built efficiently.
(Refer Slide Time: 43:48)
So here is a glimpse of register structure not all registers but I am showing all the major 32-bit registers of 8086. So they have a name like EAX, EBX, ECX, EDX this is one set where E and X are both there. Actually E stands for extension extended A register so actually extension has taken place in two stages so there were 8-bit architectures with
registers called A B C D and so on and then migrated to 16-bit architecture where you had AH AL BH BL where H stands for high and L stands for low and then they were extended further to get 32-bit registers. So still old names can be used so although EAX, EBX, ECX, EDX when you write in assembly they refer to 32-bit registers. You can also use AX BX CX DX that means you can work with half of the registers that means take data from half of it put the result in half of it that is possible and you can also work with quarters and refer to them as AH AL BH BL and so on.
Then there is another set of registers which in earlier versions are called BP SP SI DI or here called as EBP ESP EDI where E again stands for extended. BP is base pointer, SP is Stack Pointer, SI is Source Index DI is Destination Index. So, base pointer, stack pointer have their usual meaning; SI and DI are referred to operations which work on string so there is a source string and destination string and SI and DI would typically be used for indexing individual element in those strings.
The other registers particularly they are 16-bit segment registers which are labeled as CS SS DS and others. CS stands for code segment, stack segment, data segment and so on. So D E F G is all actually for data.
(Refer Slide Time: 46:04)
Therefore, segmentation was a technique which is brought into earlier versions of this architecture to address larger memory than what can be done with a 16-bit address register. So 16-bit register is limited to 64 k bytes but how do you access larger memory is with the help of a segment register. In a segment register you set up a base and starting from that base you can access 64 k bytes of memory. You want to address another area you can move your base and then address 64 k bytes there. So although these segment registers are also 16 bits but they are used with some multiplication factor.