Sunteți pe pagina 1din 10

CSC 201 - Introduction to Computer Organization

Before looking at register operations, I'd like to point out some of the block
diagrams of registers that we'll be using.

In the above illustration, (a) is a typical register, we can name a register


using capital letters or capital letters followed by a number - some examples
of register names might be R, R1, R7, PC, AR, etc; (b) is another register
(name not shown) but instead it shows the 8 bits of the register; (c) is a 16
bit register named R2, in the upper corners are the numbers 15 and 0 used to
show that this is a 16 bit register; (d) is another 16 bit register named PC,
the (H) and (L) are used to indicate the "higher half" of the bits and "lower
half" of the bits - for example in a 16 bit register named PC, PC(L) refers to
bits 7 - 0 in the register while PC(H) refers to bits 15 - 8, in 8 bit register R,
R(L) would refer to bits 3 - 0.

Not shown in the above illustration is that we can refer to any group of bits
in a register, not only the upper or lower half. For example, in a 16 bit
register named R we could refer to the 8 bits exactly in the middle as
R(4-11).

1
CSC 201 - Introduction to Computer Organization

Microoperations

Microoperations are elementary operations performed on data stored in


registers or in memory. The microoperations most frequently encountered
are of the four types described below:
1. Transfer microoperations. This is an operation where data is
transfered from one register to another. Data may also be transfered
from a register to memory or from memory to a register.

2. Arithmetic microoperation. This is an operation that performs


arithmetic on data in one or two registers.

3. Logic microoperation. This operation performs bit manipulation on


data in one or two registers.

4. Shift microoperation. This operation shifts data in a register.

I will now discuss each of the above types of microoperations and give a
couple of examples. I'll also give listings of all the varieies of operations
that we'll be using under each of the types.

Register Transfer Microoperations

The most straight forward register transfer operation is probably moving


data from one register to another. For example move the data from register
R3 to register R1. This would be written as R1 ← R3. The arrow (←) is
used to show that the data from the right is moved to the register on the left.

In a digital system, depending on how registers are attached to eachother, it


is possible that more than one register transfer can happen simultaneously.
To show that we separate the register transfers by a comma, but keep them
on the same line. For example R1 ← R3, R2 ← R5 means that the contents
of R3 are tansfered to R1 and the contents of R5 are transfered to R2 at the
same time.

2
CSC 201 - Introduction to Computer Organization

Like in programmming, some register transfers may depend on certain


conditions being met. For example, we may want R1 ← R3 to happen only
if some Boolean variable K = 1. In a programming language this might be
written as "If (K = 1) then R1 ← R3". In register transfer language this is
written as K:R1 ← R3. Should we want the operation to occur when K = 0
instead of K = 1, we would write K':R1 ← R3.

Arithmetic Microoperations

Here we will define the basic arithmetic microoperations to be add, subtract,


increment, decrement, and complement. For example, if we want the
contents of registers R1 and R2 to be added and the result placed in register
R0, we'd write R0 ← R1 + R2. Keep in mind, the symbol "+" here refers to
the actual binary addition and this could be done using a binary ripple carry
adder/subtracter that we developed recently.

Of course, as in simple register transfer, more times than not, these


microoperations will depend on some condition being met. For example, we
may want R0 ← R1 + R2 to happen only if K = 1. In this case we'd write
K:R0 ← R1 + R2.

A listing of the arithmetic microoperations we will be using is shown below:

Note that there is no multiplication or division here. That is because it is


being assumed that multiplication and division can be done by using the
other microoperations we'll be looking at in this set of notes.

One more note, in a microoperation statement such as K:R0 ← R1 + R2, the


value to the left of ":" is always either a 1 or 0. Therefore in a statement

3
CSC 201 - Introduction to Computer Organization

such as K1 + K2:R0 ← R1 + R2, the "+" in K1 + K2 represents "OR" while


the "+" in R1 + R2 represents binary addition.

4
CSC 201 - Introduction to Computer Organization

Logic Microoperations

Logical microoperations are operations that do bitwise manipulation on the


contents of a register or registers using NOT, AND, OR or XOR. They are
especially useful for masking bits or a register (clearing, setting,
complementing) as I'll show in a minute. The logic microoperations we'll be
using here are shown in the following table:

Note, to prevent any misunderstandings here between binary addition and


logical AND/OR, we'll use ∧ for AND and ∨ for OR instead of the normal ⋅
and + we've been using.

Some examples are, suppose R1 and R2 are 8 bit registers. Suppose the
contents of R1 are 11011011 and we want to "clear" the leftmost 4 bits (that
is convert them to 0). To do this we could set R2 to equal 00001111, then
the operation R1 ←R1 ∧ R2 will convert R1 to 00001011 as desired.
Suppose that instead of changing the 4 leftmost digits of R1 to 0, we want to
set them to 1. To do this, let R2 = 11110000 then R1 ←R1 ∨ R2 will
convert R1 to 11111011. You can do similar masking with XOR ... simply
go through both involved registers bit by bit doing XOR on the two bits.

5
CSC 201 - Introduction to Computer Organization

Shift Microoperations

There are six shift microoperations shl that shifts the bits of a register one
place left and shr that shifts the bits of a register one place right; cil that
shifts the bits of a register one place left with the leftmost bit being circled
back to the right and cir that works similarly but to the right; ashl that shifts
all bits except the sign bit of a register to the left but not into the sign bit and
ashr that shifts all bits excluding the sign bit to the right.

Eight-bit examples
Symbolic After shift:
Type designation Source R2 Destination R1
shift left R1 ← shl R2 10011110 00111100
shift right R1 ← shr R2 10011110 01001111
circular shift left
R1 ← cil R2 10011110 00111101
circular shift right
R1 ← cir R2 10011110 01001111
arithmetic shift left
R1 ← ashl R2 10011110 10111100
arithmetic shift right
R1 ← ashr 10011110 10001111

6
CSC 201 - Introduction to Computer Organization

More complicated transfers

In addition to the simple transfer operations we have discussed up to now,


there are cases where we want something more complex. For example, we
may have the situation where we want to transfer the contents of R1 to R0
only if K1 = 1 and if K1 = 0 then transfer R2 to R0 but only if K2 = 1. In a
programming like language this would probably be written as
if (K1 = 1)
{
R0 ←R1;
}
else
{
if(K2 = 1)
{
R0 ← R2;
}
}

In register transfer language this would be K1:R0←R1, K '1 K 2 :R0←R2

The logic diagram that would premit something like this to happen might
looks like the following:

Notice that in the logic diagram on the previous page, data is loaded into
register RO only if K1 = 1 or K2 = 1. However, what is loaded into R0
depends on K1. If K1 = 1 then the multiplexer feeds R1 through to R0. But
if K1 = 0 then it is R2 that is let through to R0.

7
CSC 201 - Introduction to Computer Organization

In a typical digital system, we may have many registers. We will also want
it to be possible for the contents from any register to be transferred to any
other register. To do this, every register would need to have its own
dedicated multiplexer, for example

To see how this works, consider the following table :


Select Load
Register Transfer S2 S1 S0 L2 L1 L0
R0 ← R2 x x 0 0 0 1
R0 ← R1, R2 ← R1 1 x 1 1 0 1
R0 ← R1, R1 ← R0 x 0 1 0 0 1

This may be okay if the number of registers is not too large. But as we
develop systems with larger number of registers, the fact that each has to
have it's own dedicated multiplexer soon will show that this plan may not be
the best one.

A more efficient scheme is to have a bus. A bus can be thought of as a


shared transfer path that is made available to all of the registers. To get
information on the bus is the only place where a multiplexer has to be used.
This is efficient because we'll normally have fewer busses than registers.
hence, fewer multiplexers.

8
CSC 201 - Introduction to Computer Organization

An example of a digital system similar to the one discussed previously with


dedicated multiplexers is shown below:

The lines in red is the bus, since the data on it is accessible to all three
registers R0, R1 and R2.
To see how this works, consider the following table :
Select Load
Register Transfer S1 S0 L2 L1 L0
R0 ← R2 1 0 0 0 1
R0 ← R1, R2 ← R1 0 1 1 0 1
R0 ← R1, R1 ← R0 not possible

The last statement R0 ← R1, R1 ← R0 is not possible because there is no


way the values from R1 and R0 can be on the bus at the same time.

So, even though there may be some things we cannot do with a bus-based
transfer system and can do with a multiplexer-based transfer system, the bus-
based system is so much more efficient that this is the approach most
frequently used for many parts of a computer.

9
CSC 201 - Introduction to Computer Organization

Memory Transfer

For the purpose of this course, memory transfer will refer to either a transfer
of data from one word in memory to some register, or a transfer of data from
one register to some word in memory.

For example, if register AR contains the address of the word in memory that
we are interested in and DR is the register from which we will transfer data
to memory or the register that will receive the data from memory then the
following transfer statement
read:DR ←M[AR]
transfers the data from the memory word whose address is in AR to register
DR when read = 1. The statement
write:M[AR] ← DR
transfers the data from register DR to the memory word whose address is in
AR when write = 1.

On some digital systems there are two registers that are attached to memory.
They are the address register AR which will hold the address of the word in
memory that we want ot use, and the data register DR that will hold the data
that either will be written into memory or read from memory.

An alternative approach is to use an address bus and a data bus. This way
memory can be accessed by a variety of registers. You will not have to first
move the contents of R1, for example, to AR then use AR to access the
appropriate word in memory. Rather you can use R1 as the address register
for memory. Examples:
read:R3 ← M[R2]
transfers data from the memory word whose address is in R2 to register R3
when read = 1 and
write:M[R7] ← R0
transfers data from R0 to the memory word whose address is in R7.

10

S-ar putea să vă placă și