Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Assembly x86 > Re: Writing sma...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 7 of 8 Topic 4573 of 4774
Post > Topic >>

Re: Writing small .COM executables

by NoSpam@[EMAIL PROTECTED] (Bob Masta) Mar 17, 2008 at 01:19 PM

On Sun, 16 Mar 2008 23:18:41 +0000, Alex Buell  <spamtrap@[EMAIL PROTECTED]
>
wrote:

>On Sun, 16 Mar 2008 14:13:35 GMT, I waved a wand and this message
>magically appears in front of Bob Masta:
>
>> >Ah, thanks I know what the error I've made - I did put all my
>> >uninitialised data in the .bss section, but forgotten all about the
>> >resb/d/q/t/o - I've been using db/w... Excellent, I'll save a lot of
>> >space!
>> >-- 
>> 
>> Just remember that unless you do something to move it, the stack is at
>> the top of your COM segment by default, and grows down toward that
>> area you are using for BSS data.  If you have a large COM app (code
>> plus all data) and/or large stack needs due to recursion or whatever,
>> you should either move your stack or put some of your data in its own
>> segment above that.  It can actually be a big help to move large data
>> buffers and arrays to their own segments, becuse then you can index
>> them starting at offset 0 in their segments.  So the index becomes the
>> pointer without needing a table offset added into every access.
>
>Ah, stack handling - another subject I need to deal with. I understand
>it's fine for tiny DOS executables; most of what I've written lately
>fits in just 1K so there's not too many worries about stack handling. 
>
>For larger projects, yes I'd agree that giving the stack its own
>segment would be more than sufficient to deal with recursion etc. 
>
>Should I run into problems with stack handling, are there any
>references on the 'net that I can read through? It's been many years
>since I dealt with that sort of thing!
>-- 

I've been bitten by the stack problem in the past, when what started
as a small utility gets added features, etc.  It produces mysterious
results that can be hard to debug unless "stack collision" is a
possibility you are thinking about.  I solved it by setting SP to 100h
(as soon as I was done with the PSP parameters) at the start of
nearly every COM I wrote after that.  The stack then grew down
into the PSP parameter section, and since I never was a big stack
user (I always pass parameters in registers or memory structures, and
never use recursion) this worked great for me.  I don't recall now
what the limit of stack incursion into the PSP was; there might be
problems if you trash the DOS return address, but I never used the
RET method to end my COMs.  But there is at least 80h of parameter
space for sure, which is more than enough for my sort of usage.

Remember that under true real-mode DOS there can be other
processes running (like interrupt handlers and TSRs) that can use your
stack.  Hopefully, if they are going to use the stack for much more
than the usual return addresses, they will use their own stacks.
I never had any problems in this regard.

Best regards,



Bob Masta
 
              DAQARTA  v3.50
   Data AcQuisition And Real-Time Analysis
             www.daqarta.com
Scope, Spectrum, Spectrogram, FREE Signal Generator
        Science with your sound card!
 




 8 Posts in Topic:
Writing small .COM executables
Alex Buell <spamtrap@  2008-03-15 14:03:24 
Re: Writing small .COM executables
Frank Kotler <spamtra  2008-03-15 22:02:10 
Re: Writing small .COM executables
Terence <spamtrap@[EM  2008-03-15 19:21:06 
Re: Writing small .COM executables
Alex Buell <spamtrap@  2008-03-16 07:59:38 
Re: Writing small .COM executables
NoSpam@[EMAIL PROTECTED]   2008-03-16 14:13:35 
Re: Writing small .COM executables
Alex Buell <spamtrap@  2008-03-16 23:18:41 
Re: Writing small .COM executables
NoSpam@[EMAIL PROTECTED]   2008-03-17 13:19:50 
Re: [Clax86list] Writing small .COM executables
Charles Crayne <spamt  2008-03-16 20:53:30 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Sep 7 7:10:23 CDT 2008.