Jump to content

DosSetVec: Difference between revisions

From EDM2
No edit summary
Ak120 (talk | contribs)
mNo edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Legacy
|RepFunc=N/A
|Remarks=This function has been eliminated since OS/2 2.0.
}}
This call allows a process to register an address to be used when a machine exception occurs.
This call allows a process to register an address to be used when a machine exception occurs.


Line 10: Line 6:
==Parameters==
==Parameters==
;VecNum (USHORT) - input : Number of the vector to be serviced by this routine. Valid values are:
;VecNum (USHORT) - input : Number of the vector to be serviced by this routine. Valid values are:
'''Value        Definition'''
::00 - Divide overflow
00       Divide overflow  
::04 - Overflow
04       Overflow  
::05 - Bound
05       Bound  
::06 - Invalid opcode
06       Invalid opcode
::07 - Processor extension not available
07       Processor extension not available
::16 - Processor extension error.
16       Processor extension error.
;Routine (PFN) - input : Address of a routine to be entered when the exception occurs. If this parameter is 0, any previous address is de-registered.
; Routine (PFN) - input : Address of a routine to be entered when the exception occurs. If this parameter is 0, any previous address is de-registered.
;PrevAddress (PFN) - output : Address of the previous handler routine. This is provided so a handler may be set, then later restored to the previous handler.
; PrevAddress (PFN) - output : Address of the previous handler routine. This is provided so a handler may be set, then later restored to the previous handler.


==Return Code==
==Return Code==
; rc (USHORT) - return
;rc (USHORT) - return:Return code descriptions are:
Return code descriptions are:
* 0 ERROR_INVALID_FUNCTION
* 0         ERROR_INVALID_FUNCTION
*50 ERROR_NOT_SUPPORTED
* 50       ERROR_NOT_SUPPORTED  


==Remarks==
==Remarks==
Line 42: Line 36:
VecNum = 7 not supported.
VecNum = 7 not supported.


==Example Code==
==Bindings==
===C Binding===
===C===
<PRE>
<PRE>
#define INCL_DOSMISC
#define INCL_DOSMISC
Line 49: Line 43:
USHORT  rc = DosSetVec(VecNum, Routine, PrevAddress);
USHORT  rc = DosSetVec(VecNum, Routine, PrevAddress);


USHORT           VecNum;             /* Function request code */
USHORT VecNum;     /* Function request code */
PFN             Routine;           /* Handler routine */
PFN     Routine;     /* Handler routine */
PFN             PrevAddress;       /* Previous handler address
PFN     PrevAddress; /* Previous handler address (returned) */
                                        (returned) */


USHORT                   rc;        /* return code */
USHORT rc;        /* return code */
</PRE>
</PRE>


===MASM Binding===
===MASM===
<PRE>
<PRE>
EXTRN  DosSetVec:FAR
EXTRN  DosSetVec:FAR
Line 70: Line 63:
</PRE>
</PRE>


==Related Functions==
[[Category:Dos16]]
*
 
[[Category:Dos]]

Latest revision as of 08:03, 26 January 2020

This call allows a process to register an address to be used when a machine exception occurs.

Syntax

DosSetVec (VecNum, Routine, PrevAddress)

Parameters

VecNum (USHORT) - input
Number of the vector to be serviced by this routine. Valid values are:
00 - Divide overflow
04 - Overflow
05 - Bound
06 - Invalid opcode
07 - Processor extension not available
16 - Processor extension error.
Routine (PFN) - input
Address of a routine to be entered when the exception occurs. If this parameter is 0, any previous address is de-registered.
PrevAddress (PFN) - output
Address of the previous handler routine. This is provided so a handler may be set, then later restored to the previous handler.

Return Code

rc (USHORT) - return
Return code descriptions are:
  • 0 ERROR_INVALID_FUNCTION
  • 50 ERROR_NOT_SUPPORTED

Remarks

The DosSetVec process is analogous to setting an address in the interrupt vector table when running in 8086 mode.

Should an exception occur, and the process has registered a handler, that handler is entered as if its address had been stored in the CPU's interrupt vector, except that the interrupt is still enabled. If no address has been registered for that vector, the process terminates.

When a process registers an exception handler for VecNum 7 (processor extension not available), the machine status word (MSW) for that process is set to indicate that a numeric processor extension (NPX) 287 is not present in the machine. The Emulate bit is set and the Monitor Processor bit is reset. This is done without regard for the true state of the hardware.

When a process de-registers a handler for VecNum 7, the MSW is set to reflect the true state of the hardware.

When an NPX287 exception is processing, the NPX287 status word is passed to the exception handler by being pushed on the stack before the exception handler is invoked. When the exception handler has completed execution, this word must be popped from the stack before an IRET is issued to return to the exception handler interface routine.

Family API Considerations

Some options operate differently in the DOS mode than in OS/2 mode. Therefore, the following restriction applies to DosSetVec when coding for the DOS mode.

VecNum = 7 not supported.

Bindings

C

#define INCL_DOSMISC

USHORT  rc = DosSetVec(VecNum, Routine, PrevAddress);

USHORT  VecNum;      /* Function request code */
PFN     Routine;     /* Handler routine */
PFN     PrevAddress; /* Previous handler address (returned) */

USHORT  rc;         /* return code */

MASM

EXTRN  DosSetVec:FAR
INCL_DOSMISC      EQU 1

PUSH   WORD    VecNum        ;Function request code
PUSH@  OTHER   Routine       ;Handler routine address
PUSH@  DWORD   PrevAddress   ;Previous handler address (returned)
CALL   DosSetVec

Returns WORD