Unit-2 Machine Instructions and Programs (Contd... ) and Basic Processing Unit
Unit-2 Machine Instructions and Programs (Contd... ) and Basic Processing Unit
Program Explanation
• In above program, Register R2 is used as a pointer to the numbers in the list, and the operands are accessed
indirectly through R2.The initialization-section of the program loads the counter-value n from memory-location N into
R1 and uses the immediate addressing-mode to place the address value NUM1, which is the address of the first number
in the list, into R2. Then it clears R0 to 0.
• The first two instructions in the loop implement the unspecified instruction block starting at LOOP.
• The first time through the loop, the instruction Add (R2), R0 fetches the operand at location NUM1 and adds it to R0.
Figure.2.3 A List of Student Marks Figure 2.4 index addressing used in accessing the test score
Two dimensional array having n rows and four Colum’s. Each row contains entries for one student and Colum’s gives
ID and test score. To compute the sum of all scores obtained on each of the tests and store these three sums in memory
location Sum1,Sum2 and Sum3.Register R0 is used as the index register. Before entering loop Ro is set to point to the
ID location of the first student record. It contains the address list.
Figure2.9 Checking for empty and full error in pop and push operation
Figure 2.11 Adding a list of numbers using subroutine with the parameters passed through registers.
STACK FRAME
• Stack Frame refers to locations that constitute a private work-space for the subroutine. The work-space is created at
the time the subroutine is entered & freed up when the subroutine returns control to the calling-program (Figure: 2.12).
Frame Pointer (FP) is used to access the parameters passed to the subroutine & to the local memory-variables.
• The contents of FP remains fixed throughout the execution of the subroutine, unlike stack-pointer SP, which must
always point to the current top element in the stack.
Ri
Riout
Yin
Y
Constant 4
Select MUX
A B
AL
Zin
Z
Z out
Bus
Fig.2.20 Control sequence for the instruction Add R4,R5,R6 for three bus organization
Fig.2.22 separation of the decoding and encoding function Fig.2.23 Generation of the Zin control signal for the processor
Microprogrammed control
• Microprogramming is a method of control unit design (Figure 2.24).
.
Fig2.26 Microroutine for the instruction Branch<0
• In case of conditional branching, microinstructions specify which of the external inputs, condition codes should be checked as a
condition for branching to take place.
• Starting and Branch Address Generator Block loads a new address into μPC when a microinstruction instructs it to do so (Figure
2.27).
• To allow implementation of a conditional branch, inputs to this block consist of
→ external inputs and condition-codes &
→ contents of IR.
• μPC is incremented every time a new microinstruction is fetched from microprogram memory except in following situations:
1) When a new instruction is loaded into IR, μPC is loaded with starting-address of microroutine for that instruction.
2) When a Branch microinstruction is encountered and branch condition is satisfied, μPC is loaded with branch-address.
3) When an End microinstruction is encountered, μPC is loaded with address of first CW in microroutine for instruction fetch cycle.
3.Write the sequence of control steps required for the single bus organization in each of the following
instructions:
a) Add the immediate number NUM to register R1.
b) Add the contents of memory-location NUM to register R1.
c) Add the contents of the memory-location whose address is at memory-location NUM to register R1.Assume that each instruction
consists of two words. The first word specifies the operation and N the addressing mode, and the second word contains the number
NUM
Sol:
4. Show the control steps for the Branch on Negative instruction for a processor with three-bus organization of the data path
Sol: