home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / lambda / soundpot / p / rpn10.lbr / RPN.DZC / RPN.DOC
Encoding:
Text File  |  1993-10-25  |  5.0 KB  |  233 lines

  1.  
  2. READ.ME:
  3.  
  4.  
  5. RPN 1.0 - reverse polish programmer's calculator
  6.  
  7.             (For the Osborne-1)
  8.  
  9.      by David Brower, GM Software, 10/82
  10.      This program is in the public domain.
  11.  
  12.      The following files were submitted to FOG:
  13.  
  14.      -    READ.ME    this documentation
  15.  
  16.      -    RPN.COM    the executable program
  17.  
  18.      -    RPN.C      the source code
  19.  
  20.  
  21. Description:
  22. ------------
  23.  
  24.      RPN 1.0 is an integer-only screen calculator
  25. particlularly usefull to programmers.  Values may
  26. be displayed and entered in any of four formats,
  27. ASCII character, DECIMAL integer, and HEX or
  28. OCTAL integers.  The program is written in BDS-C
  29. for the Osborne-1 and would require some simple
  30. modifications to run on machines with different
  31. terminal control sequences.
  32.  
  33.      Data is handled on a stack in reverse polish
  34. notation, much like Hewlett-Packard calculators.
  35.  
  36.      The stack is 30 16-bit words deep, which
  37. should be sufficient for just about anybody.
  38. While not strictly necessary (you can somehow
  39. deconvolute ANY expression into RPN), there is
  40. also a convenient MEMORY cell.  Data may be
  41. stored or recalled into or from this location
  42. freely.
  43.  
  44.      All the normal arithmetic operations are
  45. supplied, as well as a complete set of bitwise
  46. operations.  For the most part "C" like notation
  47. is used.
  48.  
  49.      Fairly explicit "HELP" information is built
  50. into the display.  The program uses a pleasant
  51. technique of keeping an up-to-date stack display
  52. while maintaining a small scrolling region for
  53. old commands.  This keeps you fully informed
  54. about your current state and also shows your last
  55. few entries, giving you some idea how you got
  56. where you are.
  57.  
  58.  
  59. Usage:
  60. ------
  61.  
  62.      In response the the CP/M prompt A> enter:
  63.  
  64. rpn<RETURN>
  65.  
  66. There are no command line arguments.
  67.  
  68.  
  69. Examples:
  70. ---------
  71.  
  72. To add 4 and 5, enter:
  73.  
  74.           4
  75.           5
  76.           +
  77.  
  78. To divide 10 by 2:
  79.  
  80.           10
  81.           2
  82.           /
  83.  
  84. To pack a BCD word from the four characters "1234":
  85. (You'd never do it this way, but it's an example.)
  86.  
  87.      <ESC>0     ; push character 0
  88.      S          ; save it in memory
  89.      <ESC>1     ; push character 1
  90.      r          ; recall the '0'
  91.      -          ; subtract '0' from '1'
  92.      4          ; 4 bits to shift
  93.      <          ; shift left
  94.      <ESC>2     ; push character 2
  95.      r          ; recall '0'
  96.      -          ; subtract
  97.      |          ; OR with the shifted '1'-'0'
  98.      16
  99.      *          ; shift left 4 more bits
  100.      <ESC>3
  101.      0xf        ; Bit mask, just to be different
  102.      &          ; AND with the mask
  103.      |          ; merge with the saved '120'
  104.      4
  105.      <
  106.      <ESC>4     ; etc.
  107.      r
  108.      -
  109.      |          ; BCD now on top of stack.
  110.  
  111.  
  112.  
  113. RPN COMMANDS:
  114. -------------
  115.  
  116.      Commands are always entered by pressing
  117. <RETURN>. You may use any of the standard CP/M
  118. line editing commands, such as <DEL>, <BS>, ^U,
  119. ^X or the "<-" back arrow on the Osborne-1.
  120.  
  121.  
  122. Entering values:
  123.  
  124.      These push a value onto the top of the stack.
  125.  
  126.      <ESC>c    ASCII character
  127.  
  128.      nnnnn     decimal integer
  129.  
  130.      0xhhhh    HEX integer
  131.  
  132.      0oooooo   OCTAL integer
  133.  
  134.  
  135. Binary (two operand) operations:
  136.  
  137.      These replace the top two values on the stack
  138.      with the result of the operation.
  139.  
  140.      +     Addition
  141.  
  142.      -     Subtraction
  143.  
  144.      *     Multiplication
  145.  
  146.      /     Division
  147.  
  148.      %     Remainder (modulus)
  149.  
  150.  
  151.  
  152.      <     Bitwise LEFT shift
  153.  
  154.      >     Bitwise RIGHT shift
  155.  
  156.  
  157.  
  158.      &     Bitwise AND
  159.  
  160.      |     Bitwise OR (inclusive)
  161.  
  162.      ^     Bitwise XOR (eXclusive OR)
  163.  
  164.  
  165. Unary (single operand) Operators:
  166.  
  167.      These replace the top of the stack with
  168.      the result of the operation.
  169.  
  170.      C     bitwise complement (1's)
  171.  
  172.      N     negate, 2's complement.
  173.  
  174.  
  175.  
  176. MEMORY Control:
  177.  
  178.      These move values to and from the MEMORY cell.
  179.  
  180.      S     Stores the top of the stack in MEMORY
  181.  
  182.      R     Recalls the MEMORY by pushing it's value
  183.  
  184.  
  185.  
  186. Stack Control:
  187.  
  188.      These clobber elements on the stack.
  189.  
  190.      E     erases the top of the stack
  191.  
  192.      Z     Zaps (erases) the entire stack and
  193.            the MEMORY cell.
  194.  
  195.  
  196. SPECIAL COMMAND:
  197.  
  198.      "     DITTO, repeat the last entered command.
  199.  
  200.  
  201. Program Exit:
  202.  
  203.      ^C    Ends and re-boots.
  204.  
  205.      ^Z    Ends without re-booting.
  206.  
  207.      <RETURN>     asks:
  208.  
  209.            rpn exit (y/n)? _
  210.  
  211.            Answering 'Y' or 'y' will exit.
  212.  
  213.  
  214.  
  215. Programming Notes:
  216. ------------------
  217.  
  218.      Originally from "The C Programming Language"
  219. by Kernighan & Ritchie, modified for screen stack
  220. display, ascii, hex, integer and octal modes, &
  221. bitwise operations.  Apologies to K & R for my
  222. hacks to their nice program.  The code (RPN.C) is
  223. written in Leor Zolman's BDS-C.  I could not get
  224. it to work using the "small-c" available on FOG
  225. disks 29-32.  Sorry about that.  The RPN.COM file
  226. should run on any Osborne-1 without problem.
  227.  
  228.     For all you Osborne "C" fans who haven't
  229. found the magic keys:
  230.  
  231.     '{'    is ^,  (ctrl on the '<' key)
  232.     '}'    is ^.  (ctrl on the '>' key)
  233.      E