Journal Articles

CVu Journal Vol 8, #2 - Apr 1996 + Programming Topics
Browse in : All > Journals > CVu > 082 (9)
All > Topics > Programming (877)
Any of these categories - All of these categories

Note: when you create a new publication type, the articles module will automatically use the templates user-display-[publicationtype].xt and user-summary-[publicationtype].xt. 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/yourtheme/modules/articles . The templates will get the extension .xt there.

Title: MSDOS Interrupts

Author: Administrator

Date: 03 April 1996 13:15:27 +01:00 or Wed, 03 April 1996 13:15:27 +01:00

Summary: 

Body: 

MSDOS Services :

Some background Information

Programs access MS-DOS services by using a set of interrupts, The Interrupts 20H through 3FH 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 21H (33 dec), you can access a variety of MS-DOS functions by specifying a function number in register AH when you call Interrupt 21H.

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.

In the previous article we used int86() to invoke the interrupts when you are accessing MS-DOS interrupts you can use intdos() to access interrupt 0x21 as described above.

I also use intdosx(). The difference between intdos() and intdosx() is that intdosx() copies the segregs ->ds and segregs ->es values into the corresponding registers before invoking the DOS function.

This program retrieves the MS-DOS version numbers and OEM numbers by using the 30H function.

#include <dos.h>
#include <stdio.h>
#include <conio.h>
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(&inregs,&outregs);  // Invoke the MS-DOS interrupt.
  clrscr();
  printf("MS-DOS Major Version Number :%d\n",outregs.h.al);
  printf("MS-DOS Minor Version Number :%d\n",outregs.h.ah);
  printf("OEM Number : %d",outregs.h.bh);
  return 0;
}

This program gets the Drive C information by using the 1BH Function.

#include <dos.h>
#include <stdio.h>
#include <conio.h>
int main(void) {
  union REGS inregs, outregs;
  inregs.h.ah=0x1B; // Specify the Drive Information Function
  intdos(&inregs,&outregs); // Invoke the Interrupt
  clrscr();
  printf("Drive C Information\n");
  printf("Sectors per Cluster : %d\n",outregs.h.al);
  printf("Bytes per Sector : %d\n",outregs.x.cx);
  printf("Total Clusters on Disk : %d",outregs.x.dx);
  return 0;
}

This program uses the MS-DOS Disk Services. It uses the Create Directory Function 39H and then uses the Function 3BH which changes the working directory.

#include <stdio.h>
#include <dos.h>
#include <conio.h>
int main(void) {
  char directory[80];
  union REGS inregs,outregs;
  struct SREGS segregs;
  clrscr();
  inregs.h.ah=0x39;  // Specify the Create Directory Function
  printf("Enter The Directory Name to Create : ");
  gets(directory);
  inregs.x.dx = FP_OFF(directory);  // Gets a Far Address Offset 
  segregs.ds = FP_SEG(directory);  // Gets a Far Address Segment
  intdosx(&inregs, &outregs, &segregs);  // Invoke the Interrupt
  if (outregs.x.cflag)  // If there has been an error...
    printf("An Error occured while Creating the Directory.\n");
  else
    printf("Directory Successfully Created.\n");
  inregs.h.ah=0x3B;  // Specifies the Change Directory Function
  intdosx(&inregs, &outregs, &segregs);
  if (outregs.x.cflag) printf("No Such Directory.\n");
  else printf("Directory Successfully Changed.\n");
  return (0);
}

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!.

If you have any problems don't hesitate to contact me, and I'll try my best to help.

Notes: 

More fields may be available via dynamicdata ..