-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
msdos.c
78 lines (64 loc) · 1.47 KB
/
msdos.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
* msdos.c
*
* MS-DOS interface functions
*/
#ifdef __DJGPP__
# include <dpmi.h>
#else
# include <dos.h>
#endif
#include "global.h"
#include "msdos.h"
#ifdef __DJGPP__
void
msdos_get_interrupt_vector (Byte int_num, Word *segment, Word *offset)
{
__dpmi_regs regs;
/* Int 21h AH=35h returns vector AL in ES:BX */
regs.h.ah = 0x35;
regs.h.al = int_num;
__dpmi_int (0x21, ®s);
*segment = regs.x.es;
*offset = regs.x.bx;
}
#else /* !__DJGPP__ */
void
msdos_get_interrupt_vector (Byte int_num, Word *segment, Word *offset)
{
union REGS regs;
struct SREGS seg_regs;
/* Int 21h AH=35h returns vector AL in ES:BX */
regs.h.ah = 0x35;
regs.h.al = int_num;
int86x (0x21, ®s, ®s, &seg_regs);
*segment = seg_regs.es;
*offset = regs.x.bx;
}
#endif /* !__DJGPP__ */
#ifdef __DJGPP__
void
msdos_set_interrupt_vector (Byte int_num, Word segment, Word offset)
{
__dpmi_regs regs;
/* Int 21h AH=25h sets vector AL to DS:DX */
regs.h.ah = 0x25;
regs.h.al = int_num;
regs.x.ds = segment;
regs.x.dx = offset;
__dpmi_int (0x21, ®s);
}
#else /* !__DJGPP__ */
void
msdos_set_interrupt_vector (Byte int_num, Word segment, Word offset)
{
union REGS regs;
struct SREGS seg_regs;
/* Int 21h AH=25h sets vector AL to DS:DX */
regs.h.ah = 0x25;
regs.h.al = int_num;
seg_regs.ds = segment;
regs.x.dx = offset;
int86x (0x21, ®s, ®s, &seg_regs);
}
#endif /* !__DJGPP__ */