summaryrefslogtreecommitdiff
path: root/v4.0/src/MAPPER/ALLOCSEG.ASM
diff options
context:
space:
mode:
Diffstat (limited to 'v4.0/src/MAPPER/ALLOCSEG.ASM')
-rw-r--r--v4.0/src/MAPPER/ALLOCSEG.ASM87
1 files changed, 87 insertions, 0 deletions
diff --git a/v4.0/src/MAPPER/ALLOCSEG.ASM b/v4.0/src/MAPPER/ALLOCSEG.ASM
new file mode 100644
index 0000000..36de869
--- /dev/null
+++ b/v4.0/src/MAPPER/ALLOCSEG.ASM
@@ -0,0 +1,87 @@
1;0
2page 80,132
3;
4title CP/DOS DosAllocSeg mapper
5;
6dosxxx segment byte public 'dos'
7 assume cs:dosxxx,ds:nothing,es:nothing,ss:nothing
8;
9; ************************************************************************* *
10; *
11; * MODULE: DosAllocSeg
12; *
13; * FUNCTION: This module allocates a segment of memory to the
14; * requesting process
15; *
16; * CALLING SEQUENCE:
17; *
18; * push size ; number of bytes requested
19; * push@ selector ; selector allocated (returned)
20; * push shareind ; whether segment will be shared
21; * call dosallocseg
22; *
23; * RETURN SEQUENCE:
24; *
25; * AX = error , 0 = no error
26; *
27; * MODULES CALLED: DOS int 21h
28; *
29; *************************************************************************
30;
31 public dosallocseg
32 .sall
33 .xlist
34 include macros.inc
35 .list
36;
37str struc
38old_bp dw ?
39return dd ?
40ShareIndicator dw ? ; whether segment will be shared
41SelectorPtr dd ? ; selector allocated
42SegmentSize dw ? ; number of bytes requested
43str ends
44
45dosallocseg proc far
46 Enter dosallocseg ; push registers
47
48 mov bx,[bp].SegmentSize ; Get segment size
49
50 test bx,0000fh ; check segment size
51 jz NoRoundRequired
52
53 and bx,not 0000fh
54 add bx,00010h
55
56NoRoundRequired:
57 cmp bx,0 ; check for 0 (full seg)
58 je AllocateMax ; jmp to full seg
59
60 shr bx,1 ; convert segment in bytes to
61 shr bx,1 ; paragraph
62 shr bx,1
63 shr bx,1
64 jmp HaveSize
65
66AllocateMax:
67 mov bx,4096 ; setup default paragraph size
68
69HaveSize:
70 mov ah,48h ; set up for dos allocate call
71 int 21h ; allocate segment
72 jc ErrorExit ; jump if error
73
74 lds si,[bp].SelectorPtr ; get selector address
75 mov ds:[si],ax ; save allocated memory block
76
77AllocDone:
78 sub ax,ax ; set good return code
79ErrorExit:
80 mexit ; pop registers
81 ret size str - 6 ; return
82
83dosallocseg endp
84
85dosxxx ends
86
87 end