🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.ibm.pc.programmer
Article #19

Re: DOS Kernel/COMMAND.COM

#19
From: Jen Kilmer
Date: Sat, 01 Aug 1992 00:54
79 lines
4172 bytes
In article <1992Jul29.213404.22198@mnemosyne.cs.du.edu> cnanayak@nyx.cs.du.edu (Chevan Nanayakkara @ Nyx) writes:
>I was wondering if someone could help me locate some information about writing
>a command.com replacement for DOS.  
>like to know what services I'd have to take care of and how.  Also how do I 
>find a list of what internal services command.com performs.  I've got some code
>I'm plugging through but if someone can point me in the direction of some text
>I would appreciate it very much.  
>Chevan (Sleepy) Nanayakkara  -  csnanaya@cadehp0.eng.utah.edu - best

hi Chevan. I'm going from memory, so it may not be totally complete,
but...

command.com provides the basic user environment for DOS. It prompts for
and accepts user input, carries out some basic file/system management
functions (anything your DOS manual calls "internal commands" - dir,
copy, cls, cd, md, rd, del, time, date, etc) and acts as a program 
loader.

The initial copy of COMMAND.COM creates the base environment space [often
called the "real environment", as in, how do I modify the real environment
from my program?]. COMMAND.COM normally passes a copy of the current 
environment to programs that it loads, and also passes on the "command tail"
- any parameters the user included with the program name. IE if you type

format a:<enter>

at the c> prompt, command reads in "format a:". The space after the t 
indicates that's the end of the actual command you want to run. So command
checks that format isn't one of it's interal things (dir, copy, et al).
Then it starts looking for a program called format. Command looks in the
current drive/directory for format.com, then format.exe, then format.bat
- if it's not found, it keeps searching in each directory specified on the
path variable.

when command finds format.com/.exe, it allocates memory for format, memory
for the environment, etc etc [see chapter 5 of the MS-DOS programmer's
reference, or another programming book about running child programs].

That's most of what command does. But it also...

responds to the prompt variable (changes its looks :-)

only has part of itself _always_ in memory...optional stuff [not needed
when other programs are active] gets overwritten. reloads itself using
comspec variable

provides default int 24 handler [you know that one, it says "abort, retry,
fail?" :> ]

provides default int 23 handler [you know that one too, it handles ctrl-c]

processes batch files

can get spawned from other programs easily [helps if you set comspec=
to yourself]

way back when and once upon a time, command actually implemented the
program execution call (int 21 func 4b). that's 2.0 though.

I would suggest picking up the...lemme check the title..._Microsoft
MS-DOS Programmer's Reference_, mainly cause it includes the 5.0-specific
stuff like how to use upper memory :-). I've heard there's a new version
of _DOS Programmer's Reference_ by Terry Dettmann, published by QUE, that
covers through 5.0 (the 2nd edition covers through 4.0).
 
While I haven't seen the new Dettmann book, I have the 1st and 2nd editions
and I prefer them to Duncan's _Advanced MS-DOS Programming_, from Microsoft
Press, which covers through 4.0 and is well regarded. [Dettmann is my
preference, more for writing style and organization than any factual 
differences.] The MS-DOS Encyclopedia is worth a look *BUT* ONLY covers
through 3.2 and IS HUGE and co$t$ more than the rest. 

My suggestions are Microsoft Press heavy because my boss can get them
for us cheaper then other publishers :-)

anyway, have fun and enjoy!

-jen
Ms Dos Enduser Support        no, I'm not speaking for microsoft, geez....
Technical Details
Message-ID: <1992Aug01.005449.13248@microsoft.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!microsoft!hexnut!jenk
References: <1992Jul29.213404.22198@mnemosyne.cs.du.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.sys.ibm.pc.programmer,alt.msdos.programmer,comp.os.msdos.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!microsoft!hexnut!jenk
From: jenk@microsoft.com (Jen Kilmer)
Subject: Re: DOS Kernel/COMMAND.COM
Message-ID: <1992Aug01.005449.13248@microsoft.com>
Date: 01 Aug 92 00:54:49 GMT
Organization: Microsoft Corporation
References: <1992Jul29.213404.22198@mnemosyne.cs.du.edu>
Sender: jen kilmer
Distribution: usa
Lines: 79