]> wirehaze git hosting - MS-DOS.git/blob - v4.0/src/MAPPER/REALLSEG.ASM

wirehaze git hosting

MZ is back!
[MS-DOS.git] / v4.0 / src / MAPPER / REALLSEG.ASM
1 ;
2 page 60,132
3 ;
4 title CP/DOS DosReallocSeg mapper
5 ;
6 dosxxx segment byte public 'dos'
7 assume cs:dosxxx,ds:nothing,es:nothing,ss:nothing
8 ;
9 ; ************************************************************************* *
10 ; *
11 ; * MODULE: DosReallocSeg
12 ; *
13 ; * FILE NAME: dos043.asm
14 ; *
15 ; * FUNCTION: This module changes the size of a segment already
16 ; * allocated
17 ; *
18 ; * CALLING SEQUENCE:
19 ; *
20 ; * push size ; new segment size requested in bytes
21 ; * push selector ; selector
22 ; * call dosreallocseg
23 ; *
24 ; * RETURN SEQUENCE:
25 ; *
26 ; *
27 ; *
28 ; * MODULES CALLED: DOS Int 21, AH=4A
29 ; *
30 ; *
31 ; *
32 ; *************************************************************************
33 ;
34 public dosreallocseg
35 .sall
36 .xlist
37 include macros.inc
38 .list
39
40 str struc
41 old_bp dw ?
42 return dd ?
43 Selector dw ? ; segment selector
44 SegmentSize dw ? ; new segment size in bytes
45 str ends
46
47 dosreallocseg proc far
48 Enter dosreallocseg ; save registers
49
50 mov bx,[bp].SegmentSize ; Get new segment size
51 cmp bx,0 ; check for 0
52 je AllocateMax ; jmp to full seg
53
54 shr bx,1 ; else convert segment in bytes
55 shr bx,1 ; paragraph
56 shr bx,1
57 shr bx,1
58 jmp HaveSize
59
60 AllocateMax:
61 mov bx,4096 ; default segment size in paragraph
62
63 HaveSize:
64 mov es,[bp].Selector ; set up segment for new size
65
66 mov ah,4ah ; set up for DOS realloc call
67 int 21h ; realloc segment
68 jc ErrorExit ; jump if error
69
70 sub ax,ax ; else set good return code
71
72 ErrorExit:
73 Mexit ; restore registers
74
75 ret size str - 6 ; return
76
77 dosreallocseg endp
78
79 dosxxx ends
80
81 end