Unit - 2 (Half Notes)
Unit - 2 (Half Notes)
CONTROL WORD
• There are 14 binary selection inputs in the unit, and their combined value
specifies control word.
• It consists of four fields:
01010 OR A and B OR
Micro-
SEL SE SEL OP Control Word
operati
A LB D R
on
R1 ← 0 0 0 001
SU
R2 – R2 R3 R1 1 1 0 01
B
R3 0 1 1
R4 ← 1 1 1 010
R4 ∨ R4 R5 R4 OR 0 0 0 10
R5 0 1 0
R6 ← 1 0 1 000
INC
R6 + - R6 R1 1 0 1 01
A
R1 0 0 0
0 0 1 000
R7 ← TSF
R1 - R7 0 0 1 00
R1 A
1 0 1
0 0 0 000
Output No TSF
R2 – 1 0 0 00
← R2 ne A
0 0 0
Output 0 0 0 000
Inp No TSF
← - 0 0 0 00
ut ne A
Input 0 0 0
1 0 1 110
R4 ← SH
R4 - R4 0 0 0 00
shl R4 LA
0 0 0
1 1 1 011
XO
R5 ← 0 R5 R5 R5 0 0 0 00
R
1 1 1
REGISTER STACK
3
SP C
2
B
1
A
0
DR
❖ In a 64-word stack, the stack pointer contains 6 bit because 2^6 = 64.
❖ Since SP has only 6 bits.
❖ When 63 is incremented by 1, the result is 0 since 111111+1= 1000000 in
binary, but SP can accommodate only the six least significant bits.
❖ Similarly, when 000000 is decremented by 1, the result is 111111.
❖ The one bit register FULL is set to 1 when the stack is full, the one bit register
EMPTY set to 1 when the stack is empty of items.
❖ DR is the data register that holds the binary data to be written into or read
out of the stack.
❖ Insertion of element
SP<- SP+1
M[SP] <- DR Write item on top of the stack
If (SP=0) then (FULL <- 1) Check if stack is full
EMPTY <- 0 Mark the stack not empty
Deletion of element
SP<- SP-1
M[SP] -> DR Write item on top of the stack
If (SP=0) then (EMPTY <- 1) Check if stack is full
FULL <- 0 Mark the stack not empty
MEMORY STACK
❖ A stack can exist as a stand-alone.
❖ Stack can be implemented in a random-access memory (RAM) attached to a
CPU.
❖ The implementation of a stack in the CPU is done by assigning a portion of
memory to a stack operation and using a processor register as a stack
pointer.
❖ A portion of computer memory divided into three segments: program, data
and stack.
❖ The program counter PC points at the address of the next instruction in the
program.
❖ The address register (AR) points at an array of data.
❖ The stack pointer SP points at the top of the stack.
❖ The three register are connected to a common address bus, and either one
can provide an address for memory.
❖ PC is used during the phase to read an instruction.
❖ AR is used during the execute phase to read operand.
❖ SP is used to push or pop items into or from the stack.
Stack Pointer is first going to point at the address 3001, and then the stack
will grow with the decreasing addresses. It means that the first item is going
to be stored at address 3001, the second item at address 3000, and the items
can keep getting stored in the stack until it reaches the last address 2000
where the last item will be held.
Here the data which is getting inserted into the Stack is obtained from
the Data Register and the data retrieved from the Stack is also read by the
Data Register.
Example :
The items in the stack communicate with a data register. A new item is
inserted with the push operation as follows:
PUSH:
SP <-SP – 1
M[SP] <- DR
The stack pointer is decremented so that it points at the address of the
next word. A memory write operation inserts the word from DR into the
top of the stack. A new item is deleted with a pop operation as follows:
POP:
DR <- M[SP]
SP <- SP + 1
INFIX TO POSTFIX
+ – ! ~ ++ —
2 Unary (type)* & Right to Left
size of
= += -+ *= /=
14 Assignment %= >>= <<= Right to Left
&= ^= |=
RULES:
• Priority - ^, */, +-
• No two operators of the same priority can stay together in stack column
• Lowest priority cannot be placed before highest priority.
A*B+C*D infix to postfix
PUSH A TOP = A
PUSH B TOP = B
PUSH C TOP = C
PUSH D TOP = D
LOAD A AC = M[A]
ADD B AC = AC + M[B]
STORE T M[T] = AC
LOAD C AC = M[C]
ADD D AC = AC + M[D]
MUL T AC = AC * M[T]
STORE X M[X] = AC
3. Two(2) Address Instruction format
• The instruction format in which the instruction uses only two address fields
is called the two address instruction format
• This type of instruction format is the most commonly used instruction format
• As in one address instruction format, the result is stored in the accumulator
only, but in two addresses instruction format the result can be stored in
different locations
• This type of instruction format has two operands
• It requires shorter assembly language instructions
• Assembly language instruction – MOV R1, A; ADD R1, B etc.
Expression: X = (A+B)*(C+D)
R1, R2 are registers
M[] is any memory location
MUL R1, R2 R1 = R1 * R2
MOV X, R1 M[X] = R1
4. Three(3) Address Instruction format
• The instruction format in which the instruction uses the three address fields
is called the three address instruction format
• It has three operands
• It requires shorter assembly language instructions
• It requires more bits.
• Assembly language instruction – ADD R1, A, B etc.
Expression: X = (A+B)*(C+D)
R1, R2 are registers
M[] is any memory location