-
Notifications
You must be signed in to change notification settings - Fork 0
/
int.c
86 lines (77 loc) · 1.07 KB
/
int.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
79
80
81
82
83
84
85
86
#include <dos.h>
#include "int.h"
union REGS regs;
struct SREGS sregs;
int _BP;
#ifndef NODOS
static char id[] = "$Id: int.c,v 1.1 1998/06/24 13:07:06 ken Exp $";
#endif
void interrupt10(unsigned ax, unsigned bx, unsigned cx, unsigned dx)
{
#asm
push bp
mov bp,sp
mov ax,4[bp]
mov bx,6[bp]
mov cx,8[bp]
mov dx,10[bp]
int #0x10
pop bp
#endasm
}
void geninterrupt(int i)
{
/* we know geninterrupt is only called for int 0x10 */
#asm
mov ax,[_regs+0]
mov bx,[_regs+2]
mov cx,[_regs+4]
mov dx,[_regs+6]
mov __BP,bp
int #0x10
mov bp,__BP
mov [_regs+0],ax
mov [_regs+2],bx
mov [_regs+4],cx
mov [_regs+6],dx
#endasm
}
void gotoxy(int x, int y)
{
interrupt10(0x0200, 0x0000, 0x0000, (y - 1) << 16 | (x - 1));
}
void enable(void)
{
#asm
sti
#endasm
}
void disable(void)
{
#asm
cli
#endasm
}
int inportb(int port)
{
#asm
pop bx
pop dx
dec sp
dec sp
inb
sub ah,ah
jmp bx
#endasm
}
void outportb(int port, char value)
{
#asm
pop bx
pop dx
pop ax
sub sp,*4
outb
jmp bx
#endasm
}