Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

Lecture 37

Programming DOS, BIOS,


Hardware with C/C++:
BIOS and DOS Interrupt Programming

Dan Stormont
Utah State University
4/18/05
Overview
• Programming BIOS Interrupts
• Using int86 to access BIOS INT 10h
• Using int86 to access BIOS INT 12h
• Using int86 to access BIOS INT 16h
• Programming DOS INT 21h in C/C++
• Accessing segment registers
• Accessing the carry flag
Programming BIOS
Interrupts
• The REGS structure allows access to 8- and 16-
bit registers, if defined by the compiler
Programming BIOS
Interrupts
• The REGS structure from
the Mazidi and Mazidi
text
Programming BIOS
Interrupts
• The REGS structure as
#ifndef _REG_DEFS
defined in Borland C++ 4.0 #define _REG_DEFS

– This is in the dos.h header struct WORDREGS {


unsigned int ax, bx, cx, dx, si, di, cflag, flags;
};

struct BYTEREGS {
unsigned char al, ah, bl, bh, cl, ch, dl, dh;
};

union REGS {
struct WORDREGS x;
struct BYTEREGS h;
};

struct SREGS {
unsigned int es;
unsigned int cs;
unsigned int ss;
unsigned int ds;
};

struct REGPACK {
unsigned r_ax, r_bx, r_cx, r_dx;
unsigned r_bp, r_si, r_di, r_ds, r_es, r_flags;
};

#endif /* _REG_DEFS */
Programming BIOS
Interrupts
• A compiler that I’ve found to
work under Windows XP that
you can get access to is
Borland Turbo C or Turbo C++
• Go to the Borland website and
download either Turbo C 2.01
or Turbo C++ 1.1 from the
Borland museum
• It’s a free download and it does
work for the examples in the
book under Windows XP
Using int86 to access
BIOS INT 10h
Using int86 to access
BIOS INT 10h
Using int86 to access
BIOS INT 12h
Using int86 to access
BIOS INT 16h
Programming
DOS INT 21h in C/C++
Accessing Segment
Registers
Accessing the Carry Flag
• The carry flag (only) can be accessed
using int86, int86x, intdos, or intdosx and
the following instruction
Next Class

• On Wednesday, we’ll cover PC Hardware


Programming

You might also like