
FreeDOS Resident Calculator
---------------------------


0. Table of contents
--------------------

  0. Table of contents
  1. License
  2. Short description
  3. Command line parameters
  4. Using FDRC
  5. Controls
  6. Known bugs and features
  7. Credits


1. License
----------

  FreeDOS Resident Calculator, Copyright (c) 2006 Oleg O. Chukaev

  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License
  as published by the Free Software Foundation; either version 2
  of the License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  02111-1307, USA.
 
  FreeDOS is a trademark of Jim Hall


2. Short description
--------------------

      FreeDOS Resident Calculator (FDRC) is a resident calculator for
  programmers.  I wrote FDRC because I need some features missing in other
  TSR calculators.  This calculator will be quite useless for those who use
  Windows or Linux -- FDRC written for old good DOS (and FreeDOS).

  FDRC lacks following features:
    * Built-in help.
    * Fraction numbers support.  (Perhaps fixed point 32:32 or (better) 48:16
      will be implemented in future versions.)
    * Functions like sin, cos, ln, etc.
    * Support for graphics and monochrome video modes.
    * Mouse support.

  FDRC has following features:
    * FDRC works with 32-bit integer numbers.
    * Expressions in reverse polish notation, eg:
      2 + 3 == 2 3 +
      2 - 9 + 8 * 5 == 2 9 - 8 5 * +
      (9 / (1 + 8)) * 5 == 9 1 8 + / 5 *
    * FDRC supports following operations:
      + -- addition              & -- bitwise AND
      - -- subtraction           | -- bitwise OR
      * -- multiplication        ^ -- bitwise XOR
      / -- division              < -- logical shift left
      % -- remainder             > -- logical shift right
      \ -- square root           { -- arithmetical shift left
      ~ -- bitwise NOT           } -- arithmetical shift right
      ` -- negation
      Operations \, ~ and ` -- unary: not(sqrt(123)+(-12)) == 123 \ 12 ` + ~.
    * FDRC show result simultaneously in decimal, hexadecimal, binary and
      string format.
    * FDRC support numerous color video modes, including 40x12, 80x25,
      90x60, 132x25, 132x43.
    * FDRC work in resident and non-resident modes.
    * Color highlighting for different parts of result.
    * History.


3. Command line parameters
--------------------------

      FDRC supports the following command line parameters (you can use `/'
  instead of `-'):

  -h        -- short help.

  -?        -- same as -h.

  -H        -- help on keyboard and oprerators usage.

  -a        -- calculate result after pressing any key, not only after pressing
               <Enter>.  Note: current string will be stored in history
               only after pressing <Enter>, even in this mode.

  -c        -- clear input line when pressing any alpha-numeric key
               _immediately_ after popup.  Pressing <Delete>, <Backspace>
               or any such keys don't clears input line.

  -e        -- allow loading 2nd, 3rd,... copy of FDRC into memory.

  -n        -- non-resident mode.
              
  -w        -- prevent loading FDRC into UMB.  By default FDRC loads itself
               into UMB if they available.

  -u        -- unload.  If INT 09h and/or INT 10h intercepted by other
               program, FDRC will print warning message and exit.

  -D        -- temporarily disables FDRC.

  -E        -- enables FDRC.

  -q        -- quiet mode.  If you try to call FDRC within graphics-mode
               program, FDRC will beep twice.  If you reached 1st or last
               entry in history, FDRC will beep once.  -q switch disables
               all such sounds.

  -l:number -- column of left side of FDRC's window.
  -t:number -- row of top side of FDRC's window.
               number -- decimal number >= 0.

  -k:number -- scancode of activation key (hexadecimal).  See `rbil_i09.txt'
               for details.  Default value -- 35h (`/').

  -s:number -- code of shift keys (hexadecimal).

               Right Shift:  01
               Left Shift:   02
               Ctrl (any):   04
               Alt (any):    08
               Scroll Lock:  10
               Num Lock:     20
               Caps Lock:    40
               Insert:       80

               Default value -- 04 (Ctrl).  For example: RightShift+Alt ==
               == 1 + 8 == 9.

  -y:number -- size of the history buffer (decimal).  Default value -- 0.
               Minimal values is 200, maximal is 16000 (can be changed in
               `config.inc').


4. Using FDRC
-------------

      Type `fdrc' to run calculator.  It will terminate and stay resident.
  Use Ctrl-/ to popup.  You can change hot-key: see chapter 3 for details.
  Type `fdrc -n' to run calculator in non-resident mode.

      When FDRC is active, you can use some keys: see chapter 5 for details.
  Use input line to enter expressions.  In expressions you can use hexadecimal
  numbers (string of hex digits, w/o any prefixes or suffixes, decimal numbers
  (w/ suffix `.'), binary numbers (w/ suffix `@'), and strings (in double
  quotes, as in C).

      In the last line of FDRC's window you can see messages about errors:

  * Parse error -- displayed when parser encountered illegal character,
    such as `.' in the string `123ab87.' or `j' in `12j6'.  Illegal character
    highlighted.

  * Stack not empty -- some numbers still on the stack after calculating
    result.  I.e. there are too few operators.

  * Stack underflow -- there are too many operators in expression.  Operator,
    which attempted to pop numbers from the stack, highlighted.

      Last line also contains history indicator: number of current string
  and arrow.  Arrow looks like diamond if there are no strings in the history.
  Up-arrow indicates that you can press Up key to get previous string,
  down-arrow -- you can press Down key to get next string, double-edged
  arrow -- you can press both Up and Down keys.

      After selecting required string by Up/Down keys you can edit it.
  Note that string in history buffer remains unchanged.  You edit the
  copy of this string.

      You can use up to 10 registers for temporary results storage.
  Operator :x saves result in the register x, where x is digit in the
  range 0..9.  Expression $x substitutes the value of the register x
  into whole expression.  For example:
  123. 3 - :0  -- calculates 123 - 3 and saves result in the reg.0;
  29 :8 :9 12. * :1  -- calculates 29h * 12, 29h is saved in the regs 8
  and 9, the result saved in the reg.1; 7 $5 ^  -- calculates 7 XOR reg.5.

      It is possible to calculate several expressions in the one line.
  In this case expressions are separated by semicolons.  Result of the
  whole expression will be equal to the result of the last subexpression.
  Results of intermediate expressions can be stored in the registers and
  used later.  For example:
  123. 3 - :0; 8; 89 9 - $0 * :4; af 67; 7 $0 ^ $4 |  -- 1) FDRC calculates
  123 - 3h, result -> reg.0; 2) calculates the value of the number 8;
  3) calculates (89h - 9h) * reg.0, result -> reg.4; 4) _tries_ to
  calculate the value of the expression af 67, but this calculation fails
  due to missing operator, semicolon flushes stack of the evaluator, so
  this expression will be ignored; 5) calculates (7 XOR reg.0) OR reg.4.


5. Controls
-----------

      You can use the following keys:

  Numerals and letters -- enter numbers.

  " -- if you enter one double quote symbol, the second such symbol
    will be entered automatically.

  <-- and --> -- move cursor.

  ^ and v (Up and Down arrows, not the caret and `v' letter) -- previous/
    next string from history.

  Page Up and Page down -- first and last strings in the history.

  Home and End -- move cursor.

  Enter -- calculate result and store it into history buffer.

  Insert -- toggle insert/overstrike mode.

  Backspace -- delete char before cursor.

  Delete -- delete char under cursor.

  Ctrl-Y -- clear string.

  Ctrl-K -- clear text to the end of string.

  You can move FDRC's window using WordStar-like keys (by default):

    Ctrl-S -- left

    Ctrl-D -- right

    Ctrl-E -- up

    Ctrl-X -- down

  or Vi-like keys (if you defined VI_KEYS constant in config.inc):

    Alt-H -- left

    Alt-L -- right

    Alt-K -- up

    Alt-J -- down

  Alt-S -- switch between signed and unsigned decimal representation of
    result.

  Alt-D -- stuff decimal representation of result to keyboard buffer and
    exit.

  Alt-H -- stuff hexadecimal representation of result to keyboard buffer and
    exit.

  Alt-1 .. Alt-4 -- stuff corresponding part of binary representation of
    result to keyboard buffer and exit.

  Esc -- exit.


6. Known bugs and features
--------------------------

  * FDRC do not check overflow.
  * Multiplication and division are unsigned.
  * FDRC stuffs result to keyboard buffer with cleared scan codes.


7. Credits
----------

      Thanks to the following people:

  * Vsevolod V. Volkov for the Volkov Commander.
  * Victor Gamayunov and Sergey Pimenov for Insight.
  * Eugene Suslikov (SEN) for Hacker's View.
  * Sergey Chehuta for the Turbo Assembler Shell.
  * All people who makes FreeDOS, Linux and programs for these OSes.
  * All who helped me with code and/or ideas.


-- EOF --


