Question

In: Computer Science

Describe the major steps for a CPU to execute a procedure call. Specify when BL and...

Describe the major steps for a CPU to execute a procedure call. Specify when BL and BR instructions will be executed, respectively.

Explain how inline function can improve the software performance, and when it should be used.

Solutions

Expert Solution

Ans:-

Below six steps are involved in execution of a procedure call in CPU.

1. Fetch instruction
2. Decode information
3.Perform ALU operation
4. Access memory
5. Update register file
6. Update the Program Counter (PC)

Fetch instruction: Execution first starts with fetching instruction from main memory. The instruction at the current program counter (PC) will be fetched and will be stored in instruction register (IR).

Decode instruction: In this step, the encoded instruction present in the IR (instruction register) is interpreted by the decoder.

Perform ALU Operation: Arithmetic Logic Unit (ALU) is where two operands in the instruction will be operated on given operator in the instructions. Such as, if the instruction was to add two numbers, then here the addition will happen. ALU take two values and output one, the result of the operation.

Access memory: There are two kinds of instructions that access memory: LOAD and STORE. LOAD copies a value from memory to a register and STORE copies a register value to memory. Any other instruction skips this step.

Update Register File: In this step, the output/result of the ALU is written back to the register file to update the register file. The result could also be due to a LOAD from memory. Some instructions don't have results to store. For example, BRANCH and JUMP instructions do not have any results to store.

Update the PC (Program Counter): Finally, at the end of the execution of the current instruction, we need to update the program counter (PC) to the address of the next instruction, so that we can go back to step 1 where the CPU will fetch instruction. However, the program counter might need to be set to other memory address than the next one if the instruction was BRANCH or JUMP.

BR instruction

A branch instruction (BR) is an instruction in a CPU that may cause a computer to start executing a different instruction sequence and thus deviate from its default behaviour of executing instructions in order. Branch may also refer to the act of switching execution to a different instruction sequence as a result of executing a branch instruction. Branch instructions are used to implement control flow in program loops and conditionals (i.e., executing a particular sequence of instructions only if certain conditions are satisfied). Mechanically, a branch instruction can change the program counter (PC) of a CPU. The program counter stores the memory address of the next instruction to be executed. Therefore, a branch can cause the CPU to begin fetching its instructions from a different sequence of memory cells.

BL instruction

The Branch with link (BL) instruction causes a branch to label, and copies the address of the next instruction into LR (R14, the link register). This instruction is only executed if the condition is true.

---------------------------------------------------

(b) Inline functions behave like macros. When an inline function gets called, instead of transferring the control to the function, the call gets substituted with the function code. Thus this saves time and improves software performance.

Inline functions can improve software performance by the following ways:

(1) Function call overhead does not occur.

(2) Inline functions save the overhead of push/pop variables on the stack when function is called.

(3) It also saves overhead of a return call from a function.

(4) When we inline a function, we may enable compiler to perform context specific optimization on the body of function. Such optimizations are not possible for normal function calls. Other optimizations can be obtained by considering the flows of calling context and the called context.

(5) Inline function may be useful (if it is small) for embedded systems because inline can yield less code than the function call preamble and return.

At the time of declaration or definition, inline functions are preceded by word inline. When inline functions are used, the overhead of function call is rejected. Instead of, executable statements of the function are copied at the place of each function call. This is done by the compiler.

NOTE:- If u have any doubts please comment below and I am happily help to u brother please thumsup bro and don't give any negative reviews please ????


Related Solutions

List and describe the steps in the power-on procedure
List and describe the steps in the power-on procedure
Describe the major steps in the construction of portfolio objectives.
Describe the major steps in the construction of portfolio objectives.
Describe the steps of aseptic technique when transferring culture to a plate. Describe the steps of...
Describe the steps of aseptic technique when transferring culture to a plate. Describe the steps of streaking for isolation. What is the goal of streaking a plate this way? Please post with typed responses - no handwritten or picture responses.
Identify and describe the major steps involved in financial planning.
Identify and describe the major steps involved in financial planning.
Describe the procedure to determine the first modal damping. Outline the key steps and sketch the...
Describe the procedure to determine the first modal damping. Outline the key steps and sketch the collected acceleration data.
Describe the steps involved in using the z-interval procedure to obtain a confidence interval for the...
Describe the steps involved in using the z-interval procedure to obtain a confidence interval for the population mean when standard deviation is known. Include a description of the preliminary data analysis. Why is preliminary data analysis needed?
describe the major steps involved in designing and implementing a training system and which steps tend...
describe the major steps involved in designing and implementing a training system and which steps tend to be the weakest
4. Cross sectioning a) Describe briefly the steps involved in a cross-sectioning procedure of an encapsulated...
4. Cross sectioning a) Describe briefly the steps involved in a cross-sectioning procedure of an encapsulated sample. b)Explain the differences between grinding ad polishing.
What problems occur in a pipelined CPU architecture when conditional branches are encountered? Name and describe...
What problems occur in a pipelined CPU architecture when conditional branches are encountered? Name and describe ways in which the effects of conditional branches can be reduced or eliminated.
Describe the phases and major steps of the ovarian and uterine cycles. Include: a. Oocyte and...
Describe the phases and major steps of the ovarian and uterine cycles. Include: a. Oocyte and follicle maturation and growth b. The role of hormones and their subsequent effects c. Differences between the cycles when fertilization occurs or does not occur
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT