please dont rip this site

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/19 06:53,
TOP NEW HELP FIND: 
3.133.145.136: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?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://massmind.org/Techref/dos/Alloc.htm"> MSDOS/PCDOS - Services - Memory Management - Allocation</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to massmind.org!

 

Welcome to massmind.org!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .