[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
        Function:       Interrupt()
        ---------
        FORCE Prototype:
        ----------------
                FUNCTION LOGICAL Interrupt PROTOTYPE
                   PARAMETERS VALUE UINT int_no,                ;
                        VALUE UINT ax,  VALUE UINT bx,  ;
                        VALUE UINT cx,  VALUE UINT dx,  ;
                        VALUE UINT si,  VALUE UINT di,  ;
                        VALUE UINT bp,  VALUE UINT ds,  ;
                        VALUE UINT es

        Description:
        ------------
        This is the function that everyone thinks about when they hear
        "Undocumented FORCE functions."  Well, it's about time to remove
        that "Undocumented" part.

        First, a REALLY quick assembly language primer:

        An Interrupt is exactly what you think it is.  It "interrupts"
        the CPU and has it attend to some task.  To call an interrupt
        (in assembly language), you say

                INT     21h             ; The major DOS interrupt



        This tells the CPU to stop and save what it's doing, and jump
        to some location specified at 0000:0084.  From there, it looks
        at the register AX, specifically the "top half," AH, and does
        a CASE statement on it.  For example, if AH were 4C, it would
        terminate the current program and return to DOS.  In assembly
        that would look like:

                MOV     AX,4C00h        ; The little h means Hexidecimal
                INT     21h


        To accomplish the same thing in FORCE, you would do:

                VARDEF
                        UINT    ax,bx,cx,dx,si,di,bp,ds,es
                ENDDEF

                AX = 0x4c00
                Interrupt( 0x21, ax, bx, cx, dx, si, di, bp, ds, es )

        That would effectively kill your program, and you'd just have
        to hope that DOS closed all of your file handles for you.  I
        don't recommend this method of shutting down.

        Another example:  if AH was 09, the interrupt would mean "print
        out a string pointed to by DS:DX."  This would be a little
        tougher in FORCE, but you could do it.

                String_to_Print = "Must End with a Dollar Sign! $"
                make_ptr( ds, dx, String_to_Print )
                ax = 0x0900
                Interrupt( 0x21, ax, bx, cx, dx, si, di, bp, ds, es )

        Note that the Interrupt() function will change the "register"
        values to what they were immediately after the interrupt
        returned.  Suppose that you wanted to know the free disk space
        on your C drive.  There's an interrupt service that will tell
        you: Int 21h/36h.  Here are the specs:

        Registers on Entry:
        ------------------
        AH = 36h
        DL = Drive code         ; 1 = A, 2 = B, 3 = C, etc

        Registers on Return:
        -------------------
        AX = Sectors per cluster        ; or 0xFFFF if error
        BX = Available clusters
        CX = Bytes per sector
        DX = Clusters per drive

        So, to get all of this information, you would do:

                ax = 0x3600
                dx = 0x0003
                interrupt( 0x21, ax, bx, cx, dx, si, di, bp, ds, es )
                if ax = 0xffff
                   ? "Error!"
                   quit
                endif

                *- And to calculate the available space, you do

                ? "available space on C:"
                ?? AX * BX * CX

        Interrupt() returns TRUE if the interrupt returned without the
        carry flag set.  Usually, the carry flag after an interrupt means
        that there was some kind of error.  If the carry flag was set,
        FALSE is returned.

See Also: Int_w_flags()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson