home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / games / rpn.zip / RPN.DOC < prev    next >
Text File  |  1986-05-05  |  11KB  |  280 lines

  1.  
  2. RPN: Programmable RPN calculator            by Frank LaRosa, 1985
  3.  
  4. -------------------------------------------------------------------
  5.  
  6. This is a public domain, user supported program. If you use this 
  7. program, please send a contribution of $10 to the programmer:
  8.  
  9. Frank LaRosa
  10. 46 Twixt Hills Rd.
  11. St. James, NY  11780
  12.  
  13. SYSOP, Searchlight bbs (516) 724-0971
  14.  
  15. Please feel free to distribute this program. You may modify the
  16. program and documentation so long as you do not remove my name from 
  17. the program or remove this message from the documentation.
  18.  
  19. -------------------------------------------------------------------
  20.  
  21. RPN simulates a multifunction, programmable Reverse Polish Notation 
  22. calculator. The command set is loosely based on the HP-11C 
  23. scientific calculator, although I have added and deleted many 
  24. commands. There are two types of input:
  25.  
  26. COMMANDS:   One-letter commands to direct the operation of the 
  27.             program. Used to create, save and load programs, etc.  
  28.  
  29. STATEMENTS: Three-letter commands to perform calculator operations.
  30.             Statements can be executed directly or made into a 
  31.             program.
  32.  
  33. GETTING STARTED
  34. The RPN archive contains the following files:
  35.  
  36. RPN.EXE   The RPN program
  37. RPN.BAS   BASIC source code to RPN.EXE (Ascii format)
  38. RPN.DOC   This documentation
  39. ???.RPN   Various RPN sample files
  40.  
  41. To run the program, type RPN. The command prompt, RPN>, will appear. 
  42. The BASIC source code is included; you may load RPN.BAS under BASIC 
  43. and type RUN, but the .EXE version executes much faster. The BASIC 
  44. source code is included for those who wish to modify the program.
  45. At the RPN> prompt, enter "?" for a list of statements and commands.
  46.  
  47. RPN COMMANDS
  48. The RPN commands are:
  49.  
  50. Insert, List, Go, Delete, Save, Recall, Files, Xamine, ?, Quit
  51.  
  52. Commands are entered by typing the FIRST LETTER of the command, 
  53. optionally followed by parameters. You must use capital letters.
  54.  
  55. Command: Insert   Syntax: I<n>
  56. The Insert command builds a program of RPN statements. Type I by 
  57. itself to enter lines at the end of the current program; or use I 
  58. followed by a number to insert in the middle of the file. Program 
  59. statements are three letters, optionally followed by a number. The 
  60. Insert command converts each statement to an integer code and will 
  61. only take valid statements, generating an error message if an 
  62. invalid command or parameter is entered. To exit from Insert mode, 
  63. just press return on a blank line.
  64.  
  65. Command: List   Syntax: L<n> <filename>
  66. List the program in memory. If parameter n is given, list from line 
  67. n on. Lines in the program are NOT numbered sequentially, they are 
  68. numbered according to their position in memory. Simple statements 
  69. take up one memory location, while statements with parameters take 
  70. two or more. When listing you must give a line number that actually 
  71. corresponds to the first location of a command. If this is not done, 
  72. the listing will start at the next valid line or an error may occur.
  73. To pause the listing, press any key; press any key again to 
  74. continue. To abort the listing, press ESC.
  75. If a filename is given, the list is output to the file instead of to 
  76. the console screen.
  77.  
  78. Command: Go   Syntax: G<n> <filename>
  79. The Go command executes the program in memory. If n is given, 
  80. execution begins at line n; else execution begins at line 1. You can 
  81. press the ESC key to break the program.
  82. If a filename is given, program output (PRX and PRS statements) is 
  83. redirected to the file instead of the screen.
  84.  
  85. Command: Delete   Syntax: Dn<,m>
  86. If n only is given, deletes line n. If n and m given, deletes lines 
  87. n thru m. Both n and m must be legal line numbers, or the command 
  88. will abort.
  89.  
  90. Command: Save   Syntax: S <filename>
  91. Save the program to a file. If filename is left out, you are 
  92. prompted for it. You may include a drive letter and pathname in the 
  93. filename, however you may not include an extension; the default 
  94. extension .RPN will be used automatically. The file is saved as a 
  95. series of binary numbers and is only readable by the RPN program.  
  96.  
  97. Command: Recall   Syntax: R <filename>
  98. Recall file saved by Save command. Default extension of .RPN is 
  99. used. Any program in memory is overwritten.
  100.  
  101. Command: Files   Syntax: F <filename>
  102. Shows the disk directory. A filename or wildcard mask may be given. 
  103.     
  104. Command: Xamine   Syntax: X<n>
  105. Examines registers. If X is entered alone, the contents of the stack 
  106. (registers X, Y, Z and T) are shown. If n is included, the contents 
  107. of external register n are displayed.
  108.  
  109. Command: ?   Syntax: ?
  110. Displays a list of valid statements and commands on the screen.
  111.  
  112. Command: Quit   Syntax: Q
  113. Quits the program and returns to DOS.
  114.  
  115.  
  116. RPN STATEMENTS
  117. The heart of the RPN program are the statements that perform 
  118. calculations. The calculator is structured as follows:
  119.  
  120. 1. A four element stack. The stack registers are labeled X, Y, Z and 
  121.    T, with X being the bottom element of the stack. Most 
  122.    computations are done on these registers.
  123.  
  124. 2. External registers. Up to 1000 external registers are available 
  125.    to store numbers. The registers can be addressed directly or 
  126.    indirectly by the program statements.  
  127.  
  128. 3. Program memory. Memory that holds program instructions.
  129.  
  130. All statements are 2 or 3 letters long; some have parameters. 
  131. Statements may be incorporated into programs or they may be executed 
  132. directly at the RPN> prompt. All calculations are done using real 
  133. numbers to a precision of 6 decimal places.
  134.  
  135. I. STACK CONTROL STATEMENTS
  136.  
  137. CON n - Enter constant n into the X regiser, and shift the stack 
  138.         upwards by 1 element.
  139. ENT   - Shift stack upwards. X register copied to Y register.
  140. RLU   - Shift stack up. T register wraps to X register.
  141. RLD   - Shift stack down. X register wraps to T register.
  142. EXC   - Exchange X register with Y register.
  143. CLX   - Clear X regiser (set to 0).
  144. CLS   - Clear stack (all registers to 0).
  145.  
  146. II. REGISTER CONTROL STATEMENTS
  147.  
  148. STO n - Store X register in register n.
  149. RCL n - Recall register n into stack. Stack shifts up.
  150. SUM n - Add contents of X register to register n.
  151. PRD n - Register n is multiplied by X register.
  152. STI n - Store indirect. The contents of register n points to the 
  153.         register where X is saved. Register n must contain a number 
  154.         from 1 to 1000.
  155. RCI n - Recall indirect. Register n points to register to recall.
  156. CLR   - Clear all registers to 0.
  157.  
  158. III. MATHEMATICAL FUNCTIONS
  159.  
  160. ADD   - Add X and Y registers. Result goes to X register, and stack 
  161.         is shifted downwards.
  162. SUB   - Subtract X from Y. Stack shifted down.
  163. MPY   - Multiply X and Y, move stack down.
  164. DIV   - Divide Y by X, move stack down.
  165. EXP   - Exponentiation; raise Y to X power. Shift stack down.
  166. CHS   - Multiply X register by -1.
  167. ABS   - Absolute value of X.
  168. 1/X   - Divide 1 by contents of X register.
  169. LNX   - Take natural log (base e) of X.
  170. LOG   - Take common log (base 10) of X.
  171. ALN   - Raise e to power of X.
  172. ALG   - Raise 10 to power of X.
  173. SIN   - Sine of X in Radians.
  174. COS   - Cosine of X.
  175. TAN   - Tangent of X.
  176. ASN   - Arcsine of X (inverse of SIN).
  177. ACS   - Arc cosine (inverse COS).
  178. ATN   - Arc tangent (inverse TAN).
  179. SQR   - Square root of X.
  180. SQU   - Square of X (X^2).
  181. INT   - Take integer value of X.
  182. FRC   - Take fractional value of X.
  183. ROU n - Round X off to n decimal places.
  184. PI    - Enter value of Pi into X register. Stack is shifted up.
  185. RND   - Enter random number between 0 and 1. Shift stack up.
  186.  
  187. IV. FLOW CONTROL STATEMENTS
  188.  
  189. LBL n - Sets a label in the program. n is a number from 1 to 50.
  190. GTO n - Goto statement. Processing jumps to LBL n statement.
  191. GSB n - Gosub to label n. Gosubs may be nested 10 deep.
  192. RTN   - Return from subroutine to statement following GSB.
  193. GTI n - Goto indirect. The contents of register n contains the label 
  194.         where processing is to jump. Register n must contain a valid 
  195.         label number (1 thru 50).
  196. GSI n - Gosub indirect. Register n points to label to gosub to.
  197. X=Y   - Conditional branching instruction. If condition is true 
  198.         (contents of X equals contents of Y), processing continues 
  199.         at the next instruction. If false, the next instruction is 
  200.         skipped. Usually, a GTO or GSB instruction follows X=Y.
  201. X#Y   - Conditional, X unequal to Y.
  202. X<Y   - Conditional, X less than Y.
  203. X=0   - Conditional, X equal to 0.
  204. X#0   - Conditional, X unequal to 0.
  205. X<0   - Conditional, X less than 0.
  206. DSZ n - Decrement and Skip on Zero. Contents of register n is 
  207.         decremented by 1. If result is zero, the next instruction is 
  208.         skipped; if not, processing continues at next instruction.
  209. END   - End program and return to control mode.
  210.  
  211. V. INPUT AND OUTPUT
  212.  
  213. PRX   - Print value of X register on screen.
  214. PRS   - Print X, Y, Z and T registers in 4-across format.
  215. FIX n - Set number of decimal places to use with PRX and PRS.
  216. INP   - Input value from keyboard to X register. Stack moves up.
  217. NOP   - No operation. Do nothing.
  218.  
  219.  
  220. PROGRAMMING NOTES:
  221.  
  222. Values used in indirect expressions (STI, GSI, etc) are rounded off 
  223. to whole numbers before use. If the number is out of range, an error 
  224. message is generated.
  225.  
  226. Values of n for ROU command can be negative. This allows rounding to 
  227. nearest tens, hundreds, etc.
  228.  
  229. Parameter to FIX may be from 0 to 10, but only 6 digits are 
  230. significant.
  231.  
  232. All values of n in program statements must be integers, except for 
  233. CON statement. Simple statements (no parameters) take up 1 memory 
  234. location in the program storage array; statements with parameters 
  235. take 2, and CON statement takes 3.
  236.  
  237. Execution of a program can be aborted by pressing the ESC key.
  238.  
  239. To print program listing or program output on the printer, use the 
  240. filename PRN with the L and G commands.
  241.  
  242. The F command doesn't seem to be able to handle DOS directories, 
  243. probably because I'm using an early version of BASCOM. It will show 
  244. the directory of another drive, but you must include a filespec as 
  245. well as a drive letter (ie. B:*.*).  
  246.  
  247. Invalid mathematical operations (for example, SQR of a negative 
  248. number), invalid branching instructions, etc. will result in an 
  249. appropriate error message. Other errors, such as entering an invalid 
  250. file name, will result in an "Input Error" message.
  251.  
  252. If entering statements at the control level (rather than in a 
  253. program line) the CON statement can be omitted. Just type a number 
  254. and CON is assumed.
  255.  
  256. For more information about this program please contact the author at 
  257. the address listed above, or via my bbs at 516-724-0971.
  258.  
  259. --------------------------------------------------------------------
  260.  
  261. 
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.