Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

The simple exception handler always jumps back to the instruction following the exception. This works fine unless the instruction that causes the exception is in the delay slot of a branch. In that case, the next instruction is the target of the branch. Write a better handler that uses the EPC register to determine which instruction should be executed after the exception.

Short Answer

Expert verified

If there is any exception occurred, then this exception handler returns the instructions and not re-execute the debug instructions, if the same exception is occurring again.

Step by step solution

01

Exception Handler and EPC.

Exception Handler:It is aninterrupt that occur during the execution of the code, that can be handled by the exception. In MIPS instruction an exception caused to a MIPS processor to jump back to a piece of code at address 80000180hex in the kernel but not the user address space.

There are some instructions to be used to avoid the delay slot of branch in exception handling.

EPC:EPC has the register number 14 which is defined as an address of instruction that can cause an exception. A mask bit 1 can enable an interrupt and mask bit 0 refers to disable an interrupt. If the exception is delayed, then it refers to the delay bit 1 which executed in the delay slot of a branch.

02

Exception without delay

This code raises exception without delay:

ktext 0x80000180

mov $k1,$at #save $at register

sw $a0, save0 #Handler is not re-entrant and can’t use

sw $a1, save1

mfc 0$k0, $13 #move cause into $k0

srl $a0, $k0, 2 #Extract branch delay bit

andi $a0, $a0, 0xf #Get branch offset

bgtz $a0, done1

03

Exception with delay. 

This code raises exception with delay:

mfc 0 $k0, $13 #Move cause into $k0

srl $a0, $k0, 31 #Extract branch delay bit

beq $a0, $0, done1 #Not in the delay slot

mfc0 $k0, $14 # $14 is EPC

lw $a0, 0($k0) #Get the branch instruction

andi $a0, $a0, 0xffff #Get branch offset

sll $a0, $a0, 16 #shift left by 16

sra $a0, $a0, 16 #Sign extension

sll $a0, $a0, 2 #Shift left by 2

mtc0 $a0, $14 #Write branch target address

#back to EPC

j done2 #jump to done2

done1:

If there is any exception occurred, then this exception handler returns the instructions and not re-execute the above debug instructions, if the same exception is occurring again.

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with Vaia!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

Aside from the smart cell phones used by a billion people, list and describe four other types of computers.

Perhaps the most likely case of adding many numbers at once in a computer would be when trying to multiply more quickly by using any adders to add many numbers in a single clock cycle. Compared to the multiply algorithm in Chapter 3, a carry save scheme with many adders could multiply more than 10 times faster. This exercise estimates the cost and speed of a combinational multiplier to multiply two positive 16-bit numbers. Assume that you have 16 intermediate terms M15, M14, …, M0, called partial products, that contain the multiplicand ANDed with multiplier bits m15, m14, …, m0. The idea is to use carry save adders to reduce the noperands into 2n/3 in parallel groups of three, and do this repeatedly until you get two large numbers to add together with a traditional adder.

First, show the block organization of the 16-bit carry save adders to add these 16 terms, as shown on the right in Figure B.14.1. Then calculate the delays to add these 16 numbers. Compare this time to the iterative multiplication scheme in Chapter 3 but only assume 16 iterations using a 16-bit adder that has full carry lookahead whose speed was calculated in Exercise B.29.

Question: We wish to add a yellow light to our traffic light example on page B-68. We will do this by changing the clock to run at 0.25 Hz (a 4-second clock cycle time), which is the duration of a yellow light. To prevent the green and red lights from cycling too fast, we add a 30-second timer. The timer has a single input, called TimerReset, which restarts the timer, and a single output, called TimerSignal, which indicates that the 30-second period has expired. Also, we must redefine the traffic signals to include yellow. We do this by defining two output signals for each light: green and yellow. If the output NSgreen is asserted, the green light is on; if the output NSyellow is asserted, the yellow light is on. If both signals are off, the red light is on. Do not assert both the green and yellow signals at the same time, since American drivers will certainly be confused, even if European drivers understand what this means! Draw the graphical representation for the finite-state machine for this improved controller. Choose names for the states that are different from the names of the outputs.

Assume a color display using 8 bits for each of the primary colors (red, green, blue) per pixel and a frame size of 1280 × 1024. a. What is the minimum size in bytes of the frame buffer to store a frame? b. How long would it take, at a minimum, for the frame to be sent over a 100 Mbit/s network?

Question: Aside from the smart cell phones used by a billion people, list and describe four other types of computers

See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.

Sign-up for free