iAPX 286 Operating System Writers Guide 1983
iAPX 286 Operating System Writers Guide 1983
iAPX 286 Operating System Writers Guide 1983
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
HANDLING EXCEPTION CONDITIONSInterrupt O-Oivide ErrorThis exception may occur during DIY (unsigned divide) and IDlY (integer divide) instructions. Theprocessor causes a divide-error exception in case of division by zero or quotient overflow.A divide-error handler might, for example, replace the quotient with a predetermined value and permitthe faulting task to continue. The return pointer indicates the first byte of the divide instruction, so thehandler must increment the return pointer before returning.Interrupt 1-Single StepThe processor causes a 'single step exception at the end of every instruction when the TF (trap flag) isset. When the processor invokes any interrupt procedure, it saves the flags and resets the TF so thatthe exception handler does not cause a single-step exception. Executing IRET at the end of the exceptionhandler restores TF.The exception handler for this exception typically belongs to a debugging system. Single stepping is avaluable debugging tool. It allows the exception handler to act as a "window" into the system throughwhich you can observe task operation instruction by instruction. A single-step handler may, for example,display register contents, the value of the instruction pointer, key variables, etc., as they change aftereach instruction.The single-step exception handler should take care, however, not to violate the system's protection goalsby its actions. To protect the operating system from the debugging activities of an applicationsprogrammer, the debugger should not give access to the more privileged levels. The debugger cancheck, either before or after each instruction, whether the instruction causes a control transfer to aprohibited level. After such a transfer, the return pointer identifies the next instruction in an accessiblesegment. The debugger can set a breakpoint at that instruction and suspend single stepping until thebreakpoint trap occurs.Interrupt 3-BreakpointThe INT 3 instruction causes this exception. The INT 3 instruction is one byte long, which makes iteasy to insert a breakpoint anywhere in an executable segment. The operating system or a debuggingsubsystem can use a data-segment alias for an executable segment to place an INT 3 instruction anyplacewhere it is convenient to arrest normal execution so that some sort of special processing can be performed.Debuggers typically use breakpoints as a way of displaying registers, variables, etc., at crucial pointsin a task.The saved IP value points to the next instruction. Ifa debugger has replaced a planted breakpoint witha valid opcode, it must subtract one from the saved IP value before returning.Interrupt 4-0verflowThis exception occurs when the processor encounters an INTO instruction and the OF (overflow) flagis set. Since signed arithmetic and unsigned arithmetic both use the same arithmetic instructions, theprocessor can not tell which is intended and therefore does not cause an overflow exception. Instead itmerely sets OF when the results, if interpreted as signed numbers, would be out of range. When doingarithmetic on signed operands, careful programmers and compilers either test OF directly or use theINTO instructioll.7-3 121960-001