COA CSE 2009 Module-2 Part-1
COA CSE 2009 Module-2 Part-1
CSE 2009
399
450
400
700
500 800
600
900
800
300
• OR
• To execute the add instruction in the figure(A) the processor uses the value B, which
is in the register R1, as the effective address of the operand. the value read is
desired operand, which the processor adds to the contents or register R0.
EA=X+[Ri]+[Rj]
this way is more useful in accessing multiple components
inside each item ( Ex: multi dimensional arrays)
Subtract #4,SP
Move NEWITEM,(SP)
These two instructions move the word from location NEWITEM onto the top of
the STACK decrementing the stack pointer before the move.
The POP operation can be implemented as
Move (SP), ITEM
Add #4,SP
These two instructions move the top value from the stack into the location
ITEM and then increment the stack pointer by 4 so that it points to the new
top element. The figure shows the effect of the each of these operations on
the stack.
• The stack pointer is loaded initially with the address value 2004.
recall that SP is decremented by 4 before new item pushed on the
stack. Hence an initial value of 2004 means that the first item
pushed onto the stack will be at location 2000.
RETURN Instruction:
• Later the subroutine returns other parameters, in this case the results of the
computation.
• The parameters may be placed in registers or in memory locations, where they can
be accessed by subroutine.
efficient.
• Figure shows how the program for adding a list of numbers can be
implemented as subroutine.