[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
        Optimizing your Code
        -----------------------------------------------------------------
        FORCE generates the tightest, fastest code of all the Xbase
        compilers that I've seen.  But, if your executable isn't just
        quite small enough for you, here are some tips:

        Specify all string lengths in your global VARDEF
                If you don't the string will take up 255 characters of space.

        Turn off stack checking (the /n option)
                This will save you about %1 of space, and probably an equal
                amount of run-time.

        Watch out for DATA.HDR.  If just #include it, you add an
        automatic 22K to your program.  The actual perpetrators of this
        crime are the variables __exit_status, which adds ~3K, and
        __field_eof, which adds the other ~19K.  So, if you've been
        using DATA.HDR for __color_std & __color_enhcd, then you should
        think about not including data.hdr, and just putting the
        variables in your own VARDEF EXTERN.

        Another memory-hogging header file is MEMO.HDR, which will add
        about ~25K to your executable.  However, there's not much you
        can do about it if you use the MEMO functions.  The good news
        is that a lot of the functions included when you #include DATA.HDR
        AND MEMO.HDR are the same, so you end up with a net gain of only
        (only?) ~28K.

        This probably applies to some other headers, but I'm pretty sure that
        data.hdr is the worst.

        Debugging Tip
        -----------------------------------------------------------------
        Most FORCE functions usually push 14 bytes of data on the stack
        when they're called.  They save BP, ES, DI, DS, and SI.  Each of
        those register values are 2 bytes (or 1 word), making 10 bytes
        total.

        Knowing this, you can look at your local variables by examining
        the stack, because that's where FORCE allocates all of its local
        memory from.  For example, if you have a function that looks like:

        PROCEDURE Mr_Function
                VARDEF
                        int                             x
                        int                             y
                ENDDEF

        X is going to be at SS:[BP - 10d], (or SS:[BP - 0ah] in hex),
        and Y is going to be at SS:[BP - 12d]
        If you use SYMDEB as your debugger, you can just type
        -e ss:bp-a
        and it'll show you the value of X.  If this information is going
        to be of any use to you, you need to know the byte lengths of
        the FORCE data types, so here they are:

        BYTE                    1
        INT, UNIT               2
        LONG, ULONG             4
        LOGICAL                 2
        DBL                     8

        Just remember that CHAR strings are also allocated from the stack,
        and are of their specified length or 255 otherwise.


See Also: General Miscellaneous Third_party Error_messages Other_linkers/compilers TSR_bloat
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson