
  <SI>mple <C>ompiler (SIC32.DLL)
  version 1.02.01
  by @L.chemist (Andrey A. Meshkov)

  SIC32 was designed to compile math expressions at run-time.

  ------------------------------------------------------------------------------

  ALGORITHM

  SIC32 makes his job in two steps:
  .1 converts input string to RPN string
     operation priority
       (         = 0
       )         = 1
       , ;       = 2
       + -       = 3
       * /       = 4
       ^ **      = 5 power(x,y)
       unary -   = 6
       function  = 7
  .2 converts RPN string to executable code

  ------------------------------------------------------------------------------

  FILES

  .\
    .0 readme
    .1 sic32.asm  - main project file
    .2 sic32.inc  - definitions
    .3 sic32m.asm - common macro instructions
    .4 sic32c.asm - macro instructions used to generate code
    .5 sic32p.asm - some functions
    .6 sic32f.asm - native function set
    .7 sic32e.asm - export functions
    .8 system.asm - some useful macro instructions
    .9 copy.bat   - copy sic32.dll to test programs location

  .\delphi\
    .1 sic32.pas  - SIC32 interface module

    .2 test.dpr   - delphi 4-5-6 example project of SIC32 usage (main example).
       test.dof
       test.cfg
       test.res
       sic32m.dfm - main form
       sic32m.pas
       sic32m.ddp
       sic32u.pas - user defined functions

  .\fasm\
    .1 test.asm   - fasm example of SIC32 usage. very simple (no GUI).
                    just change expression in test.asm code & run.
                    
  ------------------------------------------------------------------------------

  EXPORT FUNCTIONS

  .0  struct s_sic
        .data dd ? ; data segment offset (variables)
        .code dd ? ; code segment offset
        .size dd ? ; generated code size
      ends

  .1 <init> sic
     allocate memory for data segment and assign predefined constants
     -> sic : s_sic structure pointer
     <- eax : variable table item count

  .2 <done> sic
     free memory previously allocated for data & code segments
     -> sic : s_sic structure pointer

  .3 <funtac>
     create global function table
     <- eax : function table item count

  .4 <funtaf>
     destroy global function table

  .5 <afun> name, offset, param, csize
     add (set) user defined function
     if function already defined, set data (offset, param, csize)
     -> name   : function name (zero terminated string)
     -> offset : function offset
     -> param  : function parameter count
     -> csize  : function code size
                 if csize > 0, compiler will put in code csize - 1 bytes
                 (excluding trailing RET instruction) from offset
                 instead of function call
     <- eax    : >0, function count; =0, error

  .6 <avar> sic, name, offset
     add (set) user defined variable
     if variable already defined, set data (offset)
     -> sic    : s_sic structure pointer
     -> name   : variable name (zero terminated string)
     -> offset : variable offset
     <- eax    : >0, variable count; =0, error

  .7 <compile> sic, s
     compile string
     -> sic : s_sic structure pointer
     -> s   : string to compile
     <- eax : >0, generated code size; =0, error

  .8 <exec> sic, err
     execute code (unsafe mode, fast)
     -> sic   : s_sic structure pointer
     <- st(0) : result (return 0 on error)
     <- err   : error code (0, valid result; <>0, error)

  .9 <safexec> sic, err
     execute code (safe mode, slow)
     -> sic   : s_sic structure pointer
     <- st(0) : result (return 0 on error)
     <- err   : error code (0, valid result; <>0, error)
                high order word of eax = 0xFFFF
                ax and 0x08 = OE flag
                ax and 0x04 = ZE flag
                ax and 0x01 = IE flag

  ------------------------------------------------------------------------------

  SOME NOTES (unsorted)

  .0 SIC32 is subject of permanent evolution

  .1 Valid symbols for function or variable name are 
     '.', '@', '_', '`', 'A'..'Z', 'a'..'z', '0'..'9'.
     First symbol can't be a digit.

  .2 SIC32 is case insensitive.

  .3 Maximum length of function name = 19 symbols.
     Maximum function count = 255.
     Maximum length of variable name = 11 symbols.
     Maximum variable count = 63.
     Maximum token count = 1365
     Token is function, variable, constant, ",", ";", "(" or ")"

  .4 All variables and numbers are 64-bit float (double) values.

  .5 Declare user defined functions with no parameters or
     use cdecl calling conversion.

  .6 Be sure you really know what you do
     passing code size (csize) parameter to <afan> greater than 0.

  .7 SIC32 uses process heap for memory allocations

  .8 Minimum size of generated code = 17 bytes (expression is single constant).
     Maximum available code size = 48K

  ------------------------------------------------------------------------------
