    <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/">
     <channel>
        <title>ACCU  :: MSDOS Interrupts</title>
        <link>https://members.accu.org/index.php/articles/726</link>
        <description>Professionalism in Programming</description>
        <dc:language>en-us</dc:language> 
        <dc:creator>Administrator</dc:creator> 
        <admin:generatorAgent rdf:resource="http://www.xaraya.org" /> 
        <admin:errorReportsTo rdf:resource="mailto:webeditor@accu.org" />
       <sy:updatePeriod>hourly</sy:updatePeriod>
       <sy:updateFrequency>1</sy:updateFrequency>
       <docs>http://backend.userland.com/rss</docs>




<div class="xar-mod-head"><span class="xar-mod-title">Programming Topics + CVu Journal Vol 8, #2 - Apr 1996</span></div>

<table border="0" cellpadding="1" cellspacing="0">
    <tbody>
    <tr>
        <td valign="top">
            Browse in :
       </td>
       <td valign="top">

                                            <a href="https://members.accu.org/index.php/articles/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c13/">Topics</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c65/">Programming</a>
<br />

                                            <a href="https://members.accu.org/index.php/articles/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c76/">Journals</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c77/">CVu</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c136/">082</a>
<br />

                                            <a href="https://members.accu.org/index.php/articles/c65-136/">Any of these categories</a>

                    -                        <a href="https://members.accu.org/index.php/articles/c65+136/">All of these categories</a>
<br />
</td>
   </tr>
   </tbody>
</table>




<div class="xar-error">
   <p>
 <strong>Note:</strong> when you create a new publication type,
the articles module will automatically use the templates
<em>user-display-[publicationtype].xt</em>
and <em>user-summary-[publicationtype].xt</em>.
If those templates do not exist when you try to preview or display a new article,
you'll get this warning :-)  Please place your own templates in themes/<em>yourtheme</em>/modules/articles . The templates will get the extension .xt there. </p>
</div>
<div class="xar-norm xar-standard-box-padding">
   <h1><strong>Title:</strong>&nbsp;MSDOS Interrupts</h1>
<p><strong>Author:</strong>&nbsp;</p>
<p>
<strong>Date:</strong> 03 April 1996 13:15:27 +01:00 or Wed, 03 April 1996 13:15:27 +01:00</p>
<p><strong>Summary:</strong>&nbsp;</p>
<p><strong>Body:</strong>&nbsp;<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e18" id="d0e18"></a>MSDOS Services
:</h2>
</div>
<div class="sect2" lang="en">
<div class="titlepage">
<h3><a name="d0e22" id="d0e22"></a>Some background
Information</h3>
</div>
<p>Programs access MS-DOS services by using a set of interrupts,
The Interrupts <tt class="literal">20H</tt> through <tt class=
"literal">3FH</tt> are reserved for use by MS-DOS. Only 10 of these
interrupts can be used in programs, most MS-DOS services are
invoked in the same way as the BIOS services coveredlast time.
Through one 'umbrella' Interrupt <tt class="literal">21H</tt>
(<tt class="literal">33 dec</tt>), you can access a variety of
MS-DOS functions by specifying a function number in register
<tt class="literal">AH</tt> when you call Interrupt <tt class=
"literal">21H</tt>.</p>
<p>The MS-DOS services have a large selection of Disk Orientated
Services, so think of MS-DOS as a library of disk operations placed
at your service.</p>
<p>In the previous article we used <tt class="literal">int86()</tt>
to invoke the interrupts when you are accessing MS-DOS interrupts
you can use <tt class="literal">intdos()</tt> to access interrupt
<tt class="literal">0x21</tt> as described above.</p>
<p>I also use <tt class="literal">intdosx()</tt>. The difference
between <tt class="literal">intdos()</tt> and <tt class=
"literal">intdosx()</tt> is that <tt class="literal">intdosx()</tt>
copies the <tt class="literal">segregs -&gt;ds</tt> and <tt class=
"literal">segregs -&gt;es</tt> values into the corresponding
registers before invoking the DOS function.</p>
<p>This program retrieves the MS-DOS version numbers and OEM
numbers by using the <tt class="literal">30H</tt> function.</p>
<pre class="programlisting">
#include &lt;dos.h&gt;
#include &lt;stdio.h&gt;
#include &lt;conio.h&gt;
int main(void) {
  union REGS inregs, outregs; 
  inregs.h.ah=0x30;  // Specify the MSDOS Version,etc. Function Number.
  inregs.h.al=0;  // Specify an input register. 
  intdos(&amp;inregs,&amp;outregs);  // Invoke the MS-DOS interrupt.
  clrscr();
  printf(&quot;MS-DOS Major Version Number :%d\n&quot;,outregs.h.al);
  printf(&quot;MS-DOS Minor Version Number :%d\n&quot;,outregs.h.ah);
  printf(&quot;OEM Number : %d&quot;,outregs.h.bh);
  return 0;
}
</pre>
<p>This program gets the Drive C information by using the
<tt class="literal">1BH</tt> Function.</p>
<pre class="programlisting">
#include &lt;dos.h&gt;
#include &lt;stdio.h&gt;
#include &lt;conio.h&gt;
int main(void) {
  union REGS inregs, outregs;
  inregs.h.ah=0x1B; // Specify the Drive Information Function
  intdos(&amp;inregs,&amp;outregs); // Invoke the Interrupt
  clrscr();
  printf(&quot;Drive C Information\n&quot;);
  printf(&quot;Sectors per Cluster : %d\n&quot;,outregs.h.al);
  printf(&quot;Bytes per Sector : %d\n&quot;,outregs.x.cx);
  printf(&quot;Total Clusters on Disk : %d&quot;,outregs.x.dx);
  return 0;
}
</pre>
<p>This program uses the MS-DOS Disk Services. It uses the Create
Directory Function <tt class="literal">39H</tt> and then uses the
Function <tt class="literal">3BH</tt> which changes the working
directory.</p>
<pre class="programlisting">
#include &lt;stdio.h&gt;
#include &lt;dos.h&gt;
#include &lt;conio.h&gt;
int main(void) {
  char directory[80];
  union REGS inregs,outregs;
  struct SREGS segregs;
  clrscr();
  inregs.h.ah=0x39;  // Specify the Create Directory Function
  printf(&quot;Enter The Directory Name to Create : &quot;);
  gets(directory);
  inregs.x.dx = FP_OFF(directory);  // Gets a Far Address Offset 
  segregs.ds = FP_SEG(directory);  // Gets a Far Address Segment
  intdosx(&amp;inregs, &amp;outregs, &amp;segregs);  // Invoke the Interrupt
  if (outregs.x.cflag)  // If there has been an error...
    printf(&quot;An Error occured while Creating the Directory.\n&quot;);
  else
    printf(&quot;Directory Successfully Created.\n&quot;);
  inregs.h.ah=0x3B;  // Specifies the Change Directory Function
  intdosx(&amp;inregs, &amp;outregs, &amp;segregs);
  if (outregs.x.cflag) printf(&quot;No Such Directory.\n&quot;);
  else printf(&quot;Directory Successfully Changed.\n&quot;);
  return (0);
}
</pre>
<div class="sidebar">
<p>Darren is focusing on the interrupt aspect so I will leave it to
someone else to clean up the code, particularly this last program.
What are the coding defects? Well I'll leave that to you to
find.</p>
</div>
<p>I think I have covered the basic idea and usage of interrupts
and I hope that it has been of some use or help to you!.</p>
<p>If you have any problems don't hesitate to contact me, and I'll
try my best to help.</p>
</div>
</div>
</p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
