Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- FUNCky - <b>name:</b> <b>interrupt() - execute any software/hardware interrupt</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
  Name:     interrupt() - execute any software/hardware interrupt
  Usage:    interrupt(<int_num>)
  Params:   integer <int_num> - the interrupt to execute in decimal
            If you want to work in hexadecimal, you can also send
            the interrupt number as a hexadecimal string:

                 interrupt(33) is the same as interrupt("21")

  Returns:  nothing, all values are returned via the reg_XX()
            functions. The following register functions can
            be used to get or set register values.

            16 bit Register functions:

                      <value> = reg_ax([<val>])
                      <value> = reg_bx([<val>])
                      <value> = reg_cx([<val>])
                      <value> = reg_dx([<val>])
                      <value> = reg_es([<val>])
                      <value> = reg_ds([<val>])
                      <value> = reg_si([<val>])
                      <value> = reg_di([<val>])
                      <value> = reg_bp([<val>])

            8 bit register functions:

                      <value> = reg_ah([<val>])
                      <value> = reg_al([<val>])
                      <value> = reg_bh([<val>])
                      <value> = reg_bl([<val>])
                      <value> = reg_ch([<val>])
                      <value> = reg_cl([<val>])
                      <value> = reg_dh([<val>])
                      <value> = reg_dl([<val>])

                 To load a register before your interrupt call
                 place the value inside the parenthesis of
                 the register function you need to load. If the
                 interrupt call requires an 8 in the AX register,
                 you can load the register as follows:

                      reg_ax(8)
                      interrupt(??)

                 To retrieve the value after the interrupt, (such as
                 when you get the DOS version), do not pass an
                 argument to the appropriate register function and
                 it's contents will be returned. You can assign it
                 to a memvar. Please note that all register values
                 are returned in DECIMAL, not hexadecimal. In the
                 case of the carry flag function (reg_cf()), a
                 logical value is returned.

            Flag functions:

                      <logical> = reg_cf()
                      <binary>  = reg_flags()

                 The flag functions are used only to retrieve
                 the flag status after an interrupt. For example,
                 the reg_cf() function will return logical .T. if
                 the carry flag was set by a DOS function.

                 The reg_flags() function returns the entire flags
                 register as a 16 bit unsigned integer. You can use
                 the test() function to test any bit in the flags
                 register.

 ---------------------------------- Example ---------------------------------

            * Use DOS interrupt to print a string, DOS function
            * 9 prints a string that is terminated by a dollar ($)
            * sign.....:

                 * here's the string to print
                 string = "This is the string to print...$"

                 * register DS needs the segment of string
                 reg_ds(seg(string))

                 * register DX needs the offset
                 reg_dx(off(string))

                 * register AH needs the DOS function #
                 reg_ah(9)

                 * execute the DOS interrupt (21h) to print the
                 * string to standard output
                 interrupt(33)       && (decimal 33 == 21h)

  Example 2:     Use DOS interrupt 21h (33 decimal) to get the
                 DOS version number:

                 * register AH needs to contain a 30h
                 reg_ah("30")

                 * DOS interrupt 21h (33 decimal)
                 interrupt("21")

                 * registers AL and AH now contain the
                 * major and minor version number
                 major = reg_al()
                 minor = reg_ah()

                 ? "Your DOS version number is: "+;
                   ltrim(str(major))+"."+ltrim(str(minor))

  Warning!: Refer to the DOS Technical Reference manual and the
            PC BIOS technical reference manual if you want
            information on the various interrupts available to
            you. Also, the Programmers Guide to the IBM PC by
            Peter Norton contains a wealth of information on
            DOS and BIOS interrupts.

See Also: test() seg() off() peek() poke() peekstr()

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