CO - Chap 1
CO - Chap 1
3. How to prevent high speed processor from being locked to a slow input/output
device during data transfer? (6M)
4. What are the factors used to judge the performance of a computer? Explain any
3 of them.(10M)
PROCESSOR CLOCK
• The processor circuits are controlled by timing signals called as Clock.
• It defines constant time intervals and are called as Clock Cycles.
• To execute one instruction there are 3 basic steps namely (fetch, decode and
execute).
• The performance of the processor depends on the length of the clock cycle. To
obtain high performance reduce the length of the clock cycle. Let ‘ P ’ be the
number of clock cycles generated by the Processor and ‘ R ‘ be the Clock rate .
• The Clock rate is inversely proportional to the number of clock cycles.i.e R =
1/P.
If the SPEC rating = 50 Means that the computer under test is 50 times as fast as
the ultra sparc 10
• The SPEC repeated for all the programs in the SPEC suit, and the geometric
mean of the result is computed.
• Let SPECi be the rating for program ‘i’ in the suite. The overall SPEC rating for
the computer is given by
➢ 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.
➢ The second Add instruction adds 4 to the contents of the pointer R2, so that it will
contain the address value NUM2 when the above instruction is executed in the second
pass through the loop.
INDEXING AND ARRAYS
✓ A different kind of flexibility for accessing operands is useful in dealing with lists and
arrays.
Index mode
✓ The operation is indicated as X(Ri) where X=the constant value contained in the
instruction Ri=the name of the index register
✓ The effective-address of the operand is given by EA=X+[Ri].
✓ The contents of the index-register are not changed in the process of generating the
effective address.
✓ In an assembly language program, the constant X may be given either → as an
explicit number or
→ as a symbolic-name representing a numerical value.
✓ Fig(a) illustrates two ways of using the Index mode. In fig(a), the index register, R1,
contains the address of a memory location, and the value X defines an offset(also
called a displacement) from this address to the location where the operand is found.
✓ An alternative use is illustrated in fig(b). Here, the constant X corresponds to a
memory address, and the contents of the index register define the offset to the
operand. In either case, the effective address is the sum of two values; one is given
explicitly in the instruction, and the other is stored in a register.
11. What are Assembler Directives? Point out and explain the various directives
with example.
12. Write an Assembly program that reads a line of characters and display it.
13. Explain Basic I/O Operations performed by the processor, with the help of neat
diagram.
14. Explain Memory Mapped I/O and Program Controlled I/O Operation?
15. Explain Stack and Queue? Differentiate between them? Write the line of code to
implement the same.
16. Define Subroutine and Subroutine Linkage? Explain Subroutine Linkage using
Link Register.
A subtask consisting of a set of instructions which is executed many times is called a
subroutine.
The program branches to a subroutine with a Call instruction (Figure: 2.24).
Once the subroutine is executed, the calling-program must resume execution starting
from the instruction immediately following the Call instructions i.e. control is to be
transferred back to the calling-program. This is done by executing a Return instruction at
the end of the subroutine.
The way in which a computer makes it possible to call and return from subroutines is
referred to as its subroutine linkage method.
The Call instruction is a special branch instruction that performs the following
operations:
→ Store the contents of PC into link-register.
17. The Return instruction is a special branch instruction that performs the operation:
→ Branch to the address contained in the link-register.
• Hence, it is essential to save the contents of the link-register in some other location before
calling another subroutine. Otherwise, the return-address of the first subroutine will be lost.
• Subroutine nesting can be carried out to any depth. Eventually, the last subroutine called
completes its computations and returns to the subroutine that called it.
• The return-address needed for this first return is the last one generated in the nested call
sequence. That is, return-addresses are generated and used in a LIFO order.
• This suggests that the return-addresses associated with subroutine calls should be pushed
onto a stack. A particular register is designated as the SP(Stack Pointer) to be used in this
operation.
• Call instruction pushes the contents of the PC onto the processor-stack. Return instruction
pops the return-address from the processor-stack into the PC.
20. Explain the concept of Stack Frames, when subroutines are nested.
• Stack frame refers to locations that constitute a private work-space for the subroutine
(Figure:2.26).
•The work-space is
→ created at the time the subroutine is entered &
→ freed up when the subroutine returns control to the calling-program.
• Following is a program for adding a list of numbers using subroutine with the parameters
passed to stack.
• Fig: 2.27 show an example of a commonly used layout for information in a stack-frame.
•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.
Operation on Stack Frame
• Initially SP is pointing to the address of old TOS.
• Now, FP is to be initialized and its old contents have to be stored. Hence, the first 2
instructions in the subroutine are:
Move
FP,-
(SP)
Move
SP,FP
• The FP is initialized to the value of SP i.e. both FP and SP point to the saved FP address.
•The 3 local variables may now be pushed onto the stack. Space for local variables is
allocated by executing the instruction
Subtract #12,SP
• Finally, the contents of processor-registers R0 and R1 are saved in the stack. At this point,
the stackframe has been set up as shown in the fig 2.27.
•The subroutine now executes its task. When the task is completed, the subroutine pops the
saved values of R1 and R0 back into those registers, removes the local variables from the
stack frame by executing the instruction.
Add #12,SP
• And subroutine pops saved old value of FP back into FP. At this point, SP points to return-
address, so the Return instruction can be executed, transferring control back to the calling
program.
21.
22. What is the need of Processor Stack? Explain a commonly used layout for
information in a subroutine stack frame.
23. Interpret the Subroutine Stack frame with example.
24. How Parameters are passed to subroutine?
25. What is Stack Frame? Explain Subroutine stack frame.
26. Explain the use of Stack Frame in the implementation of Nesting of Subroutine?
27. Stack is very useful data structure for holding return-addresses when subroutines are
nested.
28. When nested subroutines are used; the stack-frames are built up in the processor-
stack.
29. Consider the following program to illustrate stack frames for nested subroutines (refer
fig no. 2.28 from text book).
34. SUB1 then continues its computations & eventually passes required answer back to
main-program on the stack.
When SUB1 executes return statement, the main-program stores this answers in memory-
location RESULT and continues its execution.
35. Point out various Shifts and Rotate Instruction and example, with a neat
diagram.
36. Explain Shift, Rotate and Logical operation with an example?
37. How to Encode Assembly Instructions into 32-bit words? Explain with
examples.
38. With relevant examples briefly explain about any 2 Encoding types of Machine
Instruction.
39. With the help of suitable example, illustrate Encoding of Machine Instructions
40. What is the effective address of the source operand in each of the following
instruction.
When the Register R1 and R2 of computer contain the decimal value 1200 and
41. Write a program to add N numbers using indirect addressing mode and auto
increment mode?
42. Write a routine to compare whether the most significant char is Z or not.
43. Write a routine to pack 2 BCD digits and explain with an example.