Ref Programmers Journal Vol 9.2 Pg 10
When DOS loads an EXE file into a memory block, it alocates the whole block. When your program starts, it already owns most of the available memory and cannot allocate any more. If you shrink the program memory block to the minimum required, you can then reallocate as necessary. The following is a short demonstration program.
; Code from John Otken dosseg .model small .stack .code ;; main ; main proc mov bx,offset stack+15 ; compute program size in paragraphs mov cl,4 ; SS != DGROUP in program shr bx,cl add bx,data mov ax,es ; ES == Struc -Program Segment Prefix sub bx,ax mov ah,4Ah ; Shrink program's memory block int 21h ; Int\21f\4A mov ah,48h ; Allocate 16 paragraphs of memory mov bx,16 ; (16 paragraphs == 256 bytes) int 21h ; Int\21f\48 mov ax,4C00h ; exit program int 21h ; Int\21f\4C main endp end main
file: /Techref/dos/Alloc.htm, 1KB, , updated: 1999/2/20 10:24, local time: 2024/11/16 03:44,
3.133.129.110:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://linistepper.com/techref/dos/Alloc.htm"> MSDOS/PCDOS - Services - Memory Management - Allocation</A> |
Did you find what you needed? |