]> wirehaze git hosting - MS-DOS.git/blob - v4.0/src/MEMM/MEMM/EXTPOOL.ASM

wirehaze git hosting

MZ is back!
[MS-DOS.git] / v4.0 / src / MEMM / MEMM / EXTPOOL.ASM
1
2
3 page 58,132
4 ;******************************************************************************
5 TITLE EXTPOOL - MODULE to manage a pool of extended memory
6 ;******************************************************************************
7 ;
8 ; (C) Copyright MICROSOFT Corp. 1986
9 ;
10 ; Title: MEMM.EXE - MICROSOFT Expanded Memory Manager 386 Driver
11 ;
12 ; Module: EXTPOOL - Manage a pool of extended memory.
13 ;
14 ; Version: 0.01
15 ;
16 ; Date: Sep 1, 1988
17 ;
18 ; Author: ISP (ISP)
19 ;
20 ;******************************************************************************
21 ;
22 ; Change Log:
23 ;
24 ; DATE REVISION Description
25 ; -------- -------- --------------------------------------------
26 ;******************************************************************************
27 ; Functional Description:
28 ;
29 ; "Fixit Orders" Crisis mode file. We need to ship data structures up hi.
30 ; So at init time we get a pool of extended memory and manage it for the
31 ; fixit routine. Services provided include initialise, allocate and
32 ; blkmov to the memory.
33 ;
34 ;******************************************************************************
35 .lfcond
36 .386p
37
38 page
39 ;******************************************************************************
40 ; P U B L I C D E C L A R A T I O N S
41 ;******************************************************************************
42 public pool_initialise
43 public get_buffer
44
45 page
46 ;******************************************************************************
47 ; L O C A L C O N S T A N T S
48 ;******************************************************************************
49 ;
50
51 ;******************************************************************************
52 ; INCLUDE FILES
53 ;******************************************************************************
54 include vdmseg.inc ; segment definitions
55
56 page
57 ;******************************************************************************
58 ; E X T E R N A L R E F E R E N C E S
59 ;******************************************************************************
60 ;
61 ;
62 page
63 ;******************************************************************************
64 ; S E G M E N T D E F I N I T I O N
65 ;******************************************************************************
66
67 ;*************************************************************************
68 ;
69 ; DATA
70 ;
71 ;*************************************************************************
72
73 LAST SEGMENT
74
75 ext_start dw 0000h ; start of the pool of extended memory
76 dw 0010h ; 24 bit address
77
78 ext_size dw 0 ; size
79 dw 0 ;
80
81 LAST ENDS
82
83 ;*************************************************************************
84 ;
85 ; CODE
86 ;
87 ;*************************************************************************
88 LAST SEGMENT
89 assume cs:LAST, DS:DGROUP, ES:DGROUP
90
91
92 ;******************************************************************************
93 ;*** Pool Initialise *** Give this memory manager the memory it is to play ;
94 ; with. ;
95 ; ;
96 ; INPUTS: AX = start offset of the extended memory in K ;
97 ; CX = size of the memory ;
98 ; ;
99 ; OUTPUTS: None ;
100 ; ;
101 ; USES: None ;
102 ; ;
103 ; AUTHOR: ISP (ISP) Sep 1, 1988 ;
104 ; ;
105 ;*****************************************************************************;
106
107 Pool_Initialise proc near
108 ;
109 push dx
110 push cx
111 push ax
112 ;
113 push cx ; save size of memory
114 xor dx,dx
115 mov cx,1024
116 mul cx ; dx:ax size in bytes offset from 1M
117 ;
118 add ax,cs:[ext_start] ; add it to 1M
119 adc dx,cs:[ext_start+2] ;
120 ;
121 mov cs:[ext_start],ax ;
122 mov cs:[ext_start+2],dx ;
123 ;
124 pop ax ; get size into ax
125 xor dx,dx ;
126 mul cx
127 ;
128 mov cs:[ext_size],ax
129 mov cs:[ext_size+2],dx
130 ;
131 pop ax
132 pop cx
133 pop dx
134 ;
135 ret
136 ;
137 Pool_Initialise endp
138
139
140
141 ;******************************************************************************
142 ;***Get buffer*** Give some poor beggar the memory he is asking for ;
143 ; ;
144 ; INPUTS: cx = size of buffer required in bytes ;
145 ; ;
146 ; OUTPUTS: DX:AX = address of buffer ;
147 ; cx = size allocated
148 ; ;
149 ; USES: None ;
150 ; ;
151 ; AUTHOR: ISP (ISP) Sep 1, 1988 ;
152 ; ;
153 ;*****************************************************************************;
154
155 Get_Buffer proc near
156 ;
157 ;
158 ; assume that the memory is present, put start address in dx:ax
159 ;
160 mov dx,cs:[ext_start+2]
161 mov ax,cs:[ext_start]
162 ;
163 ; then proceed to determine if it really exists
164 ;
165 push eax
166 xor eax,eax
167 mov ax,cx
168 cmp eax, dword ptr cs:[ext_size]
169 ja no_mem
170 ;
171 ; it does exist, adjust the size and the start address
172 ;
173 sub dword ptr cs:[ext_size],eax
174 add dword ptr cs:[ext_start],eax
175 ;
176 pop eax
177 clc
178 ret
179
180 no_mem:
181 pop eax
182 stc
183 ret
184 Get_buffer endp
185
186 LAST ENDS
187 end