-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXMS.PAS
More file actions
117 lines (98 loc) · 3.12 KB
/
XMS.PAS
File metadata and controls
117 lines (98 loc) · 3.12 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
{ SMIX is Copyright 1995 by Ethan Brodsky. All rights reserved. }
unit XMS;
interface
{Initialization}
function XMSInstalled: boolean;
procedure XMSInit;
{Informational}
function XMSGetVersion: word;
function XMSGetFreeMem: word;
{Allocation and deallocation}
function XMSAllocate(var Handle: word; Size: word): boolean;
function XMSReallocate(Handle: word; NewSize: word): boolean;
function XMSFree(Handle: word): boolean;
{Memory moves}
type
PMoveParams = ^TMoveParams;
TMoveParams =
record
Length : LongInt; {Length must be a multiple of two}
SourceHandle : word;
SourceOffset : LongInt;
DestHandle : word;
DestOffset : LongInt;
end;
function XMSMove(Params: PMoveParams): boolean;
implementation {ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ}
var
XMSDriver: pointer;
{ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ}
function XMSInstalled: boolean; assembler;
asm
mov ax, 4300h
int 2Fh
cmp al, 80h
jne @NoXMSDriver
mov al, TRUE
jmp @Done
@NoXMSDriver:
mov al, FALSE
@Done:
end;
{ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ}
procedure XMSInit; assembler;
asm
mov ax, 4310h
int 2Fh
mov word ptr [XMSDriver], bx
mov word ptr [XMSDriver+2], es
end;
{ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ}
function XMSGetVersion: word; assembler;
asm
mov ah, 00h
call XMSDriver
end;
{ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ}
function XMSGetFreeMem: word; assembler;
asm
mov ah, 08h
call XMSDriver
mov ax, dx
end;
{ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ}
function XMSAllocate(var Handle: word; Size: word): boolean; assembler;
asm
mov ah, 09h
mov dx, Size
call XMSDriver
les di, Handle
mov es:[di], dx
end;
{ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ}
function XMSReallocate(Handle: word; NewSize: word): boolean; assembler;
asm
mov ah, 0Fh
mov bx, NewSize
mov dx, Handle
call XMSDriver
end;
{ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ}
function XMSFree(Handle: word): boolean; assembler;
asm
mov ah, 0Ah
mov dx, Handle
call XMSDriver
end;
{ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ}
function XMSMove(Params: PMoveParams): boolean; assembler;
asm
push ds
mov ax, ds
mov es, ax
mov ah, 0Bh
lds si, Params
call es:XMSDriver
pop ds
end;
end. {ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ}