Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Peter Norton Programmer's Guide - Norton Guide http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]

  The address associated with interrupt 23H (decimal 35) points to the
  interrupt-handling routine that DOS invokes in response to the Ctrl-C key
  combination. Thus interrupt 23H is intended to be executed only by DOS,
  not by an application program. A few old-fashioned programs, such as the
  DOS editor EDLIN, use Ctrl-C as a command keystroke, but in most
  applications the Ctrl-C combination signals that the user wants to
  interrupt an ongoing process.

  DOS is a bit quirky about when it will respond to a Ctrl-C keystroke.
  Normally, DOS acts on a break only when it is reading from or writing to a
  character I/O device (the screen, keyboard, printer, or communications
  port). However, the BREAK ON command allows DOS versions 2.0 and later to
  act on Ctrl-C at the time of most other DOS system calls.

  DOS's default Ctrl-C handler terminates the program or batch file you are
  executing. However, if your program provides its own interrupt 23H
  handler, it can have DOS take any action you want.

  In general, a Ctrl-C handler can take three different courses of action:

  .  It can perform some useful action, such as setting a flag, and then
     return to DOS with an interrupt return (IRET) instruction. In this
     case, DOS picks up where it left off, without terminating your
     program's execution.

  .  It can set or clear the carry flag and then return to DOS with a far
     return instruction (RET 2) that discards the flags pushed on the stack
     when the interrupt 23H handler was called by DOS. If the carry flag is
     set, DOS terminates the interrupted program. If the carry flag is
     clear, DOS continues execution.

  .  It can keep control without returning to DOS. This option is tricky,
     however, because you don't usually know what was on the stack at the
     moment DOS detected the Ctrl-C keystroke. An interrupt 23H handler that
     doesn't return to DOS should generally restore the stack pointer
     register (SP) to a predetermined value. It should also execute
     interrupt 21H, function 0DH, to flush DOS file buffers so that the DOS
     disk I/O system will be in a known state.

  The usual reason to write your own Ctrl-C handler is to let your program
  handle a keyboard break itself. Even if you want your program to terminate
  immediately after Ctrl-C is pressed, you may still need to clean up before
  your program terminates. For example, if you use interrupt 21H, functions
  0FH or 16H, to open a file, you should write your own Ctrl-C handler to
  close it because the default DOS Ctrl-C handler won't do so. Also, if you
  installed your own interrupt handlers for ROM BIOS or hardware interrupts,
  the DOS Ctrl-C handler won't restore them before it terminates your
  program. Again, your Ctrl-C handler should do this if necessary.

  If you do write your own Ctrl-C handler, don't forget the relationship
  between Ctrl-C and the keyboard Ctrl-Break combination. When you press
  Ctrl-Break, the ROM BIOS keyboard interrupt handler generates interrupt
  1BH. DOS's interrupt 1BH handler inserts a Ctrl-C key code into the
  keyboard input buffer. The next time DOS checks the keyboard buffer, it
  finds Ctrl-C and executes interrupt 23H. Thus, in effect, pressing
  Ctrl-Break has the same effect as pressing Ctrl-C, except that DOS detects
  the break generated by Ctrl-Break without first processing the intervening
  characters in the keyboard buffer.

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson