home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / internet / cld9ia27.zip / CLD9IA01.TXT next >
Text File  |  1993-06-13  |  113KB  |  2,339 lines

  1. Archive-name: msdos-programmer-faq/part1
  2. Last modified: 13 June 1993
  3.  
  4.  
  5. This is the FAQ list (Frequently Asked Questions list) for the newsgroup
  6. comp.os.msdos.programmer.  Parts 2 through 4 of this article are posted
  7. as followups in the same thread.  Starting 2 Feb 1993, I mark new and
  8. revised answers with "new:" or "rev:" and the change date.
  9.  
  10. If the posting date shown above is more than four weeks in the past, see
  11. instructions in part 4 of this list for how to get an updated copy.  (A
  12. separate article, posted before this one, holds the changes from the
  13. previous edition.  Look for the subject line "comp.os.msdos.programmer
  14. FAQ diffs".)
  15.  
  16. FAQ lists are intended to reduce the noise level in their newsgroups
  17. that results from the repetition of the same questions, correct answers,
  18. wrong answers, corrections to the wrong answers, corrections to the
  19. corrections, debate, etc.
  20.  
  21. This list should serve as a repository of the canonical "best" answers
  22. to the questions in it.  The names of folks who have helped to improve
  23. this FAQ list follow the table of contents.  If you know a better answer
  24. or even a slight change that improves an answer, please tell me!  (Use
  25. email, please.  Traffic in this group is high, and I may miss a relevant
  26. posted article.)
  27.                       Stan Brown, Oak Road Systems, Cleveland, Ohio, USA
  28.                                                         brown@ncoast.org
  29.  
  30. Search tips
  31. ===========
  32.     To search for specific topics:  See the list of questions in the
  33. Contents section (immediately below) to find which article (part 2, 3,
  34. or 4) you need.  Then, in that part, search for that question number.
  35. For example, while you're reading part 2 of this list, the trn
  36. newsreader command "gQ203" goes to Q203.
  37.     To skip one topic and go to the next:  Search for "Q" starting in
  38. column 1.  In trn and similar newsreaders, the command "g^Q" does that.
  39.     If your newsreader doesn't support searches, you can extract these
  40. articles to a file and use your favorite editor's search commands.
  41.  
  42.  
  43. Contents--part 2 of 4
  44. =====================
  45. section 1. General questions
  46.     101. Why won't my code work?
  47.     102. What is this newsgroup about?
  48.     103. What's the difference from comp.sys.ibm.pc.programmer?
  49.     104. Is comp.os.msdos.programmer available as a mailing list?
  50.     105. What other newsgroups should I know about?
  51. section 2. Compile and link
  52.     201. What the heck is "DGROUP > 64K"?
  53.     202. How do I fix "automatic data segment exceeds 64K" or "stack
  54.          plus data exceed 64K"?
  55.     203. Will Borland C code and Microsoft C code link together?
  56.     204. Why did my program bomb at run time with "floating point
  57.          formats not linked"?
  58.     205. Why did my program bomb with "floating point not loaded"?
  59.     206. How can I change the stack size in Borland's C compilers?
  60.     207. What's the format of an .OBJ file?
  61.     208. What's the format of an .EXE header?
  62.     209. What's the difference between .COM and .EXE formats?
  63. section 3. Keyboard
  64.     301. How can I read a character without echoing it to the screen,
  65.          and without waiting for the user to press the Enter key?
  66.     302. How can I find out whether a character has been typed, without
  67.          waiting for one?
  68.     303. How can I disable Ctrl-C/Ctrl-Break and/or Ctrl-Alt-Del?
  69.     304. How can I disable the print screen function?
  70.     305. How can my program turn NumLock (CapsLock, ScrollLock) on/off?
  71.     306. How can I speed up the keyboard's auto-repeat?
  72.     307. What is the SysRq key for?
  73.     308. How can my program tell what kind of keyboard is on the system?
  74.     309. How can I tell if input, output, or stderr has been redirected?
  75.     310. How can I increase the size of the keyboard buffer?
  76.  
  77.  
  78. Contents--part 3 of 4
  79. =====================
  80. section 4. Disks and files
  81.     401. What drive was the PC booted from?
  82.     402. How can I boot from drive b:?
  83.     403. Which real and virtual disk drives are valid?
  84.     404. How can I make my single floppy drive both a: and b:?
  85.     405. Why won't my C program open a file with a path?
  86.     406. How can I redirect printer output to a file?
  87.     407. How can I redirect the output of a batch file?
  88.     408. How can my program open more files than DOS's limit of 20?
  89.     409. How can I read, create, change, or delete the volume label?
  90.     410. How can I get the disk serial number?
  91.     411. What's the format of .OBJ, .EXE., .COM files?
  92.     412. How can I flush the software disk cache?
  93. section 5. Serial ports (COM ports)
  94.     501. How do I set my machine up to use COM3 and COM4?
  95.     502. How do I find the I/O address of a COM port?
  96.     503. But aren't the COM ports always at I/O addresses 3F8, 2F8, 3E8,
  97.          and 2E8?
  98.     504. How do I configure a COM port and use it to transmit data?
  99. section 6. Other hardware questions and problems
  100.     601. Which 80x86 CPU is running my program?
  101.     602. How can a C program send control codes to my printer?
  102.     603. How can I redirect printer output to a file?
  103.     604. Which video adapter is installed?
  104.     605. How do I switch to 43- or 50-line mode?
  105.     606. How can I find the Microsoft mouse position and button status?
  106.     607. How can I access a specific address in the PC's memory?
  107.     608. How can I read or write my PC's CMOS memory?
  108.     609. How can I access memory beyond 640K?
  109.     610. Where can I find a list of 80x86 opcodes?
  110. section 7. Other software questions and problems
  111.     701. How can a program reboot my PC?
  112.     702. How can I time events with finer resolution than the system
  113.          clock's 55 ms (about 18 ticks a second)?
  114.     703. How can I find the error level of the previous program?
  115.     704. How can a program set DOS environment variables?
  116.     705. How can I change the switch character to - from /?
  117.     706. Why does my interrupt function behave strangely?
  118.     707. How can I write a TSR (terminate-stay-resident) utility?
  119.     708. How can I write a device driver?
  120.     709. What can I use to manage versions of software?
  121.     710. What's this "null pointer assignment" after my C program
  122.          executes?
  123.     711. How can my program tell if it's running under Windows?
  124.     712. How do I copyright software that I write?
  125.  
  126.  
  127. Contents--part 4 of 4
  128. =====================
  129. section A. Downloading
  130.     A01. What are Simtel, garbo, and wustl?
  131.     A02. I have no ftp access.  How can I get files from the archives?
  132.     A03. Can I get archives on CD-ROM?
  133.     A04. Where do I find program <mumble>?
  134.     A05. How can I check Simtel or garbo before I post a request for a
  135.          program?
  136.     A06. How do I download and decode a program I found?
  137.     A07. Where is UUDECODE?
  138.     A08. Why do I get errors when extracting from a ZIP file I
  139.          downloaded?
  140. section B. Vendors and products
  141.     B01. How can I contact Borland?
  142.     B02. How can I contact Microsoft?
  143.     B03. What's the current version of UNZIP?
  144.     B04. What's in Borland Pascal/Turbo Pascal 7.0?
  145.     B05. What's in Microsoft Visual C++?
  146.     B06. Where is Microsoft C 8.0?
  147. section C. More information
  148.     C01. Are there any good on-line references for PC hardware
  149.          components?
  150.     C02. Are there any good on-line references for PC interrupts?
  151.     C03. What and where is "Ralf Brown's interrupt list"?
  152.     C04. Where can I find lex, yacc, and language grammars?
  153.     C05. What's the best book to learn programming?
  154.     C06. Where are FAQ lists archived?
  155.     C07. Where can I get the latest copy of this FAQ list?
  156.     C08. How do I use ftp?
  157.  
  158.  
  159. Acknowledgements
  160. ================
  161. Many articles posted in comp.os.msdos.programmer sparked ideas or
  162. provided information for the first version of this list.  Though I am
  163. responsible for any errors, thanks are due to the following for posted
  164. articles or private email that I used in subsequent editions:  Jamshid
  165. Afshar, Mark Aitchison, Sanjay Aiyagari, George Almasi, Aaron Auseth,
  166. Preston Bannister, Denis Beauregard, Mike Black, Jon Brinkmann, Glynn
  167. Brooks, Paul Brooks, Ralf Brown, Shaun Burnett, Raymond Chen, Alan Drew,
  168. Paul Ducklin, Gary Dueck, Roland Eriksson, Markus Fischer, George
  169. Forsman, Vincent Giovannone, B.Haible, Janos Haide, Klaus Hartnegg, Kris
  170. Heidenstrom, Tom Haapanen, Joel Hoffman, Joe Huffman, Michael Holin,
  171. Mike Iarrobino, Byrial Jensen, Rune Jorgensen, Ajay Kamdar, Everett
  172. Kaser, Jeff Kellam, Jen Kilmer, Reinhard Kirchner, Dave Kirsch, Samuel
  173. Ko, Benjamin Lee, Sidney Markowitz, Jim Marks, Dimitri Matzarakis, Fred
  174. McCall, Ken McKee, Tom Milner, Bill Moore, Duncan Murdoch, Steve Murphy,
  175. Mert Nickerson, David Nugent, John Oldenburg, David Pape, Keith
  176. Petersen, Karl Riedling, Arthur Rubin, Gerald Ruderman, Timo Salmi,
  177. Tapio Sand, John Schmid, Russell Schulz, Ajay Shah, Steve Summit, Tom
  178. Swingle, Anders Thulin, Curt Tilmes, Rick Watkins, Ya-Gui Wei, Joe
  179. Wells, Gregory Youngblood, khill@vax1.umkc.edu
  180.  
  181. New contributors this issue:
  182.  
  183.  
  184. Legalistic stuff
  185. ================
  186. This article is not in the public domain, but it may be redistributed so
  187. long as this notice, the acknowledgements, and the information on
  188. obtaining the latest copy of this list are retained and no fee is
  189. charged.  The code fragments may be used freely; credit would be polite.
  190.  
  191. Copyright (C) 1993  Stan Brown, Oak Road Systems.  All rights reserved.
  192.  
  193. THERE IS NO WARRANTY ON THE CODE.  I have tested all the code included
  194. below, but your machine may not work the same as mine, and my testing
  195. may not be perfect.  (Except where otherwise noted, I tested the code
  196. with both BC++ 2.0 and MSC 5.0.)
  197.  
  198. The mention of particular books or programs must not be construed to
  199. reflect unfavorably on any that are not mentioned.
  200.  
  201.  
  202. (continued in part 2)
  203. -- 
  204. Stan Brown, Oak Road Systems                    brown@Ncoast.ORG
  205.  
  206. Can't find FAQ lists?  ftp to 'rtfm.mit.edu' and look in /pub/usenet
  207. (or email me >>> with valid reply-to address <<< for instructions).
  208. Archive-name: msdos-programmer-faq/part2
  209. Last-modified: 13 June 1993
  210.  
  211. (continued from part 1)         (no warranty on the code or information)
  212.  
  213. If the posting date is more than six weeks in the past, see instructions
  214. at the end of this article for how to get an updated copy.
  215.  
  216. Copyright (C) 1993  Stan Brown, Oak Road Systems.  All rights reserved.
  217.  
  218.  
  219. section 1. General questions
  220. ============================
  221.  
  222. Q101. Why won't my code work?
  223.  
  224.     First you need to try to determine whether the problem is in your
  225.     use of the programming language or in your use of MSDOS and your PC
  226.     hardware.  (Your manual should tell you which features are standard
  227.     and which are vendor- or MSDOS- or PC-specific.  You _have_ read
  228.     your manual carefully, haven't you?)
  229.  
  230.     If the feature that seems to be working wrong is something related
  231.     to your PC hardware or to the internals of MS-DOS, this group is the
  232.     right place to ask.  (Please check this list first, to make sure
  233.     your question isn't already answered.)
  234.  
  235.     On the other hand, if your problem is with the programming language,
  236.     the comp.lang hierarchy (including comp.lang.pascal and comp.lang c)
  237.     is probably a better resource.  Please read the other group's FAQ
  238.     list thoroughly before posting.  (These exist in comp.lang.c,
  239.     comp.lang.c++, comp.lang.modula3, comp.lang.lisp, comp.lang.perl;
  240.     they may exist in other groups as well.)  It's almost never a good
  241.     idea to crosspost between this group and a language group.
  242.  
  243.     Before posting in either place, try to make your program as small as
  244.     possible while still exhibiting the bad behavior.  Sometimes this
  245.     alone is enough to show you where the trouble is.  Also edit your
  246.     description of the problem to be as short as possible.  This makes
  247.     it look more like you tried to solve the problem on your own, and
  248.     makes people more inclined to try to help you.
  249.  
  250.     When you do post a question, it's good manners to say "email please;
  251.     I'll post a summary."  Then everybody else in the group doesn't have
  252.     to read ten virtually identical responses.  Of course, then you have
  253.     to follow through.  A summary is not simply pasting together all the
  254.     email you received.  Instead, write your own (brief) description of
  255.     the solution:  this is the best way to make sure you really
  256.     understand it.  Definitely don't repost people's cute signatures.
  257.  
  258. Q102. What is this newsgroup about?
  259.  
  260.     (rev: 11 Apr 1993) comp.os.msdos.programmer (comp.sys.ibm.pc.programmer
  261.     until September 1990) concerns programming for MS-DOS systems.  The
  262.     article "USENET Readership report for Mar 93" in news.lists shows
  263.     58,000 readers of this newsgroup worldwide.  Traffic was 1543 Kbytes
  264.     (exclusive of crossposts), comprised in 903 articles.
  265.  
  266.     Much of our traffic is about language products (chiefly from Borland
  267.     and Microsoft).  More programming topics focus on C than on any one
  268.     other language.
  269.  
  270.     Since most MS-DOS systems run on hardware that is roughly compatible
  271.     with the IBM PC, on Intel 8088, 80188, or 80x86 chips, we tend to
  272.     get a lot of questions and answers about programming other parts of
  273.     the hardware.
  274.  
  275. Q103. What's the difference from comp.sys.ibm.pc.programmer?
  276.  
  277.     c.s.i.p.programmer is the old name of comp.os.msdos.programmer, and
  278.     has been obsolete since September 1990.  However, many systems have
  279.     not removed the old group, or have removed it but aliased it to the
  280.     new name.  This means that some people still think they're posting
  281.     to c.s.i.p.programmer even though they're actually posting to
  282.     c.o.m.programmer.
  283.  
  284.     You can easily verify the non-existence of c.s.i.p.programmer by
  285.     reference to the "List of Active Newsgroups" posted to news.groups.
  286.     It's available as /pub/usenet/news.answers/active-newsgroups/part1
  287.     from the archives (see "Where are FAQ lists archived?" in section C,
  288.     "More information").
  289.  
  290. Q104. Is comp.os.msdos.programmer available as a mailing list?
  291.  
  292.     (new: 2 Feb 1993)  Sorry, no.
  293.  
  294. Q105. What other newsgroups should I know about?
  295.  
  296.     (rev: 16 Mar 1993) Your best bet is to read the periodic information
  297.     postings in the comp.binaries.ibm.pc newsgroup.  Recommended:
  298.         Starter kit
  299.         Beginner's guide to binaries
  300.     Please wait for these articles to come around; don't post a request.
  301.     Or you can retrieve them from directory of rtfm.mit.edu (see "How do
  302.     I download and decode a program I found?  " in section A,
  303.     "Downloads").
  304.  
  305.     Also check out news.announce.newusers, even if you're not a new
  306.     user.  You may be surprised how much useful information is in the
  307.     monthly postings there.  Lots of old-timers also get useful stuff
  308.     from news.newusers.questions, especially the periodic postings.
  309.  
  310.     Remember that it's good manners to subscribe to any newsgroup and
  311.     read it for a while before you post a question.  When you post, it's
  312.     also good manners to ask for replies to be emailed and then to post
  313.     a summary, which you've edited down to the absolute minimum size.
  314.  
  315.     You may also be interested in the following newsgroups.  Caution:
  316.     Some of them have specialized charters; you'll probably get (and
  317.     deserve) some flames if you post to an inappropriate group.
  318.  
  319.     - misc.forsale.computers.d and misc.forsale.computers.pc-clone are
  320.       where you post notices of equipment, software, or computer books
  321.       that you want to sell.  Please don't post or crosspost those
  322.       notices to comp.os.msdos.programmer.
  323.  
  324.     - comp.os.ms-windows.programmer.tools and ...misc (formerly part of
  325.       comp.windows.ms.programmer):  Similar to this group, but focus
  326.       on programming for the MS-Windows platform.
  327.  
  328.     - comp.sys.ibm.pc.hardware is for more hardware-oriented discussions
  329.       of the machines that run DOS.
  330.  
  331.     - comp.binaries.ibm.pc.wanted: AFTER you have looked in the other
  332.       groups, this is the place to post a request for a particular
  333.       binary program.
  334.  
  335.     - comp.archives.msdos.announce (moderated) explains how to use the
  336.       archive sites, especially garbo and Simtel, and lists files
  337.       uploaded to them.  Discussions belong in comp.archives.msdos.d,
  338.       which replaced comp.binaries.ibm.pc.archives.
  339.  
  340.     - comp.binaries.ibm.pc.d is for discussions about programs posted in
  341.       comp.binaries.ibm.pc, and only those programs.  This is a good
  342.       place to report bugs in the programs, but not to ask where to find
  343.       them (see cbip.wanted, above).  cbip.d is NOT supposed to be a
  344.       general PC discussion group.
  345.  
  346.     - comp.sources.misc: a moderated group for source code for many
  347.       computer systems.  It tends to get lots of Unix stuff, but you may
  348.       also pick up some DOS-compatible code here.
  349.  
  350.     - alt.sources: an unmoderated group for source code.  Guidelines are
  351.       posted periodically.
  352.  
  353.     - Turbo Vision is a mailing list, not a newsgroup; send email to
  354.       listserv@vtvm1.cc.vt.edu if you want to subscribe.
  355.  
  356. section 2. Compile and link
  357. ===========================
  358.  
  359. Q201. What the heck is "DGROUP > 64K"?
  360.  
  361.     (rev: 18 Apr 1993) DGROUP is a link-time group of data segments, and
  362.     the compiler typically generates code that expects DS to be pointing
  363.     to DGROUP.  (Exception:  Borland's huge model has no DGROUP.)
  364.  
  365.     Here's what goes into DGROUP:
  366.  
  367.     - tiny model (all pointers near):  DGROUP holds the entire program.
  368.  
  369.     - small and medium models (data pointers near):  DGROUP holds all
  370.       globals and static variables including string literals, plus the
  371.       stack and the heap.
  372.  
  373.     - large, compact, and huge models in Microsoft (data pointers far):
  374.       DGROUP holds only initialized globals and static variables
  375.       including string literals, plus the stack and the near heap.
  376.  
  377.     - large and compact models in Borland (data pointers far): DGROUP
  378.       holds initialized and uninitialized globals and static variables
  379.       including string literals, but not the stack or heap.
  380.  
  381.     - huge model in Borland (data pointers far): there is no DGROUP, so
  382.       the 64K limit doesn't apply.
  383.  
  384.     In all of the above, which is to say all six models in Microsoft C
  385.     and all but huge in Borland C, DGROUP is limited to 64K including
  386.     string literals (which are treated as static data).  This limitation
  387.     is due to the Intel CPU's segmented architecture.
  388.  
  389.     See the next Q for possible remedies.
  390.  
  391.     For more information, see topics like "memory models" and "memory
  392.     management" in the index of your compiler manual.  Also see
  393.     ti738.asc, downloadable as part of
  394.         pd1:<msdos.turbo-c>bchelp10.zip at Simtel
  395.         /pc/turbopas/bchelp10.zip at garbo,
  396.     for an extended general discussion of memory usage in Borland C
  397.     programs, of which much applies to any C compiler in DOS.
  398.  
  399. Q202. How do I fix "automatic data segment exceeds 64K" or "stack plus
  400.       data exceed 64K"?
  401.  
  402.     These messages are a variation of "DGROUP > 64K".  For causes,
  403.     please see the preceding Q.
  404.  
  405.     If you get this error in tiny model, your program is simply too big
  406.     and you must use a different memory model.  If you get this link
  407.     error in models S, C, M, L, or Microsoft's H, there are some things
  408.     you can do.  (This error can't occur in Borland's huge model.)
  409.  
  410.     If you have one or two big global arrays, simply declare them far.
  411.     The compiler takes this to mean that any references to them will use
  412.     32-bit pointers, so they'll be in separate segments and no longer
  413.     part of DGROUP.
  414.  
  415.     Or you can use the /Gt[number] option with Microsoft or -Ff[=size]
  416.     with Borland C++ 2.0 and up.  This will automatically put variables
  417.     above a certain size into their own segments outside of DGROUP.
  418.  
  419.     Yet another option is to change global arrays to far pointers.  Then
  420.     at the beginning of your program, allocate them from the far heap
  421.     (_fmalloc in Microsoft, farmalloc in Borland).
  422.  
  423.     Finally, you can change to huge model (with Borland compilers, not
  424.     Microsoft).  Borland's H model still uses far pointers by default,
  425.     but "sets aside the [64K] limit" and has no DGROUP group, according
  426.     to the BC++ 2.0 Programmer's Guide.  Microsoft's H model does use
  427.     huge data pointers by default but retains DGROUP and its 64K limit,
  428.     so switching to the H model doesn't buy you anything if you have
  429.     DGROUP problems.
  430.  
  431. Q203. Will Borland C code and Microsoft C code link together?
  432.  
  433.     (rev: 13 Feb 1993) Typically this question is asked by someone who
  434.     owns compiler A and is trying to write code to link with a
  435.     third-party library that was compiled under compiler B.
  436.  
  437.     The answer to the question is, Not in general.  Here are some of the
  438.     reasons:
  439.  
  440.     - "Helper" functions (undocumented functions for stack checking,
  441.       floating-point arithmetic, and operations on longs) differ between
  442.       the two compilers.
  443.  
  444.     - The compilers may embed instructions in the object code that tell
  445.       the linker to look for their own run-time libraries.  You can use
  446.       the linker option that says to ignore such instructions:  /n in
  447.       TLINK, /NOD in the Microsoft linker (the one that comes with the C
  448.       compiler, not the one that used to come with DOS).  But getting
  449.       around this problem will very likely just reveal other problems,
  450.       like different helper functions, that have no easy solution.
  451.  
  452.     Those problems will generate link-time errors.  Others may not show
  453.     up until run time:
  454.  
  455.     - Borland's compact, large, and huge models don't assume DS=SS, but
  456.       Microsoft's do.  The -Fs option on the Borland compiler, or one of
  457.       the /A options on Microsoft, should take care of this problem --
  458.       once you know that's what's going on.
  459.  
  460.     - Check conventions for ordering and packing structure members, and
  461.       for alignment of various types on byte, word, paragraph, or other
  462.       boundaries.  Again, you can generally adjust your code to match if
  463.       you know what conventions were used in compiling the "foreign"
  464.       libraries.
  465.  
  466.     - Check the obvious and make sure that your code was compiled under
  467.       the same memory model as the code you're trying to link with.
  468.       (That's necessary, but no guarantee.  Microsoft and Borland don't
  469.       use exactly the same conventions for segments and groups,
  470.       particularly in the larger memory models.)
  471.  
  472.     That said, there are some circumstances where you can link hybrids.
  473.     Your best chance of success comes if you avoid longs and floating
  474.     point, use only 16-bit pointers, suppress stack checking, and
  475.     specify all libraries used in the link.
  476.  
  477. Q204. Why did my program bomb at run time with "floating point formats
  478.       not linked"?
  479.  
  480.     First, is that the actual message, or did it say "floating point not
  481.     loaded"?  If it was the latter, see the next Q.
  482.  
  483.     You're probably using a Borland compiler for C or C++ (including
  484.     Turbo C and Turbo C++).  Borland's compilers try to be smart and not
  485.     link in the floating-point (f-p) library unless you need it.  Alas,
  486.     they all get the decision wrong.  One common case is where you don't
  487.     call any f-p functions, but you have %f or other f-p formats in
  488.     scanf/printf calls.  The cure is to call an f-p function, or at
  489.     least force one to be present in the link.
  490.  
  491.     To do that, define this function somewhere in a source file but
  492.     don't call it:
  493.  
  494.         static void forcefloat(float *p)
  495.             { float f = *p; forcefloat(&f); }
  496.  
  497.     It doesn't have to be in the module with the main program, as long
  498.     as it's in a module that will be included in the link.
  499.  
  500.     If you have Borland C++ 3.0, the README file documents a slightly
  501.     less ugly work-around.  Insert these statements in your program:
  502.  
  503.         extern unsigned _floatconvert;
  504.         #pragma extref _floatconvert
  505.  
  506. Q205. Why did my program bomb with "floating point not loaded"?
  507.  
  508.     That is Microsoft C's run-time message when the code requires a
  509.     numeric coprocessor but your computer doesn't have one installed.
  510.  
  511.     If the program is yours, relink it using the xLIBCE or xLIBCA
  512.     library (where x is the memory model).
  513.  
  514. Q206. How can I change the stack size in Borland's C compilers?
  515.  
  516.     In Turbo C, Turbo C++, and Borland C++, you may not find "stack
  517.     size" in the index but the global variable _stklen should be there.
  518.     The manual will instruct you to put a statement like
  519.  
  520.         extern unsigned _stklen = 54321U;
  521.  
  522.     in your code, outside of any function.  You must assign the value
  523.     right in the extern statement; it won't work to assign a value at
  524.     run time.  (The "extern" in this context isn't ANSI C and ought not
  525.     to be required, but the above statement is a direct quote from the
  526.     Library Reference manual of Borland C++ 2.0.)  The linker may give
  527.     you a duplicate symbol warning, which you can ignore.
  528.  
  529. Q207. What's the format of an .OBJ file?
  530.  
  531.     (rev: 1 May 1993) Here's what I've been told.  I have verified the
  532.     references marked "(verified)".
  533.  
  534.     - base .OBJ format:  Intel's document number #121748-001, {8086
  535.       Relocatable Object Module Formats}.  (Both Microsoft and Borland
  536.       have extended the .OBJ format, as has IBM for OS/2; and according
  537.       to the MS-DOS encyclopedia, Microsoft doesn't actually use all the
  538.       listed formats.)
  539.  
  540.     - Microsoft-specific .OBJ formats:  a 45-page article in the {MS-DOS
  541.       Encyclopedia}, ISBN 1-55615-049-0 (verified).  I am told there is
  542.       also a "Microsoft Object Module Format (OMF)" Specification,
  543.       printed 22 Nov 1991, from the Microsoft Languages Group.
  544.  
  545.     - Microsoft publishes an .OBJ spec in Windows help format (266K
  546.       after unzipping).  I'm not sure why it's in Windows help format,
  547.       since it's one long document without hypertex links.  Download it
  548.       as /vendor/microsoft/developer-network/ctech/11-9.zip from
  549.       ftp.uu.net (verified).
  550.  
  551.     - Borland-specific .OBJ formats:  Open Architecture Handbook.  The
  552.       Borland Developer's Technical Guide, 1991, no ISBN.  Chapter 2,
  553.       "Object file contents", (pages 27-50) covers the comment records
  554.       sent to the object file by Borland C++ version 3.0 and other
  555.       Borland compilers.  The comment records mostly contain information
  556.       for the Borland debugger.
  557.  
  558.     - A "tutorial on the .OBJ format" comes with the VAL experimental
  559.       linker, downloadable as pd1:<msdos.pgmutl>val-link.arc at Simtel.
  560.  
  561. Q208. What's the format of an .EXE header?
  562.  
  563.     See pages 349-350 of {PC Magazine}'s 30 June 1992 issue (xi:12) for
  564.     the old and new formats.  For a more detailed layout, look under INT
  565.     21 function 4B in Ralf Brown's interrupt list.  Ralf Brown's list
  566.     includes extensions for Borland's TLINK and Borland debugger info.
  567.  
  568.     Among the books that detail formats of executable files are {DOS
  569.     Programmer's Reference: 2d Edition} by Terry Dettman and Jim Kyle,
  570.     ISBN 0-88022-458-4; and {Microsoft MS-DOS Programmer's Reference},
  571.     ISBN 1-55615-329-5.
  572.  
  573. Q209. What's the difference between .COM and .EXE formats?
  574.  
  575.     To oversimplify:  a .COM file is a direct image of core, and an .EXE
  576.     file will undergo some further relocation when it is run (and so it
  577.     begins with a relocation header).  A .COM file is limited to 64K for
  578.     all segments combined, but an .EXE file can have as many segments as
  579.     your linker will handle and be as large as RAM can take.
  580.  
  581.     The actual file extension doesn't matter.  DOS knows that a file
  582.     being loaded is in .EXE format if its first two bytes are MZ or ZM;
  583.     otherwise it is assumed to be in .COM format.  For instance, I am
  584.     told that DR-DOS 6.0's COMMAND.COM is in .EXE format.
  585.  
  586. section 3. Keyboard
  587. ===================
  588.  
  589. Q301. How can I read a character without echoing it to the screen, and
  590.       without waiting for the user to press the Enter key?
  591.  
  592.     The C compilers from Microsoft and Borland offer getch (or getche to
  593.     echo the character); Turbo Pascal has ReadKey.
  594.  
  595.     In other programming languages, load 8 in register AH and execute
  596.     INT 21; AL is returned with the character from standard input
  597.     (possibly redirected).  If you don't want to allow redirection, or
  598.     you want to capture Ctrl-C and other special keys, use INT 16 with
  599.     AH=10; this will return the scan code in AH and ASCII code (if
  600.     possible) in AL, except that AL=E0 with AH nonzero indicates one of
  601.     the grey "extended" keys was pressed.  (If your BIOS doesn't
  602.     support the extended keyboard, use INT 16 function 0 not 10.)
  603.  
  604. Q302. How can I find out whether a character has been typed, without
  605.       waiting for one?
  606.  
  607.     In Turbo Pascal, use KeyPressed.  Both Microsoft C and Turbo C offer
  608.     the kbhit( ) function.  All of these tell you whether a key has been
  609.     pressed.  If no key has been pressed, they return that information
  610.     to your program.  If a keystroke is waiting, they tell your program
  611.     that but leave the key in the input buffer.
  612.  
  613.     You can use the BIOS call, INT 16 function 01 or 11, to check
  614.     whether an actual keystroke is waiting; or the DOS call, INT 21
  615.     function 0B, to check for a keystroke from stdin (subject to
  616.     redirection).  See Ralf Brown's interrupt list.
  617.  
  618. Q303. How can I disable Ctrl-C/Ctrl-Break and/or Ctrl-Alt-Del?
  619.  
  620.     (rev: 18 Apr 1993)  Several utilities are downloadable from
  621.     pd1:<msdos.keyboard> at Simtel.  In that directory, cadel.zip
  622.     contains a TSR (with source code) to disable those keys.  Also,
  623.     keykill.arc contains two utilities:  keykill.com lets you disable up
  624.     to three keys of your choice, and deboot.com changes the boot key to
  625.     leftShift-Alt-Del.
  626.  
  627.     C programmers who simply want to make sure that the user can't
  628.     Ctrl-Break out of their program can use the ANSI-standard signal( )
  629.     function; the Borland compilers also offer ctrlbrk( ) for handling
  630.     Ctrl-Break.  However, if your program uses normal DOS input, the
  631.     characters ^C will appear on the screen when the user presses Ctrl-C
  632.     or Ctrl-Break.  There are many ways to work around that, including:
  633.     use INT 21 function 7, which allows redirection but doesn't display
  634.     the ^C (or echo any other character, for that matter); or use INT 16
  635.     function 0 or 10; or call _bios_keybrd( ) in MSC or bioskey( ) in
  636.     BC++; or hook INT 9 to discard Ctrl-C and Ctrl-Break before the
  637.     regular BIOS keyboard handler sees them; etc., etc.
  638.  
  639.     You should be aware that Ctrl-C and Ctrl-Break are processed quite
  640.     differently internally.  Ctrl-Break, like all keystrokes, is
  641.     processed by the BIOS code at INT 9 as soon as the user presses the
  642.     keys, even if earlier keys are still in the keyboard buffer:  by
  643.     default the handler at INT 1B is called.  Ctrl-C is not special to
  644.     the BIOS, nor is it special to DOS functions 6 and 7; it _is_
  645.     special to DOS functions 1 and 8 when at the head of the keyboard
  646.     buffer.  You will need to make sure BREAK is OFF to prevent DOS
  647.     polling the keyboard for Ctrl-C during non-keyboard operations.
  648.  
  649.     Some good general references are {Advanced MS-DOS} by Ray Duncan,
  650.     ISBN 1-55615-157-8; {8088 Assembler Language Programming:  The IBM
  651.     PC}, ISBN 0-672-22024-5, by Willen & Krantz; and {COMPUTE!'s Mapping
  652.     the IBM PC}, ISBN 0-942386-92-2.
  653.  
  654. Q304. How can I disable the print screen function?
  655.  
  656.     There are really two print screen functions:  1) print current
  657.     screen snapshot, triggered by PrintScreen or Shift-PrtSc or
  658.     Shift-grey*, and 2) turn on continuous screen echo, started and
  659.     stopped by Ctrl-P or Ctrl-PrtSc.
  660.  
  661.     1) Screen snapshot to printer
  662.  
  663.     The BIOS uses INT 5 for this.  Fortunately, you don't need to mess
  664.     with that interrupt handler.  The standard handler, in BIOSes dated
  665.     December 1982 or later, uses a byte at 0040:0100 (alias 0000:0500)
  666.     to determine whether a print screen is currently in progress.  If it
  667.     is, pressing PrintScreen again is ignored.  So to disable the screen
  668.     snapshot, all you have to do is write a 1 to that byte.  When the
  669.     user presses PrintScreen, the BIOS will think that a print screen is
  670.     already in progress and will ignore the user's keypress.  You can
  671.     re-enable PrintScreen by zeroing the same byte.
  672.  
  673.     Here's some simple code:
  674.  
  675.         void prtsc_allow(int allow) /* 0=disable, nonzero=enable */ {
  676.             unsigned char far* flag = (unsigned char far*)0x00400100UL;
  677.             *flag = (unsigned char)!allow;
  678.         }
  679.  
  680.     2) Continuous echo of screen to printer
  681.  
  682.     If ANSI.SYS is loaded, you can easily disable the continuous echo of
  683.     screen to printer (Ctrl-P or Ctrl-PrtSc).  Just redefine the keys by
  684.     "printing" strings like these to the screen (BASIC print, C printf,
  685.     Pascal Write statements, or ECHO command in batch files):
  686.  
  687.         <27>[0;114;"Ctrl-PrtSc disabled"p
  688.         <27>[16;"^P"p
  689.  
  690.     Change <27> in the above to an Escape character, ASCII 27.
  691.  
  692.     If you haven't installed ANSI.SYS, I can't offer an easy way to
  693.     disable the echo-screen-to-printer function.  Please send any tested
  694.     solutions to brown@ncoast.org and I'll add them to this list.
  695.  
  696.     Actually, you might not need to disable Ctrl-P and Ctrl-PrtSc.  If
  697.     your only concern is not locking up your machine, when you see the
  698.     "Abort, Retry, Ignore, Fail" prompt just press Ctrl-P again and then
  699.     I.  As an alternative, install one of the many print spoolers that
  700.     intercept printer-status queries and always return "Printer ready".
  701.  
  702. Q305. How can my program turn NumLock (CapsLock, ScrollLock) on or off?
  703.  
  704.     First, if you just don't want NumLock turned on when you reboot,
  705.     check your system's setups.  (Use Ctrl-Alt-Enter any time, or press
  706.     a special key like Del at boot time, or run the setup program
  707.     supplied with your system.)  Many systems now have an option in
  708.     setup to turn NumLock off at boot time.
  709.  
  710.     You need to twiddle bit 5, 6, or 4 of location 0040:0017.  Here's
  711.     some code:  lck( ) turns on a lock state, and unlck( ) turns it off.
  712.     (The status lights on some keyboards may not reflect the change.  If
  713.     yours is one, call INT 16 function 2, "get shift status", and that
  714.     may update them.  It will certainly do no harm.)
  715.  
  716.         #define NUM_LOCK  (1 << 5)
  717.         #define CAPS_LOCK (1 << 6)
  718.         #define SCRL_LOCK (1 << 4)
  719.         void lck(int shiftype) {
  720.             char far* kbdstatus = (char far*)0x00400017UL;
  721.             *kbdstatus |= (char)shiftype;
  722.         }
  723.         void unlck(int shiftype) {
  724.             char far* kbdstatus = (char far*)0x00400017UL;
  725.             *kbdstatus &= ~(char)shiftype;
  726.         }
  727.  
  728. Q306. How can I speed up the keyboard's auto-repeat?
  729.  
  730.     The keyboard speed has two components: delay (before a key that you
  731.     hold down starts repeating) and typematic rate (the speed once the
  732.     key starts repeating).  Most BIOSes since 1986 let software change
  733.     the delay and typematic rate by calling INT 16 function 3, "set
  734.     typematic rate and delay"; see Ralf Brown's interrupt list.  If you
  735.     have DOS 4.0 or later, you can use the MODE CON command that you'll
  736.     find in your DOS manual.
  737.  
  738.     On 83-key keyboards (mostly XTs), the delay and typematic rate can't
  739.     easily be changed.  According to the {PC Magazine} of 15 Jan 1991,
  740.     page 409, to adjust the typematic rate you need "a memory-resident
  741.     program which simply '[watches]' the keyboard to see if you're
  742.     holding down a key ... and after a certain time [starts] stuffing
  743.     extra copies of the held-down key into the buffer."  No source code
  744.     is given in that issue; but I'm told that the QUICKEYS utility that
  745.     {PC} published in 1986 does this sort of watching; source and object
  746.     code are downloadable in pd1:<msdos.pcmag>vol5n05.arc from Simtel.
  747.  
  748. Q307. What is the SysRq key for?
  749.  
  750.     There is no standard use for the key.  The BIOS keyboard routines in
  751.     INT 16 simply ignore it; therefore so do the DOS input routines in
  752.     INT 21 as well as the keyboard routines in libraries supplied with
  753.     high-level languages.
  754.  
  755.     When you press or release a key, the keyboard triggers hardware line
  756.     IRQ1, and the CPU calls INT 9.  INT 9 reads the scan code from the
  757.     keyboard and the shift states from the BIOS data area.
  758.  
  759.     What happens next depends on whether your PC's BIOS supports an
  760.     enhanced keyboard (101 or 102 keys).  If so, INT 9 calls INT 15
  761.     function 4F to translate the scan code.  If the translated scan code
  762.     is 54 hex (for the SysRq key) then INT 9 calls INT 15 function 85
  763.     and doesn't put the keystroke into the keyboard buffer.  The default
  764.     handler of that function does nothing and simply returns.  (If your
  765.     PC has an older BIOS that doesn't support the extended keyboards,
  766.     INT 15 function 4F is not called.  Early ATs have 84-key keyboards,
  767.     so their BIOS calls INT 15 function 85 but nor 4F.)
  768.  
  769.     Thus your program is free to use SysRq for its own purposes, but at
  770.     the cost of some programming.  You could hook INT 9, but it's
  771.     probably easier to hook INT 15 function 85, which is called when
  772.     SysRq is pressed or released.
  773.  
  774. Q308. How can my program tell what kind of keyboard is on the system?
  775.  
  776.     Ralf Brown's Interrupt List includes MEMORY.LST, a detailed
  777.     breakdown by Robin Walker of the contents of the BIOS system block
  778.     that starts at 0040:0000.  Bit 4 of byte 0040:0096 is "1=enhanced
  779.     keyboard installed".  C code to test the keyboard type:
  780.         char far *kbd_stat_byte3 = (char far *)0x00400096UL;
  781.         if (0x10 & *kbd_stat_byte3)
  782.             /* 101- or 102-key keyboard is installed */
  783.  
  784.     {PC Magazine}'s 15 Jan 1991 issue suggests on page 412 that "for
  785.     some clones [the above test] is not foolproof".  If you use this
  786.     method in your program you should provide the user some way to
  787.     override this test, or at least some way to tell your program to
  788.     assume a non-enhanced keyboard.  The {PC Magazine} article suggests
  789.     a different approach to determining the type of keyboard.
  790.  
  791. Q309. How can I tell if input, output, or stderr has been redirected?
  792.  
  793.     (rev: 13 June 1993)  Normally, input and output are associated with
  794.     the console (i.e., with the keyboard and the screen, respectively).
  795.     If either is not, you know that it has been redirected.  Some source
  796.     code to check this is available at the usual archive sites.
  797.  
  798.     If you program in Turbo Pascal, you'll want this downloadable
  799.     collection of Turbo Pascal units:
  800.         /pc/ts/tspa32*.zip at garbo
  801.         pd1:<msdos.turbopas>tspa32*.zip at Simtel.
  802.     (where the * is 70, 60, 55, 50, or 40 for Turbo Pascal 6.0, 5.5,
  803.     5.0, or 4.0 respectively.) Source code is not included.  Also see
  804.     the downloadable Frequently Asked Questions files by Timo Salmi:
  805.         /pc/ts/tsfaqp12.zip at garbo
  806.         pd1:<msdos.info>tafaqp12.zip at Simtel.
  807.  
  808.     If you program in C, use isatty( ) if your implementation has it.
  809.     Otherwise, pd1:<msdos.sysutl>is_con10.zip is downloadable from
  810.     Simtel; it includes source code.
  811.  
  812.     Good references for the principles are {PC Magazine} 16 Apr 1991
  813.     (vol 10 nr 7) pg 374; Ray Duncan's {Advanced MS-DOS}, ISBN
  814.     1-55615-157-8, or Ralf Brown's interrupt list for INT 21 function
  815.     4400; and Terry Dettman and Jim Kyle's {DOS Programmer's Reference:
  816.     2d edition}, ISBN 0-88022-458-4, pp 602-603.
  817.  
  818. Q310. How can I increase the size of the keyboard buffer?
  819.  
  820.     (new: 9 May 1993)  I have tested only one of the many available
  821.     device drivers that do this.  That one has performed flawlessly for
  822.     me in almost two years of use with MS-DOS 5 and Windows 3.1.  It
  823.     extends the keyboard buffer to 160 characters; it's downloadable as
  824.         pd1:<msdos.keyboard>buf160_6.zip at Simtel.
  825.  
  826. (continued in part 3)
  827. -- 
  828. Stan Brown, Oak Road Systems                    brown@Ncoast.ORG
  829.  
  830. Can't find FAQ lists?  ftp to 'rtfm.mit.edu' and look in /pub/usenet
  831. (or email me >>> with valid reply-to address <<< for instructions).
  832. Archive-name: msdos-programmer-faq/part3
  833. Last-modified: 13 June 1993
  834.  
  835.  
  836. (continued from part 2)         (no warranty on the code or information)
  837.  
  838. If the posting date is more than six weeks in the past, see instructions
  839. in part 4 of this list for how to get an updated copy.
  840.  
  841. Copyright (C) 1993  Stan Brown, Oak Road Systems.  All rights reserved.
  842.  
  843.  
  844. section 4.  Disks and files
  845. ===========================
  846.  
  847. Q401. What drive was the PC booted from?
  848.  
  849.     Under DOS 4.0 or later, load 3305 hex into AX; do an INT 21.  DL is
  850.     returned with an integer indicating the boot drive (1=A:, etc.).
  851.  
  852. Q402. How can I boot from drive b:?
  853.  
  854.     (rev: 18 Apr 1993)  Downloadable shareware:
  855.         pd1:<msdos.dskutl>boot_b.zip from Simtel
  856.         /pc/bootutil/boot_b.zip from garbo.
  857.     The included documentation says it works by writing a new boot
  858.     sector on a disk in your a: drive that redirects the boot to your
  859.     b: drive.
  860.  
  861.     If that doesn't work, you can always interchange your a: and b:
  862.     drives by switching ribbon cables and changing the setup in your
  863.     BIOS.  From an article posted 27 Jan 1993 on another newsgroup:
  864.  
  865.     Take the "ribbon" connector, as you call it, and switch them.  To
  866.     double check, start at the end of the cable that connects to the
  867.     motherboard or floppy controller.  Follow the cable until you get to
  868.     the first connector.  Connect this to the drive you want to be b:.
  869.     After this, there should be a few lines on the cable that get
  870.     flipped left to right.  (On most cables, they just cut the lines and
  871.     physically reverse them.  It should be quite obvious from looking at
  872.     the cable.)  Anyway, the connector after the pins get flipped
  873.     right to left is the connector for your a: drive.
  874.  
  875. Q403. Which real and virtual disk drives are valid?
  876.  
  877.     Use INT 21 function 29 (parse filename).  Point DS:SI at a null-
  878.     terminated ASCII string that contains the drive letter and a colon,
  879.     point ES:DI at a 37-byte dummy FCB buffer, set AX to 2900h, and do
  880.     an INT 21.  On return, AL is FF if the drive is invalid, something
  881.     else if the drive is valid.  RAM disks and SUBSTed drives are
  882.     considered valid.
  883.  
  884.     Unfortunately, the b: drive is considered valid even on a single-
  885.     diskette system.  You can check that special case by interrogating
  886.     the BIOS equipment byte at 0040:0010.  Bits 7-6 contain the one less
  887.     than the number of diskette drives, so if those bits are zero you
  888.     know that b: is an invalid drive even though function 29 says it's
  889.     valid.
  890.  
  891.     Following is some code originally posted by Doug Dougherty, with my
  892.     fix for the b: special case, tested only in Borland C++ 2.0 (in
  893.     the small model):
  894.  
  895.         #include <dos.h>
  896.         void drvlist(void)  {
  897.             char *s = "A:", fcb_buff[37];
  898.             int valid;
  899.             for (   ;  *s<='Z';  (*s)++) {
  900.                 _SI = (unsigned) s;
  901.                 _DI = (unsigned) fcb_buff;
  902.                 _ES = _DS;
  903.                 _AX = 0x2900;
  904.                 geninterrupt(0x21);
  905.                 valid = _AL != 0xFF;
  906.                 if (*s == 'B'  &&  valid) {
  907.                     char far *equipbyte = (char far *)0x00400010UL;
  908.                     valid = (*equipbyte & (3 << 6)) != 0;
  909.                 }
  910.                 printf("Drive '%s' is %sa valid drive.\n",
  911.                         s, valid ? "" : "not ");
  912.             }
  913.         }
  914.  
  915. Q404. How can I make my single floppy drive both a: and b:?
  916.  
  917.     Under any DOS since DOS 2.0, you can put the command
  918.  
  919.         assign b=a
  920.  
  921.     into your AUTOEXEC.BAT file.  Then, when you type "DIR B:" you'll no
  922.     longer get the annoying prompt to insert diskette B (and the even
  923.     more annoying prompt to insert A the next time you type "DIR A:").
  924.  
  925.     You may be wondering why anybody would want to do this.  Suppose you
  926.     use two different machines, maybe one at home and one at work.  One
  927.     of them has only a 3.5" diskette drive; the other machine has two
  928.     drives, and b: is the 3.5" one.  You're bound to type "dir b:" on
  929.     the first one, and get the nuisance message
  930.  
  931.         Insert diskette for drive B: and press any key when ready.
  932.  
  933.     But if you assign drive b: to point to a:, you avoid this problem.
  934.  
  935.     Caution:  there are a few commands, such as DISKCOPY, that will not
  936.     work right on ASSIGNed or SUBSTed drives.  See the DOS manual for
  937.     the full list.  Before typing one of those commands, be sure to turn
  938.     off the mapping by typing "assign" without arguments.
  939.  
  940.     The DOS 5.0 manual says that ASSIGN is obsolete, and recommends the
  941.     equivalent form of SUBST: "subst b: a:\".  Unfortunately, if this
  942.     command is executed when a: doesn't hold a diskette, the command
  943.     fails.  ASSIGN doesn't have this problem, so I must advise you to
  944.     disregard that particular bit of advice in the DOS manual.
  945.  
  946. Q405. Why won't my C program open a file with a path?
  947.  
  948.     You've probably got something like the following code:
  949.  
  950.         char *filename = "c:\foo\bar\mumble.dat";
  951.         . . .  fopen(filename, "r");
  952.  
  953.     The problem is that \f is a form feed, \b is a backspace, and \m is
  954.     m.  Whenever you want a backslash in a string constant in C, you
  955.     must use two backslashes:
  956.  
  957.         char *filename = "c:\\foo\\bar\\mumble.dat";
  958.  
  959.     This is a feature of every C compiler, because Dennis Ritchie
  960.     designed C this way.  It's a problem only on MS-DOS systems, because
  961.     only DOS (and Atari ST/TT running TOS, I'm told) uses the backslash
  962.     in directory paths.  But even in DOS this backslash convention
  963.     applies _only_ to string constants in your source code.  For file
  964.     and keyboard input at run time, \ is just a normal character, so
  965.     users of your program would type in file specs at run time the same
  966.     way as in DOS commands, with single backslashes.
  967.  
  968.     Another possibility is to code all paths in source programs with /
  969.     rather than \ characters:
  970.  
  971.         char *filename = "c:/foo/bar/mumble.dat";
  972.  
  973.     Ralf Brown writes that "All versions of the DOS kernel accept either
  974.     forward or backslashes as directory separators.  I tend to use this
  975.     form more frequently than backslashes since it is easier to type and
  976.     read."  This applies to DOS function calls (and therefore to calls
  977.     to the file library of every programming language), but not to DOS
  978.     commands.
  979.  
  980. Q406. How can I redirect printer output to a file?
  981.  
  982.     (rev: 18 Apr 1993)  My personal favorite utility for this purpose is
  983.     PRN2FILE from {PC Magazine}, downloadable as:
  984.         pd1:<msdos.printer>prn2file.arc at Simtel
  985.         /pc/printer/prn2file.zip at garbo.
  986.     {PC Magazine} has given copies away as part of its utilities disks,
  987.     so you may already have a copy.
  988.  
  989.     The directories mentioned above have lots of other utilities to
  990.     redirect printer output.
  991.  
  992. Q407. How can I redirect the output of a batch file?
  993.  
  994.     (new: 12 June 1993) Assuming the batch file is called batch.bat, to
  995.     send its output (stdout) to another file, just invoke COMMAND.COM as
  996.     a secondary command processor:
  997.  
  998.         command /c batch parameters_if_any >outfile
  999.  
  1000.     Timo Salmi's notes on this and other batch tricks are downloadable:
  1001.         pd1:<msdos.batutl>tsbat43.zip at Simtel
  1002.         /pc/ts/tsbat43.zip at garbo.
  1003.  
  1004. Q408. How can my program open more files than DOS's limit of 20?
  1005.  
  1006.     (rev: 1 May 1993.  This is a summary of an article Ralf Brown posted
  1007.     on 8 August 1992, with some additions from a Microsoft tech note.)
  1008.  
  1009.     There are separate limits on files and file handles.  For example,
  1010.     DOS opens three files but five file handles:  CON (stdin, stdout,
  1011.     and stderr), AUX (stdaux), and PRN (stdprn).
  1012.  
  1013.     The limit in FILES= in CONFIG.SYS is a system-wide limit on files
  1014.     opened by all programs (including the three that DOS opens and any
  1015.     opened by TSRs); each process has a limit of 20 handles (including
  1016.     the five that DOS opens).  Example:  CONFIG.SYS has FILES=40.  Then
  1017.     program #1 will be able to open 15 file handles.  Assuming that the
  1018.     program actually does open 15 handles pointing to 15 different
  1019.     files, other programs could still open a total of 22 files (40-3-15
  1020.     = 22), though no one program could open more than 15 file handles.
  1021.  
  1022.     If you're running DOS 3.3 or later, you can increase the per-process
  1023.     limit of 20 file handles by a call to INT 21 function 67, Set Handle
  1024.     Count.  Your program is still limited by the system-wide limit on
  1025.     open files, so you may also need to increase the FILES= value in
  1026.     your CONFIG.SYS file (and reboot).  The run-time library that you're
  1027.     using may have a fixed-size table of file handles, so you may also
  1028.     need to get source code for the module that contains the table,
  1029.     increase the table size, and recompile it.
  1030.  
  1031.     In Microsoft C the run-time library limits you to 20 file handles.
  1032.     To change this, you must be aware of two limits:
  1033.  
  1034.     - file handles used with _open( ), _read( ), etc.: Edit _NFILE_ in
  1035.       CRT0DAT.ASM.
  1036.  
  1037.     - stream files used with fopen( ), fread( ), etc.: Edit _NFILE_ in
  1038.       _FILE.C for DOS or FILE.ASM for Windows/QuickWin.  This must not
  1039.       exceed the value of _NFILE_ in CRT0DAT.ASM.
  1040.  
  1041.     (QuickWin uses the constant _WFILE_ in CRT0DAT.ASM and WFILE.ASM for
  1042.     the maximum number of child text windows.)
  1043.  
  1044.     After changing the limits, recompile using CSTARTUP.BAT.  Microsoft
  1045.     recommends that you first read README.TXT in the same directory.
  1046.  
  1047. Q409. How can I read, create, change, or delete the volume label?
  1048.  
  1049.     In DOS 5.0 (and, I believe, in 4.0 as well), there are actually two
  1050.     volume labels: one, the traditional one, is an entry in the root
  1051.     directory of the disk; and the other is in the boot record along
  1052.     with the serial number (see next Q).  The DIR and VOL commands
  1053.     report the traditional label; the LABEL command reports the
  1054.     traditional one but changes both of them.
  1055.  
  1056.     In DOS 4.0 and later, use INT 21 function 69 to access the boot
  1057.     record's serial number and volume label together; see the next Q.
  1058.  
  1059.     Assume that by "volume label" you mean the traditional one, the one
  1060.     that DIR and VOL display.  Though it's a directory entry in the root
  1061.     directory, you can't change it using the newer DOS file-access
  1062.     functions (3C, 41, 43); instead, use the old FCB-oriented directory
  1063.     functions.  Specifically, you need to allocate a 64-byte buffer and
  1064.     a 41- byte extended FCB (file control block).  Call INT 21 AH=1A to
  1065.     find out whether there is a volume label.  If there is, AL returns 0
  1066.     and you can change the label using DOS function 17 or delete it
  1067.     using DOS function 13.  If there's no volume label, function 1A will
  1068.     return FF and you can create a label via function 16.  Important
  1069.     points to notice are that ? wildcards are allowed but * are not; the
  1070.     volume label must be space filled not null terminated.
  1071.  
  1072.     The following MSC 7.0 code worked for me in DOS 5.0; the functions
  1073.     it uses have been around since DOS 2.0.  The function parameter is 0
  1074.     for the current disk, 1 for a:, 2 for b:, etc.  It doesn't matter
  1075.     what your current directory is; these functions always search the
  1076.     root directory for volume labels.  (I didn't try to change the
  1077.     volume label of any networked drives.)
  1078.  
  1079.     // Requires DOS.H, STDIO.H, STRING.H
  1080.     void vollabel(unsigned char drivenum) {
  1081.         static unsigned char extfcb[41], dta[64], status, *newlabel;
  1082.         int chars_got = 0;
  1083.         #define DOS(buff,func) __asm { __asm mov dx,offset buff \
  1084.             __asm mov ax,seg buff  __asm push ds  __asm mov ds,ax \
  1085.             __asm mov ah,func  __asm int 21h  __asm pop ds \
  1086.             __asm mov status,al }
  1087.         #define getlabel(buff,prompt) newlabel = buff;  \
  1088.             memset(newlabel,' ',11);  printf(prompt);   \
  1089.             scanf("%11[^\n]%n", newlabel, &chars_got);  \
  1090.             if (chars_got < 11) newlabel[chars_got] = ' ';
  1091.  
  1092.         // Set up the 64-byte transfer area used by function 1A.
  1093.         DOS(dta, 1Ah)
  1094.         // Set up an extended FCB and search for the volume label.
  1095.         memset(extfcb, 0, sizeof extfcb);
  1096.         extfcb[0] = 0xFF;             // denotes extended FCB
  1097.         extfcb[6] = 8;                // volume-label attribute bit
  1098.         extfcb[7] = drivenum;         // 1=A, 2=B, etc.; 0=current drive
  1099.         memset(&extfcb[8], '?', 11);  // wildcard *.*
  1100.         DOS(extfcb,11h)
  1101.         if (status == 0) {            // DTA contains volume label's FCB
  1102.             printf("volume label is %11.11s\n", &dta[8]);
  1103.             getlabel(&dta[0x18], "new label (\"delete\" to delete): ");
  1104.             if (chars_got == 0)
  1105.                 printf("label not changed\n");
  1106.             else if (strncmp(newlabel,"delete     ",11) == 0) {
  1107.                 DOS(dta,13h)
  1108.                 printf(status ? "label failed\n" : "label deleted\n");
  1109.             }
  1110.             else {                    // user wants to change label
  1111.                 DOS(dta,17h)
  1112.                 printf(status ? "label failed\n" : "label changed\n");
  1113.             }
  1114.         }
  1115.         else {                        // no volume label was found
  1116.             printf("disk has no volume label.\n");
  1117.             getlabel(&extfcb[8], "new label (<Enter> for none): ");
  1118.             if (chars_got > 0) {
  1119.                 DOS(extfcb,16h)
  1120.                 printf(status ? "label failed\n" : "label created\n");
  1121.             }
  1122.         }
  1123.     }   // end function vollabel
  1124.  
  1125. Q410. How can I get the disk serial number?
  1126.  
  1127.     Use INT 21.  AX=6900 gets the serial number; AX=6901 sets it.  See
  1128.     Ralf Brown's interrupt list, or page 496 of the July 1992 {PC
  1129.     Magazine}, for details.
  1130.  
  1131.     This function also gets and sets the volume label, but it's the
  1132.     volume label in the boot record, not the volume label that a DIR
  1133.     command displays.  See the preceding Q.
  1134.  
  1135. Q411. What's the format of .OBJ, .EXE., .COM files?
  1136.  
  1137.     Please see section 2, "Compile and link".
  1138.  
  1139. Q412. How can I flush the software disk cache?
  1140.  
  1141.     Please see "How can a program reboot my PC?" in section 7, "Other
  1142.     software questions and problems".
  1143.  
  1144. section 5. Serial ports (COM ports)
  1145. ===================================
  1146.  
  1147. Q501. How do I set my machine up to use COM3 and COM4?
  1148.  
  1149.     Unless your machine is fairly old, it's probably already set up.
  1150.     After installing the board that contains the extra COM port(s),
  1151.     check the I/O addresses in word 0040:0004 or 0040:0006.  (In DEBUG,
  1152.     type "D 40:4 L4" and remember that every word is displayed low
  1153.     byte first, so if you see "03 56" the word is 5603.)  If those
  1154.     addresses are nonzero, your PC is ready to use the ports and you
  1155.     don't need the rest of this answer.
  1156.  
  1157.     If the I/O address words in the 0040 segment are zero after you've
  1158.     installed the I/O board, you need some code to store these values
  1159.     into the BIOS data segment:
  1160.  
  1161.         0040:0004  word  I/O address of COM3
  1162.         0040:0006  word  I/O address of COM4
  1163.         0040:0011  byte (bits 3-1): number of serial ports installed
  1164.  
  1165.     The documentation with your I/O board should tell you the port
  1166.     addresses.  When you know the proper port addresses, you can add
  1167.     code to your program to store them and the number of serial ports
  1168.     into the BIOS data area before you open communications.  Or you can
  1169.     use DEBUG to create a little program to include in your AUTOEXEC.BAT
  1170.     file, using this script:
  1171.  
  1172.             n SET_ADDR.COM      <--- or a different name ending in .COM
  1173.             a 100
  1174.             mov  AX,0040
  1175.             mov  DS,AX
  1176.             mov  wo [0004],aaaa <--- replace aaaa with COM3 address or 0
  1177.             mov  wo [0006],ffff <--- replace ffff with COM4 address or 0
  1178.             and  by [0011],f1
  1179.             or   by [0011],8    <--- use number of serial ports times 2
  1180.             mov  AH,0
  1181.             int  21
  1182.                                 <--- this line must be blank
  1183.             rCX
  1184.             1f
  1185.             rBX
  1186.             0
  1187.             w
  1188.             q
  1189.  
  1190. Q502. How do I find the I/O address of a COM port?
  1191.  
  1192.     Look in the four words beginning at 0040:0000 for COM1 through COM4.
  1193.     (The DEBUG command "D 40:0 L8" will do this.  Remember that words
  1194.     are stored and displayed low byte first, so a word value of 03F8
  1195.     will be displayed as F8 03.)  If the value is zero, that COM port is
  1196.     not installed (or you've got an old BIOS; see the preceding Q).  If
  1197.     the value is nonzero, it is the I/O address of the transmit/receive
  1198.     register for the COM port.  Each COM port occupies eight consecutive
  1199.     I/O addresses (though only seven are used by many chips).
  1200.  
  1201.     Here's some C code to find the I/O address:
  1202.  
  1203.         unsigned ptSel(unsigned comport) {
  1204.             unsigned io_addr;
  1205.             if (comport >= 1  &&  comport <= 4) {
  1206.                 unsigned far *com_addr = (unsigned far *)0x00400000UL;
  1207.                 io_addr = com_addr[comport-1];
  1208.             }
  1209.             else
  1210.                 io_addr = 0;
  1211.             return io_addr;
  1212.         }
  1213.  
  1214. Q503. But aren't the COM ports always at I/O addresses 3F8, 2F8, 3E8,
  1215.       and 2E8?
  1216.  
  1217.     The first two are usually right (though not always); the last two
  1218.     are different on many machines.
  1219.  
  1220. Q504. How do I configure a COM port and use it to transmit data?
  1221.  
  1222.     (rev: 18 Apr 1993) Do you want actual code, or do you want books
  1223.     that explain what's going on?
  1224.  
  1225.     1) Source code
  1226.  
  1227.     First, check your compiler's run-time library.  Many compilers offer
  1228.     functions similar to Microsoft C's _bios_serialcom() or Borland's
  1229.     bioscom(), which may meet your needs.
  1230.  
  1231.     Second, check for downloadable resources at Simtel and garbo.  At
  1232.     Simtel, pd1:<msdos.c>pcl4c34.zip (March 1993) is described as
  1233.     "Asynchronous communications library for C"; garbo has a whole
  1234.     /pc/comm directory.  Also, an extended example is in Borland's
  1235.     TechFax TI445, downloadable as part of
  1236.         pd1:<msdos.turbo-c>bchelp10.zip at Simtel
  1237.         /pc/turbopas/bchelp10.zip at garbo.
  1238.     Though written by Borland, much of it is applicable to other forms
  1239.     of C, and it should give you ideas for other programming languages.
  1240.  
  1241.     2) Reference books
  1242.  
  1243.     After hearing several recommendations, I looked at Joe Campbell's {C
  1244.     Programmer's Guide to Serial Communications}, ISBN 0-672-22584-0,
  1245.     and agree that it is excellent.  He gives complete details on how
  1246.     serial ports work, along with complete programs for doing polled or
  1247.     interrupt-driver I/O.  The book is quite thick, and none of it looks
  1248.     like filler.
  1249.  
  1250.     If Campbell's book is overkill for you, you'll find a good short
  1251.     description of serial I/O in {DOS 5: A Developer's Guide}, ISBN
  1252.     1-55851-177-6, by Al Williams.
  1253.  
  1254. section 6. Other hardware questions and problems
  1255. ================================================
  1256.  
  1257. Q601. Which 80x86 CPU is running my program?
  1258.  
  1259.     (rev: 13 June 1993)  According to an article posted by Michael
  1260.     Davidson, Intel's approved code for distinguishing among 8086,
  1261.     80286, 80386, and 80486 and for detecting the presence of an 80287
  1262.     or 80387 is published in Intel's 486SX processor manual (order
  1263.     number 240950-001).  David Kirschbaum's improved version of this is
  1264.     downloadable as
  1265.         pd1:<msdos.sysutl>cpuid593.zip from Simtel
  1266.         /pc/sysinfo/cpuid593.zip from garbo.
  1267.  
  1268.     According to an article posted by its author, WCPU knows the
  1269.     differences between DX and SX varieties of 386 and 486 chips, and
  1270.     can also detect a math coprocessor and a Pentium.  It's downloadable
  1271.     as pd1:<msdos.sysutl>wcpu050.zip at Simtel.
  1272.  
  1273. Q602. How can a C program send control codes to my printer?
  1274.  
  1275.     If you just fprintf(stdprn, ...), C will translate some of your
  1276.     control codes.  The way around this is to reopen the printer in
  1277.     binary mode:
  1278.  
  1279.         prn = fopen("PRN", "wb");
  1280.  
  1281.     You must use a different file handle because stdprn isn't an lvalue.
  1282.     By the way, PRN or LPT1 must not be followed by a colon in DOS 5.0.
  1283.  
  1284.     There's one special case, Ctrl-Z (ASCII 26), the DOS end-of-file
  1285.     character.  If you try to send an ASCII 26 to your printer, DOS
  1286.     simply ignores it.  To get around this, you need to reset the
  1287.     printer from "cooked" to "raw" mode.  Microsoft C users must use int
  1288.     21 function 44, "get/set device information".  Turbo C and Borland
  1289.     C++ users can use ioctl to accomplish the same thing:
  1290.  
  1291.         ioctl(fileno(prn), 1, ioctl(fileno(prn),0) & 0xFF | 0x20, 0);
  1292.  
  1293.     An alternative approach is simply to write the printer output into a
  1294.     disk file, then copy the file to the printer with the /B switch.
  1295.  
  1296.     A third approach is to bypass DOS functions entirely and use the
  1297.     BIOS printer functions at INT 17.  If you also fprintf(stdprn,...)
  1298.     in the same program, you'll need to use fflush( ) to synchronize
  1299.     fprintf( )'s buffered output with the BIOS's unbuffered.
  1300.  
  1301.     By the way, if you've opened the printer in binary mode from a C
  1302.     program, remember that outgoing \n won't be translated to carriage
  1303.     return/line feed.  Depending on your printer, you may need to send
  1304.     explicit \n\r sequences.
  1305.  
  1306. Q603. How can I redirect printer output to a file?
  1307.  
  1308.     Please see section 4, "Disks and files", for the answer.
  1309.  
  1310. Q604. Which video adapter is installed?
  1311.  
  1312.     The technique below should work if your BIOS is not too old.  It
  1313.     uses three functions from INT 10, the BIOS video interrupt.  (If
  1314.     you're using a Borland language, you may not have to do this the
  1315.     hard way.  Look for a function called DetectGraph or something
  1316.     similar.)
  1317.  
  1318.     Set AH=12h, AL=0, BL=32h; INT 10h.  If AL is 12h, you have a VGA.
  1319.     If not, set AH=12h, BL=10h; INT 10h.  If BL is 0,1,2,3, you have an
  1320.     EGA with 64,128,192,256K memory.  If not, set AH=0Fh; INT 10h.  If
  1321.     AL is 7, you have an MDA (original monochrome adapter) or Hercules;
  1322.     if not, you have a CGA.
  1323.  
  1324.     I've tested this for my VGA and got the right answer; but I can't
  1325.     test it for the other equipment types.  Please let me know by email
  1326.     at brown@ncoast.org if your results vary.
  1327.  
  1328. Q605. How do I switch to 43- or 50-line mode?
  1329.  
  1330.     pd1:<msdos.screen>vidmode.zip, downloadable from Simtel, contains
  1331.     .COM utilities and .ASM source code.
  1332.  
  1333. Q606. How can I find the Microsoft mouse position and button status?
  1334.  
  1335.     Use INT 33 function 3, described in Ralf Brown's interrupt list.
  1336.  
  1337.     The Windows manual says that the Logitech mouse is compatible with
  1338.     the Microsoft one, so I assume the interrupt will work the same.
  1339.  
  1340.     Also, many files are downloadable from pd1:<msdos.mouse> at Simtel.
  1341.  
  1342. Q607. How can I access a specific address in the PC's memory?
  1343.  
  1344.     First check the library that came with your compiler.  Many vendors
  1345.     have some variant of peek and poke functions; in Turbo Pascal use
  1346.     the pseudo-arrays Mem, MemW, and MemL.  As an alternative, you can
  1347.     construct a far pointer:  use Ptr in Turbo Pascal, MK_FP in the
  1348.     Turbo C family, and FP_OFF and FP_SEG in Microsoft C.
  1349.  
  1350.     Caution:  Turbo C and Turbo C++ also have FP_OFF and FP_SEG macros,
  1351.     but they can't be used to construct a pointer.  In Borland C++ those
  1352.     macros work the same as in Microsoft C, but MK_FP is easier to use.
  1353.  
  1354.     By the way, it's not useful to talk about "portable" ways to do
  1355.     this.  Any operation that is tied to a specific memory address is
  1356.     not likely to work on another kind of machine.
  1357.  
  1358. Q608. How can I read or write my PC's CMOS memory?
  1359.  
  1360.     (rev: 13 Jun 1993) There are a great many public-domain utilities
  1361.     that do this.  These are downloadable from Simtel:
  1362.  
  1363.     pd1:<msdos.at>
  1364.     cmos14.zip     5965  920817  Saves/restores CMOS to/from file
  1365.     cmoser11.zip  28323  910721  386/286 enhanced CMOS setup program
  1366.     cmosram.zip   76096  920214  Save AT/386/486 CMOS data to file and restore
  1367.     rom2.zip      15692  900131  Save AT and 386 CMOS data to file and restore
  1368.     setup21.zip   18172  880613  Setup program which modifies CMOS RAM
  1369.     viewcmos.zip  11068  900225  Display contents of AT CMOS RAM, w/C source
  1370.  
  1371.     Downloadable from garbo, /pc/ts/tsutle22.zip contains a CMOS program
  1372.     to check and display CMOS memory, but not to write to it.
  1373.  
  1374.     I have heard good reports of CMOS299.ZIP, available in the pc.dir
  1375.     directory of cantva.canterbury.ac.nz [132.181.30.3].
  1376.  
  1377.     Of the above, my only experience is with CMOSRAM, which seems to
  1378.     work fine.  It contains an excellent (and witty) .DOC file that
  1379.     explains the hardware involved and gives specific recommendations
  1380.     for preventing disaster or recovering from it.  It's $5 shareware.
  1381.  
  1382.     Robert Jourdain's {Programmer's Problem Solver for the IBM PC, XT,
  1383.     and AT} has code for accessing the CMOS RAM, according to an article
  1384.     posted in this newsgroup.
  1385.  
  1386. Q609. How can I access memory beyond 640K?
  1387.  
  1388.     (rev: 2 May 1993) This is a legitimate FAQ, in that it is frequently
  1389.     asked.  But there is no single agreed-upon answer.  Please see the
  1390.     separate article called "How to access memory above 640K" in
  1391.     comp.os.msdos.programmer and in faqp*.zip at Simtel and garbo.
  1392.  
  1393. Q610. Where can I find a list of 80x86 opcodes?
  1394.  
  1395.     (new: 2 May 1993)  It's part of a rather long file, the 8 Dec 1992
  1396.     edition of the Info-IBMPC Digest (V92 #185), downloadable as
  1397.     pd2:<archives.ibmpc>9212.1-txt at Simtel.  (Note: pd2, not
  1398.     pd1.)  Opcodes for the 8086 through 80386 are listed.
  1399.  
  1400. section 7. Other software questions and problems
  1401. ================================================
  1402.  
  1403. Q701. How can a program reboot my PC?
  1404.  
  1405.     You can generate a "cold" boot or a "warm" boot.  A cold boot is
  1406.     the same as turning the power off and on; a warm boot is the same as
  1407.     Ctrl-Alt-Del and skips the power-on self test.
  1408.  
  1409.     For a warm boot, store the hex value 1234 in the word at 0040:0072.
  1410.     For a cold boot, store 0 in that word.  Then, if you want to live
  1411.     dangerously, jump to address FFFF:0000.  Here's C code to do it:
  1412.  
  1413.         /* WARNING:  data loss possible */
  1414.         void bootme(int want_warm)  /* arg 0 = cold boot, 1 = warm */ {
  1415.             void (far* boot)(void) = (void (far*)(void))0xFFFF0000UL;
  1416.             unsigned far* type = (unsigned far*)0x00400072UL;
  1417.             *type = (want_warm ? 0x1234 : 0);
  1418.             (*boot)( );
  1419.         }
  1420.  
  1421.     What's wrong with that method?  It will boot right away, without
  1422.     closing files, flushing disk caches, etc.  If you boot without
  1423.     flushing a write-behind disk cache (if one is running), you could
  1424.     lose data or even trash your hard drive.
  1425.  
  1426.     There are two methods of signaling the cache to flush its buffers:
  1427.     (1) simulate a keyboard Ctrl-Alt-Del in the keystroke translation
  1428.     function of the BIOS (INT 15 function 4F), and (2) issue a disk
  1429.     reset (DOS function 0D).  Most disk-cache programs hook one or both
  1430.     of those interrupts, so if you use both methods you'll probably be
  1431.     safe.
  1432.  
  1433.     When user code simulates a Ctrl-Alt-Del, one or more of the programs
  1434.     that have hooked INT 15 function 4F can ask that the key be ignored by
  1435.     clearing the carry flag.  For example, HyperDisk does this when it
  1436.     has started but not finished a cache flush.  So if the carry flag
  1437.     comes back cleared, the boot code has to wait a couple of clock
  1438.     ticks and then try again.  (None of this matters on older machines
  1439.     whose BIOS can't support 101- or 102-key keyboards; see "What is the
  1440.     SysRq key for?" in section 3, "Keyboard".)
  1441.  
  1442.     Here's C code that tries to signal the disk cache (if any) to flush:
  1443.  
  1444.         #include <dos.h>
  1445.         void bootme(int want_warm)  /* arg 0 = cold boot, 1 = warm */ {
  1446.             union REGS reg;
  1447.             void    (far* boot)(void) = (void (far*)(void))0xFFFF0000UL;
  1448.             unsigned far* boottype    =     (unsigned far*)0x00400072UL;
  1449.             char     far* shiftstate  =         (char far*)0x00400017UL;
  1450.             unsigned      ticks;
  1451.             int           time_to_waste;
  1452.             /* Simulate reception of Ctrl-Alt-Del: */
  1453.             for (;;) {
  1454.                 *shiftstate |= 0x0C;    /* turn on Ctrl & Alt */
  1455.                 reg.x.ax = 0x4F53;      /* 0x53 = Del's scan code */
  1456.                 reg.x.cflag = 1;        /* sentinel for ignoring key */
  1457.                 int86(0x15, ®, ®);
  1458.                 /* If carry flag is still set, we've finished. */
  1459.                 if (reg.x.cflag)
  1460.                     break;
  1461.                 /* Else waste some time before trying again: */
  1462.                 reg.h.ah = 0;
  1463.                 int86(0x1A, ®, ®);/* system time into CX:DX */
  1464.                 ticks = reg.x.dx;
  1465.                 for (time_to_waste = 3;  time_to_waste > 0;  ) {
  1466.                     reg.h.ah = 0;
  1467.                     int86(0x1A, ®, ®);
  1468.                     if (ticks != reg.x.dx)
  1469.                         ticks = reg.x.dx , --time_to_waste;
  1470.                 }
  1471.             }
  1472.             /* Issue a DOS disk reset request: */
  1473.             reg.h.ah = 0x0D;
  1474.             int86(0x21, ®, ®);
  1475.             /* Set boot type and boot: */
  1476.             *boottype = (want_warm ? 0x1234 : 0);
  1477.             (*boot)( );
  1478.         }
  1479.  
  1480. Q702. How can I time events with finer resolution than the system
  1481.       clock's 55 ms (about 18 ticks a second)?
  1482.  
  1483.     (rev: 13 June 1993) The following files, among others, are
  1484.     downloadable from Simtel:
  1485.  
  1486.     pd1:<msdos.at>
  1487.     atim.zip       4783  881126  Precision program timing for AT
  1488.  
  1489.     pd1:<msdos.c>
  1490.     millisec.zip  37734  911205  MSC/asm src for millisecond res timing
  1491.     mschrt3.zip   53708  910605  High-res timer toolbox for MSC 5.1
  1492.     msec_12.zip    8484  920320  High-def millisec timer v1.2 (C,ASM)
  1493.     ztimer11.zip  77625  920428  Microsecond timer for C, C++, ASM
  1494.  
  1495.     pd1:<msdos.turbo-c>
  1496.     tchrt3.zip    53436  910606  High-res timer toolbox for Turbo C 2.0
  1497.     tctimer.arc   20087  891030  High-res timing of events for Turbo C
  1498.         (same as /pc/c/tctimer.zoo at garbo?)
  1499.  
  1500.     For Turbo Pascal users, source and object code are downloadable in
  1501.         pd1:<msdos.turbopas>bonus507.zip at Simtel
  1502.         /pc/turbopas/bonus507.zip at garbo.
  1503.  
  1504. Q703. How can I find the error level of the previous program?
  1505.  
  1506.     (rev: 13 June 1993)  First, which previous program are you talking
  1507.     about?  If your current program ran another one, when the child
  1508.     program ends its error level is available to the program that
  1509.     spawned it.  Most high-level languages provide a way to do this; for
  1510.     instance, in Turbo Pascal it's Lo(DosExitCode) and the high byte
  1511.     gives the way in which the child terminated.  In Microsoft C, the
  1512.     exit code of a synchronous child process is the return value of the
  1513.     spawn-type function that creates the process.
  1514.  
  1515.     If your language doesn't have a function to return the error code
  1516.     of a child process, you can use INT 21 function 4D (get return
  1517.     code).  By the way, this will tell you the child's exit code and the
  1518.     manner of its ending (normal, Ctrl-C, critical error, or TSR).
  1519.  
  1520.     It's much trickier if the current program wants to get the error
  1521.     level of the program that ran and finished before this one started.
  1522.     G.A.Theall has published source and compiled code to do this; the
  1523.     code is downloadable as pd1:<msdos.batutl>errlvl13.zip at Simtel.
  1524.     (The code uses undocumented features in DOS 3.3 through 5.0.  Theall
  1525.     says in the .DOC file that the values returned under 4DOS or other
  1526.     replacements won't be right.)
  1527.  
  1528. Q704. How can a program set DOS environment variables?
  1529.  
  1530.     (rev: 13 June 1993)  Program functions that read or write "the
  1531.     environment" typically access only the program's copy of it.  What
  1532.     this Q really wants to do is to modify the active environment, the
  1533.     one that is affected by SET commands in batch files or at the DOS
  1534.     prompt.  You need to do some programming to find the active
  1535.     environment, and that depends on the version of DOS.
  1536.  
  1537.     A fairly well-written article in {PC Magazine} volume 8 number 20
  1538.     (1989 Nov 28), pages 309-314, explains how to find the active
  1539.     environment, and includes Pascal source code.  The article hints at
  1540.     how to change the environment, and suggests creating paths longer
  1541.     than 128 characters as one application.
  1542.  
  1543.     Now as for downloadable source code, there are many possibilities.
  1544.     Of the ones I looked at (not all of them), I liked
  1545.         pd1:<msdos.envutil>rbsetnv1.zip at Simtel
  1546.         /pc/envutil/rbsetnv1.zip at garbo
  1547.     the best.  It includes some utilities to manipulate the environment,
  1548.     with source code in C.  A newer program is
  1549.         pd1:<msdos.batutl>strings2.zip at Simtel
  1550.         part of /pc/pcmag/vol11n22.zip at garbo,
  1551.     which is the code from the {PC Magazine} article of volume 11 number
  1552.     22 (22 Dec 1992).
  1553.  
  1554.     You can also use a call to INT 2E, Pass Command to Interpreter for
  1555.     Execution; see Ralf Brown's interrupt list for details and cautions.
  1556.  
  1557. Q705. How can I change the switch character to - from /?
  1558.  
  1559.     Under DOS 5.0, you can't -- not completely, anyway.  INT 21 function
  1560.     3700, get switch character, always returns a '/' (hex 2F) -- and the
  1561.     DOS commands don't even call that function, but hard code '/' as the
  1562.     switch character.
  1563.  
  1564.     Some history:  DOS used to let you change the switch character by
  1565.     using SWITCHAR= in CONFIG.SYS or by calling DOS function 3701.  DOS
  1566.     commands and other programs called DOS function 3700 to find out the
  1567.     switch character.  If you changed the switch character to '-' (the
  1568.     usual choice), you could then type "dir c:/c700 -p" rather than "dir
  1569.     c:\c700 /p".  Under DOS 4.0, the DOS commands ignored the switch
  1570.     character but functions 3700 and 3701 still worked and could be used
  1571.     by other programs.  Under DOS 5.0, even those functions no longer
  1572.     work, though all DOS functions still accept '/' or '\' in file
  1573.     specs.
  1574.  
  1575.     You can reactivate the functions to get and set switchar by using
  1576.     programs like SLASH.ZIP or the sample TSR called SWITCHAR in
  1577.     amisl091.zip (see "How can I write a TSR?", below.)  DOS commands
  1578.     will still use the slash, but non-DOS programs that call DOS func-
  1579.     tion 3700 will use your desired switch character.  (DOS replacements
  1580.     like 4DOS may honor the switch character for internal commands.)
  1581.  
  1582.     Some readers may wonder why this is even an issue.  Making '-' the
  1583.     switch character frees up the front slash to separate names in the
  1584.     path part of a file spec.  This is easier for the ten-fingered to
  1585.     type, and it's one less difference to remember for commuters between
  1586.     DOS and Unix.  The switch character is the only issue, since all the
  1587.     INT 21 functions accept '/' or '\' to separate directory names.
  1588.  
  1589. Q706. Why does my interrupt function behave strangely?
  1590.  
  1591.     Interrupt service routines can be tricky, because you have to do
  1592.     some things differently from "normal" programs.  If you make a
  1593.     mistake, debugging is a pain because the symptoms may not point at
  1594.     what's wrong.  Your machine may lock up or behave erratically, or
  1595.     just about anything else can happen.  Here are some things to look
  1596.     for.  (See the next Q for general help before you have a problem.)
  1597.  
  1598.     First, did you fail to set up the registers at the start of your
  1599.     routine?  When your routine begins executing, you can count on
  1600.     having CS point to your code segment and SS:SP point to some valid
  1601.     stack (of unknown length), and that's it.  In particular, an
  1602.     interrupt service routine must set DS to DGROUP before accessing any
  1603.     data in its data segments.  (If you're writing in a high-level
  1604.     language, the compiler may generate this code for you automatically;
  1605.     check your compiler manual.  For instance, in Borland and Microsoft
  1606.     C, give your function the "interrupt" attribute.)
  1607.  
  1608.     Did you remember to turn off stack checking when compiling your
  1609.     interrupt server and any functions it calls?  The stack during the
  1610.     interrupt is not where the stack-checking code expects it to be.
  1611.     (Caution:  Some third-party libraries have stack checking compiled
  1612.     in, so you can't call them from your interrupt service routine.)
  1613.  
  1614.     Next, are you calling any DOS functions (INT 21, 25, or 26) in your
  1615.     routine?  DOS is not re-entrant.  This means that if your interrupt
  1616.     happens to be triggered while the CPU is executing a DOS function,
  1617.     calling another DOS function will wreak havoc.  (Some DOS functions
  1618.     are fully re-entrant, as noted in Ralf Brown's interrupt list.
  1619.     Also, your program can test, in a way too complicated to present
  1620.     here, when it's safe to call non-re-entrant DOS functions.  See INT
  1621.     28 and functions 34, 5D06, 5D0B of INT 21; and consult {Undocumented
  1622.     DOS} by Andrew Schulman.  Your program must read both the "InDOS
  1623.     flag" and the "critical error flag".)
  1624.  
  1625.     Is a function in your language library causing trouble?  Does it
  1626.     depend on some initializations done at program startup that is no
  1627.     longer available when the interrupt executes?  Does it call DOS (see
  1628.     preceding paragraph)?  For example, in both Borland and Microsoft C
  1629.     the memory-allocation functions (malloc, etc..) and standard I/O
  1630.     functions (scanf, printf) call DOS functions and also depend on
  1631.     setups that they can't get at from inside an interrupt.  Many other
  1632.     library functions have the same problem, so you can't use them
  1633.     inside an interrupt function without special precautions.
  1634.  
  1635.     Is your routine simply taking too long?  This can be a problem if
  1636.     you're hooking on to the timer interrupt, INT 1C or INT 8.  Since
  1637.     that interrupt expects to be called 18.2 times a second, your
  1638.     routine -- plus any others hooked to the same interrupts -- must
  1639.     execute in less than 55 ms.  If they use even a substantial fraction
  1640.     of that time, you'll see significant slowdowns of your foreground
  1641.     program.  A good discussion is downloadable as
  1642.         pub/msdos/simtel20/info/INTSHARE at ni.funet.fi
  1643.         pd1:<msdos.info>intshare at Simtel.
  1644.  
  1645.     Did you forget to restore all registers at the end of your routine?
  1646.  
  1647.     Did you chain improperly to the original interrupt?  You need to
  1648.     restore the stack to the way it was upon entry to your routine, then
  1649.     do a far jump (not call) to the original interrupt service routine.
  1650.     (The process is a little different in high-level languages.)
  1651.  
  1652. Q707. How can I write a TSR (terminate-stay-resident utility)?
  1653.  
  1654.     (rev: 13 June 1993)  There are books, and there's code to download.
  1655.  
  1656.     First, the books:
  1657.  
  1658.     - Ray Duncan's {Advanced MS-DOS}, ISBN 1-55615-157-8, gives a brief
  1659.       checklist intended for experienced programmers.  The ISBN is for
  1660.       the second edition, through DOS 4; but check to see whether the
  1661.       DOS 5 version is available yet.
  1662.  
  1663.     - {DOS 5:  A Developer's Guide} by Al Williams, ISBN 1-55851-177-6,
  1664.       goes into a little more detail, 90 pages worth!
  1665.  
  1666.     - Pascal programmers might look at {The Ultimate DOS Programmer's
  1667.       Manual} by John Mueller and Wallace Wang, ISBN 0-8306-3534-3, for
  1668.       an extended example in mixed Pascal and assembler.
  1669.  
  1670.     - For a pure assembler treatment, check Steven Holzner's {Advanced
  1671.       Assembly Language}, ISBN 0-13-663014-6.  He has a book with the
  1672.       same title out from Brady Press, but it's about half as long as
  1673.       this one.
  1674.  
  1675.     - For C programmers, there's a chapter in Herbert Schildt's {The Art
  1676.       of C:  Elegant Programming Solutions}.  I haven't seen the book,
  1677.       but a posted article recommended it.
  1678.  
  1679.     Next, the code.  Some of it is companion code to published articles,
  1680.     which are also listed below:
  1681.  
  1682.     - The Alternate Multiplex Interrupt Specification, downloadable as
  1683.         pd1:<msdos.info>altmpx35.zip at Simtel
  1684.         /pc/programming/altmpx35.zip at garbo
  1685.         /afs/cs/user/ralf/pub/altmpx35.zip at cs.cmu.edu
  1686.  
  1687.     - Ralf Brown's assembly-language implementation of the spec, with
  1688.       utilities in C, downloadable as
  1689.         pd1:<msdos.asmutl>amisl091.zip at Simtel
  1690.         /afs/cs/user/ralf/pub/amisl091.zip at cs.cmu.edu
  1691.  
  1692.     - Douglas Boling's MASM template for a TSR is downloadable as
  1693.         pd1:<msdos.asmutl>template.zip at Simtel.
  1694.  
  1695.     - A posted article mentions Boling's "Strategies and Techniques for
  1696.       Writing State-of-the-Art TSRs that Exploit MS-DOS 5", Microsoft
  1697.       Systems Journal, Jan-Feb 1992, Volume 7, Number 1, pages 41-59,
  1698.       with examples downloadable in
  1699.           pd1:<msdos.msjournal>msjv7-1.zip at Simtel
  1700.  
  1701.     - code for Al Stevens's "Writing Terminate-and-Stay-Resident
  1702.       Programs", Computer Language, February 1988, pages 37-48 and March
  1703.       1988, pages 67-76 is downloadable as
  1704.         pd1:<msdos.c>tsrc.zip at Simtel
  1705.  
  1706.     - software examples to accompany Kaare Christian's "Using Microsoft
  1707.       C Version 5.1 to Write Terminate-and-Stay-Resident Programs",
  1708.       Microsoft Systems Journal, September 1988, Volume 3, Number 5,
  1709.       pages 47-57 are downloadable as
  1710.           pd1:<msdos.msjournal>msjv3-5.arc at Simtel
  1711.  
  1712.     Finally, there are commercial products, of which TesSeRact (for
  1713.     C-language TSRs) is one of the best known.
  1714.  
  1715. Q708. How can I write a device driver?
  1716.  
  1717.     Many books answer this in detail.  Among them are {Advanced MS-DOS}
  1718.     and {DOS 5: A Developer's Guide}, cited in the preceding Q.
  1719.     Michael Tischer's {PC System Programming}, ISBN 1-55755-036-0, has
  1720.     an extensive treatment, as does Dettman and Kyle's {DOS Programmer's
  1721.     Reference: 2d Edition}, ISBN 0-88022-458-4.  For a really in-depth
  1722.     treatment, look for a specialized book like Robert Lai's {Writing
  1723.     MS-DOS Device Drivers}, ISBN 0-201-13185-4.
  1724.  
  1725. Q709. What can I use to manage versions of software?
  1726.  
  1727.     (rev: 18 Apr 1993)  A port of the Unix RCS utility is downloadable
  1728.     from Simtel as pd1:<msdos.gnuish>rcs55ax.zip (EXE and docs) and
  1729.     rcs55as.zip (source).  I haven't used it myself, but I understand
  1730.     this is no longer limited to one-character extensions on filenames
  1731.     (so .CPP and .BAS are fine).
  1732.  
  1733. Q710. What's this "null pointer assignment" after my C program executes?
  1734.  
  1735.     (rev: 18 Apr 1993)  Somewhere in your program, you assigned a value
  1736.     _through_ a pointer without first assigning a value _to_ the
  1737.     pointer.  (This might have been something like a strcpy or memcpy
  1738.     with a pointer as its first argument, not necessarily an actual
  1739.     assignment statement.) Your program may look like it ran correctly,
  1740.     but if you get this message you can be certain that there's a bug
  1741.     somewhere.
  1742.  
  1743.     Microsoft and Borland C, as part of their exit code (after a return
  1744.     from your main function), check whether the location 0000 in your
  1745.     data segment contains a different value from what you started with;
  1746.     if so, they infer that you must have used an uninitialized pointer.
  1747.  
  1748.     To track down the problem, you can put exit( ) statements at various
  1749.     spots in the program and narrow down where the uninitialized pointer
  1750.     is being used by seeing which added exit( ) makes the null-pointer
  1751.     message disappear.  Or, in the debugger, set a watch at location
  1752.     0000 in your data segment, assuming you're in small or medium model.
  1753.     (If data pointers are 32 bits, as in the compact and large models, a
  1754.     null pointer will overwrite the interrupt vectors at 0000:0000 and
  1755.     probably lock up your machine.)
  1756.  
  1757.     Under MSC/C++ 7.0, you can declare the undocumented library function
  1758.  
  1759.         extern _cdecl _nullcheck(void);
  1760.  
  1761.     and then sprinkle calls to _nullcheck( ) through your program at
  1762.     regular intervals.
  1763.  
  1764.     Borland's TechFax document #TI726 discusses the null pointer
  1765.     assignment from a Borland point of view.  It's one of many documents
  1766.     downloadable as part of
  1767.         pd1:<msdos.turbo-c>bchelp10.zip at Simtel
  1768.         /pc/turbopas/bchelp10.zip at garbo.
  1769.  
  1770. Q711. How can my program tell if it's running under Windows?
  1771.  
  1772.     (rev: 18 Apr 1993)  Set AX=4680 and execute INT 2F.  If AX contains
  1773.     0, you're in Windows real mode or standard mode (or under the DOS
  1774.     5.0 shell).  Otherwise, set AX=1600 and INT 2F.  If AL does not
  1775.     contain 0 or 80, you're in Windows 386 enhanced mode.  (source:  PC
  1776.     Magazine volume 11 nr 20, pp 492-493)
  1777.  
  1778.     When Windows 3.0 or 3.1 is running, the DOS environment will contain
  1779.     a definition of the string windir, in lower case.
  1780.  
  1781.     For more information, see {PC Magazine} 92/11/24 pages 492-3 and
  1782.     92/5/26 pages 345-6.  A program, WINMODE, is available as part of
  1783.         pd1:<msdos.pcmag>vol11n10.zip at Simtel
  1784.         /pc/pcmag/vol11n10.zip at garbo.
  1785.  
  1786. Q712. How do I copyright software that I write?
  1787.  
  1788.     (new: 5 Apr 1993) The following is adapted (and greatly condensed)
  1789.     from chapter 4 of the Chicago Manual of Style (13th edition, ISBN
  1790.     0-226-10390-0).  Disclaimer:  I am not a lawyer, and this is not
  1791.     legal advice.  Also, there are very likely to be differences in
  1792.     copyright law among nations.  No matter where you live, if
  1793.     significant money may be involved, get legal advice.
  1794.  
  1795.     That said, in the U.S. (at least), when you write something, you own
  1796.     the copyright.  (The most significant exception to programmers is
  1797.     "works made for hire", i.e., something you write because your
  1798.     employer or client pays you to.  A contract, agreed in advance, can
  1799.     vest the copyright in the programmer even if an employee.)  You
  1800.     don't have to register the work with the Copyright Office unless
  1801.     (until) the copyright is infringed and you intend to bring suit;
  1802.     however, it is easier to recover damages in court if you did
  1803.     register the work within three months of publication.
  1804.  
  1805.     From paragraph 4.16 of the Chicago Manual:  "... the [copyright]
  1806.     notice consists of three parts: (1) the symbol [C-in-a-circle]
  1807.     (preferred because it also suits the requirements of the Universal
  1808.     Copyright Convention), the word 'Copyright', or the abbreviation
  1809.     'Copr.', (2) a date--the year of first publication, and (3) the name
  1810.     of the copyright owner.  Most publishers also add the phrase 'All
  1811.     rights reserved' because it affords some protection in Central and
  1812.     South American countries ...."  Surprise:  "(C)" is legally not the
  1813.     same as the C-in-a-circle, so those of us who are ASCII-bound must
  1814.     use the word or the abbreviation.
  1815.  
  1816.  
  1817. (continued in part 4)
  1818. -- 
  1819. Stan Brown, Oak Road Systems                    brown@Ncoast.ORG
  1820.  
  1821. Can't find FAQ lists?  ftp to 'rtfm.mit.edu' and look in /pub/usenet
  1822. (or email me >>> with valid reply-to address <<< for instructions).
  1823. Archive-name: msdos-programmer-faq/part4
  1824. Last-modified: 13 June 1993
  1825.  
  1826.  
  1827. (continued from part 3)         (no warranty on the code or information)
  1828.  
  1829. If the posting date is more than six weeks in the past, see instructions
  1830. in part 4 of this list for how to get an updated copy.
  1831.  
  1832. Copyright (C) 1993  Stan Brown, Oak Road Systems.  All rights reserved.
  1833.  
  1834.  
  1835. section A. Downloads
  1836. ====================
  1837.  
  1838. QA01. What are Simtel, garbo, and wustl?
  1839.  
  1840.     (rev: 13 Jun 1993) These are three of the most popular archive
  1841.     sites, with a few bazillion files available for downloading by ftp.
  1842.     (For email access, see next Q.)  Everything is free for downloading,
  1843.     though many of the files are shareware and you're expected to send a
  1844.     payment directly to the authors if you use them regularly.
  1845.  
  1846.     In comp.archives.msdos.d, Samuel Ko posts a two-part "Useful
  1847.     MSDOS Programs at SIMTEL20 and Garbo"; it's downloadable as
  1848.         pd1:<msdos.info>useful27.zip at Simtel
  1849.         /pc/filelist/useful27.zip at garbo
  1850.         /pub/usenet/news.answers/msdos-archives/part* at rtfm.mit.edu.
  1851.     For rtfm.mit.edu instructions, see "Where are FAQ lists archived?"
  1852.     in section C, "More information".
  1853.  
  1854.     A few words about file names and versions:  Many files at the
  1855.     archive sites are updated from time to time.  I have verified the
  1856.     filenames in this FAQ list as follows:
  1857.  
  1858.         garbo: from /pc/INDEX as of 10 Jun 1993
  1859.         Simtel: from pd1:<msdos.filedocs>simibm.zip as of 1 Jun 1993
  1860.         rtfm.mit.edu: via ftp access on 10 Apr 1993
  1861.  
  1862.     If you can't find a file given in these articles as mumble12.zip,
  1863.     perhaps there's a newer version; try mumble13.zip or mumble14.zip,
  1864.     or mumble*.zip if your ftp program supports wildcards (most do so).
  1865.     Please let me know of any out-of-date file names in these FAQs and
  1866.     I'll gladly update them.
  1867.  
  1868.     I have tried to list both garbo and Simtel directory and file names
  1869.     for every file mentioned for downloading.  If you see a listing for
  1870.     only one of them, it means that I couldn't find the file at the
  1871.     other site, or that the other site's catalog shows an old version.
  1872.  
  1873.     Also remember that caps and lower case filenames are not inter-
  1874.     changeable at most archive sites, though they are at Simtel.
  1875.  
  1876.     1) Simtel = wsmr-simtel20.army.mil [192.88.110.20]
  1877.  
  1878.     is located in New Mexico, USA.  For instructions, see these monthly
  1879.     articles in comp.archives.msdos.announce:
  1880.  
  1881.         SIMTEL20 archives info for Internet FTP users
  1882.         How to find files in the SIMTEL20 msdos collection
  1883.         How to order SIMTEL20 files via e-mail
  1884.         How to upload files to SIMTEL20
  1885.  
  1886.     These are downloadable from Simtel as pd1:<msdos.starter>simtel20.inf
  1887.     and pd1:<msdos.filedocs>aaaread.me, mailserv.inf, and upload.inf.
  1888.     If you have no ftp access, you can get these files (and anything
  1889.     else) by email; see the next Q.
  1890.  
  1891.     If Simtel is busy, you might try the mirror site oak.oakland.edu,
  1892.     which is operated by the University of Rochester (Michigan).  Both
  1893.     are maintained by Keith Petersen (w8sdz@TACOM-EMH1.Army.Mil or
  1894.     w8sdz@Vela.ACS.Oakland.Edu), so oak will probably be updated faster
  1895.     than any other mirror.  At Oak, the directories /pub/msdos/*
  1896.     correspond to Simtel's pd1:<msdos.*>, so the starter files mentioned
  1897.     above are downloadable as /pub/msdos/starter/simtel20.inf and
  1898.     /pub/msdos/filedocs/aaaread.me, mailserv.inf, and upload.inf.
  1899.  
  1900.     2) garbo = garbo.uwasa.fi [128.214.87.1]
  1901.  
  1902.     is located at the University of Vaasa in Finland and maintained by
  1903.     Timo Salmi (ts@uwasa.fi).  garbo and Simtel contain many of the same
  1904.     files, but there are many differences too.  Among them:  the
  1905.     directory structures differ greatly, and case is significant in
  1906.     directory and file names at garbo.
  1907.  
  1908.     3) wustl = wuarchive.wustl.edu [128.252.135.4]
  1909.  
  1910.     mirrors both garbo (in /mirrors4/garbo.uwasa.fi) and Simtel (in
  1911.     /mirrors/msdos).  As with any mirror site, it may lag by a day or
  1912.     two, so you may not want to try it on the same day you see an upload
  1913.     notice posted.
  1914.  
  1915.     4) others
  1916.  
  1917.     A comprehensive list of MS-DOS archive sites is downloadable as
  1918.     /pc/pd2/moder25.zip at garbo.
  1919.  
  1920.     For archie.au via Telnet (different from the Archie file-finding
  1921.     mail servers):  Oceanian users should try archie.au first.  Paul
  1922.     Brooks has written to say that it "mirrors garbo and simtel-20 (in
  1923.     /micros/pc/simtel-20, /micros/pc/garbo) as well as many other
  1924.     archives.  Telnetting to 'archie.au' and logging on as 'archie' (no
  1925.     password) will access the Oceanic ARCHIE server." Email Craig Warren
  1926.     (ccw@archie.au) for instructions if needed.
  1927.  
  1928. QA02. I have no ftp access.  How can I get files from the archives?
  1929.  
  1930.     (new: 2 Feb 1993) First, be _sure_ that you have no ftp access
  1931.     before trying email methods.  (Ask your sysadmin, or a knowledgeable
  1932.     user at your site.)  ftp is better for you because it's faster, and
  1933.     it uses less net resources too.
  1934.  
  1935.     When using an email server, make sure the Reply-to path in your
  1936.     message is valid.  If it's not, you'll get no reply from the server.
  1937.     Do wait a few days before assuming you're not going to get a
  1938.     response; some servers have long pending queues.  After a suitable
  1939.     wait, get your sysadmin's help to correct your reply-to, and send
  1940.     your message again.
  1941.  
  1942.     Occasionally a machine goes down for an extended period, which may
  1943.     prevent a timely reply to your message.  If you're sure your message
  1944.     bears a good reply path and you haven't got a reply in a week or so,
  1945.     you might send your message again, once.  Don't post it as an
  1946.     article in a newsgroup.
  1947.  
  1948.     For files from Simtel, see "How to order SIMTEL20 files via e-mail",
  1949.     posted monthly in comp.archives.msdos.announce; or send email
  1950.     containing only the word "help" to listserv@vm1.nodak.edu.
  1951.  
  1952.     The DEC Western Research Labs server will get files from any ftp
  1953.     site by ftp and then email them to you.  Send email containing
  1954.     "help" to ftpmail@decwrl.dec.com.
  1955.  
  1956. QA03. Can I get archives on CD-ROM?
  1957.  
  1958.     (rev: 24 May 1993) Copies of the SIMTEL20 MS-DOS, Macintosh and
  1959.     Unix-C collections (also of wuarchive, cica, and others) are
  1960.     available from Walnut Creek CDROM, 1547 Palos Verdes, Suite 260,
  1961.     Walnut Creek, CA 94596-2228, telephone (800) 786-9907 or +1 510
  1962.     674-0783, or FAX +1 510 674-0821, or email rab@cdrom.com.
  1963.  
  1964.     For a catalog of disks available, send email to info@cdrom.com, or
  1965.     ftp the catalog as /cdrom/catalog from cdrom.com.
  1966.  
  1967. QA04. Where do I find program <mumble>?
  1968.  
  1969.     (rev: 2 Feb 1993) There are several newsgroups to help;
  1970.     comp.binaries.ibm.pc.wanted is generally the best place to ask your
  1971.     question.  Please review the guidelines in "What other newsgroups
  1972.     should I know about?" in section 1, "General questions".
  1973.  
  1974.     Download and check the indexes from Simtel and garbo (see next Q).
  1975.     Unless what you're looking for is commercial software, there's a
  1976.     good chance it will be at one or both of those sites.
  1977.  
  1978.     The Archie servers maintain directories of many (not all) ftp sites
  1979.     worldwide.  You can Telnet to a server or client to search for
  1980.     files, or perform a search by email.  See the Anonymous FTP List,
  1981.     posted periodically in news.answers and other groups, for a list of
  1982.     Archie servers.
  1983.  
  1984. QA05. How can I check Simtel or garbo before I post a request for a
  1985.       program?
  1986.  
  1987.     (rev: 2 Feb 1993) Simtel and garbo have indexes of their contents,
  1988.     which you can download and then search off line.
  1989.  
  1990.     garbo's index file, /pc/INDEX, is an annotated list, frequently
  1991.     updated, of the MS-DOS files there; to save download time, get the
  1992.     packed form /pc/INDEX.ZIP.  The news file /pc/pd2/news-pd2 contains
  1993.     selected news on all MS-DOS directories at garbo.
  1994.  
  1995.     Simtel's index files, in pd1:<msdos.filedocs>, are updated several
  1996.     times a month.  SIMLIST.ZIP contains a list in text format.  But you
  1997.     may prefer the file SIMIBM.ZIP, which is comma-delimited for easy
  1998.     use with any of these search facilities:
  1999.  
  2000.     - Two downloadable search programs are SIMTEL35.ARC and
  2001.       SIMDIR22.ZIP.  Of the two, I find I use SIMDIR much more often.
  2002.  
  2003.     - dBASE III or IV users can load the index from SIMLIST.ZIP using
  2004.       instructions in SIMIBM.INF and SIMIBM.DB3.
  2005.  
  2006.     - PC-FILE users should get SIMIBM.HDR, which tells how to use
  2007.       SIMIBM.IBM.
  2008.  
  2009. QA06. How do I download and decode a program I found?
  2010.  
  2011.     (rev: 16 Mar 1993) See the "starter kit" in comp.binaries.ibm.pc,
  2012.     usually posted on the first and 15th of every month.  Most binaries
  2013.     are posted and sent through email in 'uuencode' format.  The starter
  2014.     kit contains a uudecode program to turn this file back into binary.
  2015.  
  2016.     If you can't wait (if?, bwaa-haa-haa), you can get the starter kit
  2017.     via ftp or email from rtfm.mit.edu, in the directory
  2018.     /pub/usenet/comp.binaries.ibm.pc as files
  2019.         v21inf02:_s.k,_C_S_s_K_v1.9.1_(p_01_01)
  2020.         v21inf04:_b.m,_B_s_G_t_B_V1.3_(p_01_01)
  2021.     For general instructions on rtfm.mit.edu, see "Where are FAQ lists
  2022.     archived?" in section C, "More information".
  2023.  
  2024.     If you're using Kermit, remember to set file type binary before
  2025.     issuing the send command.  By the way, the uuencoded file is bigger
  2026.     than the binary, so you'll save connect time if you can uudecode it
  2027.     and then download the binary file.
  2028.  
  2029. QA07. Where is UUDECODE?
  2030.  
  2031.     You can find it at Simtel and garbo, but it's easier to take it from
  2032.     the "starter kit" mentioned in the preceding Q.
  2033.  
  2034.     If you're logged in at a Unix site, there's almost certainly a
  2035.     uudecode there:  just type "uudecode" followed by a space and the
  2036.     file name.  The binary file is 25% smaller than the uuencoded file,
  2037.     so you'll save connect time if you can uudecode it on the Unix host
  2038.     and then download the binary file.  Remember: set file type binary.
  2039.  
  2040. QA08. Why do I get errors when extracting from a ZIP file I downloaded?
  2041.  
  2042.     (rev: 5 Apr 1993) There are many possible causes, but two of them
  2043.     probably account for 95% of all problems.
  2044.  
  2045.     1) File transmission:  You must tell the archive site to transfer
  2046.     .ZIP files in binary mode.  Depending on your software, you may also
  2047.     need to set your local software to receive files in binary mode.
  2048.  
  2049.     2) Unzipping program:  Make sure you aren't using an obsolete
  2050.     version.  In <9303290853.kp28285@tacom-emh1.army.mil> on 29 Mar
  2051.     1993, Keith Petersen, Simtel administrator, wrote:  "SIMTEL20 has
  2052.     standardized on the Info-ZIP group's ZIP and UNZIP because they are
  2053.     freely distributable and they have no restrictions on exporting.
  2054.     The latest version of Info-ZIP's ZIP and UNZIP can always be found
  2055.     in directory PD1:<MSDOS.ZIP> and will always have the name
  2056.     'Info-ZIP' in the description to make them easy to locate."  PKUNZIP
  2057.     version 1.10 may not unzip newer stuff from archive sites because
  2058.     site administrators have now embraced version 2.04.  Also see
  2059.     "What's the current version of UNZIP?" in section B, "Vendors and
  2060.     products".
  2061.  
  2062. section B. Vendors and products
  2063. ===============================
  2064.  
  2065. QB01. How can I contact Borland?
  2066.  
  2067.     (rev: 18 Apr 1993)  Borland has set up these email addresses.
  2068.     However, none of them is for technical support such as help with
  2069.     finding your own programming errors and explaining compiler
  2070.     messages.
  2071.  
  2072.     - bp7-info@borland.com will reply to any message with 17K of info on
  2073.       Borland Pascal with Objects 7.0 and Turbo Pascal 7.0.
  2074.  
  2075.     - customer-support@borland.com is for questions about prices and
  2076.       features of products, replacing bad or missing disks, info on
  2077.       upgrades, etc.  They do not accept emailed credit-card numbers.
  2078.  
  2079.     - bugs@borland.com will take "a well-documented bug report" and send
  2080.       an automated response, but will not give you a workaround or a
  2081.       scheduled fix date or even confirm that it is or is not considered
  2082.       a bug.  "The purpose of bugs@borland.com is to improve future
  2083.       products sooner, not as a substitute for tech support channels."
  2084.  
  2085.     Tech support is provided through Compuserve (GO BOR), by voice phone
  2086.     at +1 408 438 5300, by FAX at (800) 822-4269 in U.S. (use Touch-Tone
  2087.     voice phone), on a BBS at +1 408 439 9096, and by mail at
  2088.  
  2089.         Technical Support Department
  2090.         Borland International
  2091.         P.O. Box 660001
  2092.         Scotts Valley CA 95067-0001, USA.
  2093.  
  2094.     You'll need to give your product's name, version, and serial number.
  2095.  
  2096.     Borland's TechFax documents are also available for download:
  2097.         pd1:<msdos.turbo-c>bchelp10.zip from Simltel
  2098.         /pc/turbopas/bchelp10.zip from garbo.
  2099.     These documents are detailed answers to common questions about Turbo
  2100.     C and Borland C products, and aggregate about four times the size of
  2101.     this file.
  2102.  
  2103. QB02. How can I contact Microsoft?
  2104.  
  2105.     (rev: 18 Apr 1993) Individual employees of Microsoft (not MicroSoft,
  2106.     please!) post here sometimes.  Their addresses all take the form
  2107.     person@microsoft.com.  However, Microsoft as a company does not
  2108.     provide product support through the Internet, as far as I'm aware.
  2109.     Technical support through your modem is available on Compuserve (GO
  2110.     MICROSOFT) or via Microsoft's BBS at +1 206 936-6735 in the U.S., or
  2111.     +1 416 507-3022 in Canada.
  2112.  
  2113.     If you want to place an order or get general pre-sales information,
  2114.     call the appropriate sales and service number:
  2115.  
  2116.         U.S. end-user sales                   (800) 426-9400
  2117.         U.S. corporate/gov't/reseller/
  2118.                  educational sales            (800) 227-4679
  2119.         Canadian sales                        (800) 568-3503
  2120.         International sales                  +1 206 936-8661
  2121.  
  2122.     For tech support you must make an ordinary long-distance phone call.
  2123.     Microsoft has separate incoming phone numbers for many products.
  2124.     Since it's your nickel, first check your documentation to see if a
  2125.     phone number is listed.  Here are phone numbers (as of 1 June 1992)
  2126.     for a few products of most interest to the readers of this group:
  2127.  
  2128.         C/C++               (206) 635-7007
  2129.         MASM                (206) 646-5109
  2130.         DOS Upgrade Users   (206) 646-5104 (for 90 days after first call)
  2131.         Windows Users       (206) 637-6098
  2132.  
  2133.     If you can't find the direct number any other way, call the "master"
  2134.     numbers below or the sales numbers a few paragraphs above.  You'll
  2135.     get the "voice mail phone tree from h-ll" but you'll eventually get
  2136.     to the right department.  They don't provide technical assistance,
  2137.     but a voice menu will help you find the current phone number for the
  2138.     department you need.
  2139.  
  2140.         U.S. end-user product support         (206) 454-2030
  2141.         U.S. languages support                (206) 637-7096
  2142.  
  2143.     You can also write to Microsoft Product Support, 16011 NE 36th Way,
  2144.     Box 97017, Redmond WA 98073-9717, USA.
  2145.  
  2146. QB03. What's the current version of UNZIP?
  2147.  
  2148.     (rev: 13 June 1993)  As of April 1993, the administrators of garbo
  2149.     and Simtel are accepting uploads in the ZIP 2.0 format.  You can use
  2150.     the free Info-ZIP versions, or PKZIP 2.04g (not 2.04c or 2.04e).
  2151.     Simtel has standardized on the Info-ZIP versions for several
  2152.     reasons, as explained in an article posted 29 Mar 1993 in
  2153.     comp.archives.msdos.announce.
  2154.  
  2155.     The official site for the latest versions of Info-ZIP's Zip and
  2156.     unZip programs is quest.jpl.nasa.gov [128.129.75.43] in directory
  2157.     /pub.  Also downloadable are these files, in pd1:<msdos.zip> at
  2158.     Simtel and /pc/arcers at garbo (no source code at garbo):
  2159.  
  2160.         unz50p1.exe   UnZip 5.0p1 program and documentation
  2161.         unz50p1.zip   UnZip 5.0p1 source code
  2162.         zip19p1x.zip  Zip 1.9p1 .EXEs and docs (PKZIP 2.04 compatible)
  2163.         zip19p1.zip   Zip 1.9p1 source code (PKZIP 2.04 compatible)
  2164.  
  2165.     An advantage of the Info-ZIP versions is that are not restricted to
  2166.     MS-DOS.  Look at quest.jpl.nasa.gov for versions for all supported
  2167.     operating systems.  At Simtel, look in pd8:<misc.unix> and
  2168.     pd8:<misc.vaxvms> for unix and VAX/VMS versions; the source code in
  2169.     pd8:<misc.unix> also compiles under MS-DOS and VAX/VMS.
  2170.  
  2171.     PKZIP and PKUNZIP are shareware products of PKWARE Inc.  The current
  2172.     version is 2.04g, which is the third official version after 1.10.
  2173.     You can download them from PKWARE's bulletin board, +1 414 354 8670,
  2174.     or from garbo as /pc/arcers/pkz204g.exe.  U.S. law forbids U.S.
  2175.     archive sites from making them available.
  2176.  
  2177.     By the way, if you want to develop your own utilities, you will find
  2178.     the ZIP 2.0 data structures described in the downloadable file
  2179.     pd1:<msdos.zip>appnote.zip at Simtel.
  2180.  
  2181. QB04. What's in Borland Pascal/Turbo Pascal 7.0?
  2182.  
  2183.     You can send email to bp7-info@borland.com and get an automatic
  2184.     reply of the 17K information file from Borland, or the file is
  2185.     downloadable (6k, ZIPped) as /pc/turbopas/bp7-info.zip from
  2186.     garbo.uwasa.fi.
  2187.  
  2188. QB05. What's in Microsoft Visual C++?
  2189.  
  2190.     (new: 24 May 1993)  This is the replacement for Microsoft C/C++
  2191.     7.0.  It comes in Standard and Professional versions, as well as an
  2192.     upgrade from MSC 7.0.  The Professional upgrade is $139 in U.S. and
  2193.     includes all software but less than half the full set of manuals.
  2194.  
  2195.     According to Microsoft Sales, (800) 426-9400 in the U.S., the
  2196.     Professional edition can develop applications for Windows or good
  2197.     ol' DOS and includes the optimizing compiler; the Standard edition's
  2198.     compiler lacks the optimization and can't develop Windows
  2199.     applications.
  2200.  
  2201. QB06. Where is Microsoft C 8.0?
  2202.  
  2203.     There won't be an 8.0.  Visual C++ is the upgrade to C/C++ 7.0 (see
  2204.     previous Q).
  2205.  
  2206. section C. More information
  2207. ===========================
  2208.  
  2209. QC01. Are there any good on-line references for PC hardware components?
  2210.  
  2211.     (rev: 18 Apr 1993) I have heard good reports of HELPPC21, which is
  2212.     downloadable as
  2213.         pd1:<msdos.info>helppc21.zip at Simtel
  2214.         /pc/programming/helppc21.zip at garbo.
  2215.     There's an info file in the same directory, helppc21.inf.
  2216.  
  2217.     This hypertext system contains much information on ports and other
  2218.     hardware, as well as some overlap with Ralf Brown's interrupt list
  2219.     (see next Q).  It is shareware ($25).
  2220.  
  2221. QC02. Are there any good on-line references for PC interrupts?
  2222.  
  2223.     (rev: 6 June 1993)  The definitive work is Ralf Brown's interrupt
  2224.     list, which is packed with information on documented and
  2225.     (officially) undocumented BIOS and DOS interrupts, DOS tables, and
  2226.     interrupts hooked by many software packages.
  2227.  
  2228.     The interrupt list comes from CS.CMU.EDU [128.2.222.173] in
  2229.     /afs/cs/user/ralf/pub (switch there with a *single* command) as
  2230.     inter35a.zip, inter35b.zip, and inter35c.zip.  It's downloadable as
  2231.         pd1:<msdos.info>inter35*.zip from Simtel
  2232.         /pc/programming/inter35*.zip from garbo.
  2233.     These versions were uploaded in early June 1993; updates are
  2234.     announced every few months in comp.archives.msdos.announce.
  2235.  
  2236.     There is a book, {PC Interrupts:  A Programmer's Reference to BIOS,
  2237.     DOS, and Third-Party Calls} by Ralf Brown and Jim Kyle
  2238.     (Addison-Wesley; ISBN 0-201-57797-6).  This corresponds to INTER26
  2239.     with the most important new material from INTER27, so the on-line
  2240.     list contains more current information (and more information) than
  2241.     the book.
  2242.  
  2243. QC03. What and where is "Ralf Brown's interrupt list"?
  2244.  
  2245.     See the preceding Q.
  2246.  
  2247. QC04. Where can I find lex, yacc, and language grammars?
  2248.  
  2249.     The FAQ list of the comp.compilers newsgroup answers this for Basic,
  2250.     C, Pascal, and other languages.  See later in this section.
  2251.  
  2252. QC05. What's the best book to learn programming?
  2253.  
  2254.     Sorry, this FAQ list cannot settle religious arguments.
  2255.  
  2256.     Much of the heat over this topic arises because each person believes
  2257.     that the book that he or she learned from is the best book.  But my
  2258.     observation is that different people have very different experiences
  2259.     of the same book.  The only person who can tell you which is the
  2260.     best book for learning a given topic is you.
  2261.  
  2262.     Your best bet is to go to a fairly well-stocked bookstore when you
  2263.     have a couple of hours to spare.  Start at one end of the shelf and
  2264.     work your way methodically through every book that looks like it
  2265.     might cover what you want to learn.  Look at the tables of contents;
  2266.     read a page or two from each book.  Then make your decision.  If
  2267.     money is a problem, or if you're not sure of your choice, check out
  2268.     your top two or three from your library.
  2269.  
  2270. QC06. Where are FAQ lists archived?
  2271.  
  2272.     (rev: 27 Apr 1993) Very possibly the FAQ list you want is already at
  2273.     your site.  Check the newsgroup news.answers; if your site doesn't
  2274.     carry news.answers, check comp.answers, rec.answers, etc., according
  2275.     to the top-level name in the FAQ list's "home" newsgroup.  Articles
  2276.     are posted to the *.answers groups in a way that should make them
  2277.     last until the next versions are posted.  If they expire sooner at
  2278.     your site, you might want to lobby your sysadmin to treat the
  2279.     moderated *.answers groups as a special case and grant them longer
  2280.     expiry times than other groups.
  2281.  
  2282.     To ftp the FAQ lists, connect to rtfm.mit.edu, which is operated by
  2283.     Jonathan Kamens (jik@gza.com) at MIT.  Change to directory
  2284.     /pub/usenet/news.answers.  The name of the file that you want is the
  2285.     Archive-name from the top of the article.  For instance, to retrieve
  2286.     this article you would get msdos-programmer-faq/part4.
  2287.  
  2288.     By email (only if you have no ftp access, please), the server is
  2289.     mail-server@rtfm.mit.edu; file names omit the leading "/pub/".  For
  2290.     instructions about the mail server, send a message with "help" and
  2291.     "index" on different lines.
  2292.  
  2293.     Not just FAQ lists, but every article listed in the "List of
  2294.     Periodic Informational Postings" (LoPIP) can be obtained by ftp or
  2295.     email from rtfm.mit.edu.  If you have an old copy of an
  2296.     informational article, look for an "Archive-name" at the beginning;
  2297.     rtfm.mit.edu stores it under that name in /pub/usenet/news.answers.
  2298.     If the article has no Archive-name, check the first name on the
  2299.     Newsgroups line and change to that directory under /pub/usenet.
  2300.  
  2301. QC07. Where can I get the latest copy of this FAQ list?
  2302.  
  2303.     (rev: 22 Apr 1993)  It is posted to news.answers in such a way that
  2304.     it should stick around until the next version has been posted.
  2305.     Please check news.answers or comp.answers first, looking for the
  2306.     Subject line "comp.os.msdos.programmer FAQ".
  2307.  
  2308.     If the article has expired from your site's news.answers, or your
  2309.     site doesn't get news.answers, you can retrieve the latest version
  2310.     of this list as
  2311.         /pub/usenet/news.answers/msdos-programmer-faq/part* via ftp or
  2312.             email from rtfm.mit.edu; see previous Q
  2313.         pd1:<msdos.info>faqp*.zip from Simtel
  2314.         /pc/doc-net/faqp*.zip from garbo.
  2315.  
  2316. QC08. How do I use ftp?
  2317.  
  2318.     (new: 16 Mar 1993) I have been much impressed with {The Whole
  2319.     Internet User's Guide and Catalog} by Ed Krol (O'Reilly &
  2320.     Associates, ISBN 1-56592-025-2).  It gives lots of information on
  2321.     using ftp, email, Telnet, Archie, etc.  As a new user of ftp
  2322.     (January 1993), I found the information made me productive quickly.
  2323.  
  2324.     Disclosure:  Though I don't believe it has biased my judgment, you
  2325.     should know that O'Reilly sent me a free evaluation copy.
  2326.  
  2327.     You may also want to look for the "Beginner's Guide to FTP", posted
  2328.     periodically in comp.binaries.ibm.pc.  You can retrieve it from
  2329.     rtfm.mit.edu (see "Where are FAQ lists archived?", above), in
  2330.     /pub/usenet/comp.binaries.ibm.pc, as (hang on!)
  2331.     v21inf05:_b.m,_B_s_G_t_F_V1.7_(p_01_01) .
  2332.  
  2333. (end of comp.os.msdos.programmer FAQ)
  2334. -- 
  2335. Stan Brown, Oak Road Systems                    brown@Ncoast.ORG
  2336.  
  2337. Can't find FAQ lists?  ftp to 'rtfm.mit.edu' and look in /pub/usenet
  2338. (or email me >>> with valid reply-to address <<< for instructions).
  2339.