i) Name a special register within a CPU that contains the address of the next in
ID: 3705037 • Letter: I
Question
i) Name a special register within a CPU that contains the address of the next instruction to be executed. Explain how the register is updated normally (i.e., to execute the next instruction in sequence). Name one type of instructions which can change the content of that register explicitly, other than by the normal way 2a ii) Explain what the "Call" and "Return" instructions do for initiating and ending the execution of a procedure (function) call, respectively. In your explanation, name the register and memory segment that are typically involved in executing the instructions. iii) Following part ii) above, what should an assembly programmer do to ensure that after the execution of the called procedure, the program execution resumes with the CPU state identical to that immediately before the procedure call? iv) What are two main differences between a procedure (function) call and a hardware interrupt?Explanation / Answer
i) PC - PC stands for Program Counter is a register which holds the location of the next instruction to be executed from memory.
Register updation : This register is automatically incremented to the next instruction when the current instruction is being executed.
Data copy instruction or data transfer instruction can be used to change the content of register explicitly.
Eg: ADD, SUB,MOV...
ii) Call instruction: This instruction interrupts the flow of a program by passing the control to a subroutine. CALL passes the control to a program name that is written after the CALL keyword. The processing state information is saved when a CALL is made and this information is restored when the function returns back to the calling function.
The processing state info is:
pending control structures, command address settings(current and saved locations), pending condition handler information, elapsed time clock, trace options, return address, etc.,.
All the above information is stored in stack.
Return instruction: This instruction returns the control from the subroutine back to the calling program with/without a value.
iii) The programmer need not take any extra care for saving/storing the state of process before calling any function as the processor stores all the neccessary information so that it knows where it should start over again to continue the process after the subroutine returns.
iv) An interrupt is generated by hardware where as a function call is program generated.
The function call or subroutines are programmed by the programmer where as the interrupts are physically programmed or designed inside the hardware for sake for other hardware.
We can know when a function call happens and also why but this is not the same case with interrupts as they can occur at any time.
For interrupt,, the return instruction is RETI where as it is RET for function call. RETI clears the source of interrupt.
Function call can have a return value but an interrupt cannot have any return value.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.