Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.msdos.programmer > #4080
| From | "R.Wieser" <address@not.available> |
|---|---|
| Newsgroups | comp.os.msdos.programmer |
| Subject | Re: initial memory |
| Date | 2021-12-03 11:25 +0100 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <socrrm$1tl0$1@gioia.aioe.org> (permalink) |
| References | <8808cb98-5cfd-444d-87ac-a71ef937f64cn@googlegroups.com> |
Muta, > I have startup code below that resizes that memory, as > per rules I no longer remember. ... > mov ax, sp > mov cl, 4 > shr ax, cl ; get sp into pages When a COM runs SP is set to the end of the SS segment. As a COM has all the segments overlapping its upto how big your program is how much stack you are actually reserving. But looking at my own programs I don't think that reserving 60KB stack for a 4KB program is normally called for. Hence I set SP myself (sometimes even to the programs top at 0100h) and instead use a LASTBYTE label to figure out how much room I actually need calculated the # of pages from it : - - - - - - - - - - - - - - - - - - - - lea sp,[StackTop] ;Set new Stack-top mov bx,(offset LASTBYTE)+000Fh ;number of bytes in program + round-up mov cl,04h ;convert to pages shr bx,cl ;/ mov ah,4ah ;resize program space int 21h ;/ jc @@Main_Error ;ERROR : Out of Memory ! - - - - - - - - - - - - - - - - - - - - As you might see, I also made sure I could actually allocate it, as its possible a COM gets loaded in a memory fragment thats not actually large enough to hold it and the "extra" memory it needs. > So for all executables, all of memory is allocated until > released? Yes for a .COM style program, and "it depends" for a .EXE style one - as that latter one has got a header wich specifies lots of stuff. > tlink (which is what I originally used) puts x'ffff' as the number > of paragraphs to allocate, meaning allocate all memory. Indeed it does (using Borlands Tasm v4.1 and TLink v7.1). I've never been able to find a "minimize footprint" switch or setting, which has irked me to no end. You see, one of the fields in an .EXEs header is "min_extra_paragraphs" , containing - you guessed it - exactly how much it needs. As such I wrote a small program that copies that field into the "max_extra_paragraphs" one (which is, in our case, the culprit), recalculate the SS:SP value from it and put it into their respective fields. From than on the OS does, for the .EXE, all the work for me, allowing me to drop the "shrink my memory" code from it. :-) Regards, Rudy Wieser
Back to comp.os.msdos.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
initial memory "muta...@gmail.com" <mutazilah@gmail.com> - 2021-12-02 14:07 -0800
Re: initial memory JJ <jj4public@gmail.com> - 2021-12-03 15:05 +0700
Re: initial memory "muta...@gmail.com" <mutazilah@gmail.com> - 2021-12-03 00:38 -0800
Re: initial memory Mateusz Viste <mateusz@xyz.invalid> - 2021-12-03 09:45 +0100
Re: initial memory "muta...@gmail.com" <mutazilah@gmail.com> - 2021-12-03 01:22 -0800
Re: initial memory JJ <jj4public@gmail.com> - 2021-12-04 14:00 +0700
Re: initial memory "R.Wieser" <address@not.available> - 2021-12-04 08:39 +0100
Re: initial memory Mateusz Viste <mateusz@xyz.invalid> - 2021-12-04 09:35 +0100
Re: initial memory "R.Wieser" <address@not.available> - 2021-12-04 13:00 +0100
Re: initial memory Mateusz Viste <mateusz@xyz.invalid> - 2021-12-04 13:12 +0100
Re: initial memory "R.Wieser" <address@not.available> - 2021-12-04 15:55 +0100
Re: initial memory Mateusz Viste <mateusz@xyz.invalid> - 2021-12-04 16:30 +0100
Re: initial memory "R.Wieser" <address@not.available> - 2021-12-04 18:11 +0100
Re: initial memory Mateusz Viste <mateusz@xyz.invalid> - 2021-12-04 19:04 +0100
Re: initial memory "R.Wieser" <address@not.available> - 2021-12-04 21:02 +0100
Re: initial memory "muta...@gmail.com" <mutazilah@gmail.com> - 2021-12-05 15:01 -0800
Re: initial memory Mateusz Viste <mateusz@xyz.invalid> - 2021-12-06 09:27 +0100
Re: initial memory JJ <jj4public@gmail.com> - 2021-12-05 14:03 +0700
Re: initial memory JJ <jj4public@gmail.com> - 2021-12-04 14:01 +0700
Re: initial memory "muta...@gmail.com" <mutazilah@gmail.com> - 2021-12-04 02:00 -0800
Re: initial memory JJ <jj4public@gmail.com> - 2021-12-05 14:12 +0700
Re: initial memory "muta...@gmail.com" <mutazilah@gmail.com> - 2021-12-05 15:02 -0800
Re: initial memory JJ <jj4public@gmail.com> - 2021-12-06 13:28 +0700
Re: initial memory "R.Wieser" <address@not.available> - 2021-12-03 11:25 +0100
Re: initial memory "muta...@gmail.com" <mutazilah@gmail.com> - 2021-12-03 03:18 -0800
Re: initial memory "R.Wieser" <address@not.available> - 2021-12-03 14:19 +0100
Re: initial memory "muta...@gmail.com" <mutazilah@gmail.com> - 2021-12-03 11:35 -0800
Re: initial memory "R.Wieser" <address@not.available> - 2021-12-03 22:30 +0100
Re: initial memory - SS:SP "R.Wieser" <address@not.available> - 2021-12-06 14:32 +0100
Re: initial memory - SS:SP "R.Wieser" <address@not.available> - 2021-12-06 14:51 +0100
csiph-web