Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

THE QUESTION: High-level languages provide a switch statement that looks as follows. switch (k) { case 0: case 1: case 2: case 3: The compiler

image text in transcribed

THE QUESTION:

image text in transcribed

High-level languages provide a "switch" statement that looks as follows. switch (k) \{ case 0: case 1: case 2: case 3: The compiler writer knows that " k " can take contiguous integer values from 0 to 9 during execution, with any other value going to the default case. She decides to use a jump table data structure (implemented as an array indexed by the value contained in k ) to hold the start address for the code for each of the case value as shown below: Jump tadie Assuming we are using the LC-2200 instruction set architecture, which can be found in the appendix: (i) Assume the base address of the jump table is stored in the register $t0, the value of k is stored in register $t1. Help her out by writing a series of instructions that reaches the code for case k. (4 points) (ii) Instead of using a jump table, her friend suggests using a series of conditional branch instructions to compile the switch statement. Which one is faster? Explain your answer, clearly stating your assumptions. ( 6 points) High-level languages provide a "switch" statement that looks as follows. switch (k) \{ case 0: case 1: case 2: case 3: The compiler writer knows that " k " can take contiguous integer values from 0 to 9 during execution, with any other value going to the default case. She decides to use a jump table data structure (implemented as an array indexed by the value contained in k ) to hold the start address for the code for each of the case value as shown below: Jump tadie Assuming we are using the LC-2200 instruction set architecture, which can be found in the appendix: (i) Assume the base address of the jump table is stored in the register $t0, the value of k is stored in register $t1. Help her out by writing a series of instructions that reaches the code for case k. (4 points) (ii) Instead of using a jump table, her friend suggests using a series of conditional branch instructions to compile the switch statement. Which one is faster? Explain your answer, clearly stating your assumptions. ( 6 points)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

L A -r- P[N]

Answered: 1 week ago