home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR8 / CALC_SRC.ZIP / CALC.DOC < prev    next >
Text File  |  1993-08-10  |  11KB  |  236 lines

  1. The SemWare Editor calculator Macros
  2. ────────────────────────────────────
  3. Version: 0.9
  4.  Date: Monday, 9 August 1993
  5. Author: L.A.Vonderscheer
  6. (Tim Farley & the University of California (Randall Hyde))
  7.  
  8. Copyright:
  9. ─────────
  10. This package is released to SemWare for use by them as they see fit.
  11. CALC.S and FPCALC.S are subject to the restrictions, if any, made by Tim
  12. Farley in his SEFP (SemWare Editor Floating Point) package and by the
  13. distributors of UCRLIB;  the University of California Standard Library
  14. for Assembly Programming.  As of this writing, SEFP and UCRLIB imply
  15. public domain and seem to have no significant restrictions in their use.
  16. (see excerpts at end of this document)
  17.  
  18. The integer versions are written entirely in SAL and shouldn't have any
  19. concerns as to rights to the source.
  20.  
  21. Introduction
  22. ────────────
  23. Calc.zip is a collection of 4 calculators for The SemWare Editor (TSE).
  24. These calculators come in two styles, a standard algebraic type and a
  25. Reverse Polish Notation (RPN) type. Each style of calculator is also
  26. divided into two versions; floating point and integer versions.
  27.  
  28. The reason for this split in function seemed logical and in keeping with
  29. "separate and small is better".  The macros of choice can be called from
  30. TSE with a controlling Load/Purge/Load macro that would make more
  31. efficient use of available resources then a single large calculator. Or
  32. a menu front end might be desired to call a specific macro.
  33.  
  34. Files Included
  35. ──────────────
  36. CALC.DOC    This document
  37.  
  38. FPCALC.S    Algebraic floating point calculator source.
  39.             Requires Tim Farley's SEFP 0.9 of 26 February 1993, in
  40.             particular FP.S* and FPLOW.BIN.
  41.  
  42. ACLAC.S     Algebraic Integer calculator source
  43.  
  44. CALC.S      Reverse Polish Notation Floating Point Calculator source
  45.             Requires Tim Farley's SEFP 0.9 of 26 February 1993, in
  46.             particular FP.S* and FPLOW.BIN. (FP_MIN.S included)
  47.  
  48. CALC.INC    CALC.S #include file containing some helper functions.
  49.  
  50. ICALC.S     Reverse Polish Notation Integer Calculator source.
  51.  
  52. ICALC.HLP   #Include help display source for ICALC.S
  53.  
  54. FP_MIN.S    * Revised version of Tim Farley's FP.S that has unused
  55.             procedures removed. The two source files (FPCALC.S & CALC.S)
  56.             for floating point #Include this file instead of the full
  57.             version.
  58.  
  59. Algebraic Calculator use
  60. ────────────────────────
  61. Since this is a calculator familiar to us all there is little reason to
  62. explain it's basic use. As a minimum these versions function as:
  63. "Number, Operation, Number, Equals, Result". Specifics to the type
  64. (integer or floating point) abilities follow below.
  65.  
  66. RPN Calculator use
  67. ──────────────────
  68. For real number crunching this is the ONLY calculator type to use. With
  69. it's stack and stack manipulation it allows the solution of many
  70. involved formula without re-entry of intermediate results.  This saves
  71. many keystrokes required by other types.  I'm a crummy teacher so I
  72. won't review the use of RPN calculators, but if you have used any of the
  73. Hewlett-Packard units on the market you should be on familiar ground.
  74. These calculators function as: Number, <enter>, number, operation,
  75. result. The "=" key doesn't exist on this calculator type.
  76.  
  77. Minimum stack manipulation operations (RollUp|Dn, X<>Y, LastX ClX) are
  78. provided. These are the most used operations and although X<>Z|T and
  79. storage registers are useful they were not implemented in this version.
  80.  
  81. Integer versions
  82. ────────────────
  83. There are a few functions that bear some examination.  This version has
  84. provision to do calculations and display in alternate number bases
  85. (Binary, Octal, Decimal, Hex). Switching from base to base has no effect
  86. on any calculation in progress. It just changes the display and the
  87. ability to input numbers of the current base. This makes it easy to
  88. convert numbers between bases or to add numbers of disparate bases.
  89.  
  90. There are provisions to perform some bit manipulation. AND(&), OR(|),
  91. XOR(^), NOT(N).
  92.  
  93. "Not" is an oddball in that it does not affect or require any other
  94. number entry. Enter a number, press (N)ot and the bits are toggled and
  95. the result displayed. As an example start up the calculator switch into
  96. binary display (W) and enter 1010101010101010 then press "N". The result
  97. will be 0101010101010101. Note that there is one setting/function that
  98. can affect this operation; it is "WO(R)D SIZE". Word size sets the
  99. number of bits (right to left) that are to be operated on. The default
  100. is 0Fh (16). Setting to another value affects the number of bits
  101. toggled. Returning to the previous example after setting the Wo(r)d size
  102. to 8 the (n)ot result is: 1010101001010101.  This holds true for the
  103. other bit manipulation functions (and, or, xor ) as well. There is no
  104. requirement that you be in, or remain in, binary mode to perform these
  105. functions, but behind the scenes this is what is being done.
  106.  
  107. AND, OR and XOR require two numbers be entered and return the result in
  108. the display. Word size effects how many bits are and|or|xor'ed together.
  109.  
  110. There are two more bit operations: ShiftLeft(shl) and ShiftRight(shr)
  111. that also require two number input. Number1 [Shl | shr] Number2 = Result.
  112. The second number is the number of bits to shift the first digit by. For
  113. example: 1111b shl 10b = 111100b or 1111b shr 10b = 0011b. These
  114. functions also do not require binary mode be or remain in effect in
  115. order to function.
  116.  
  117. Floating Point versions
  118. ───────────────────────
  119. The floating point versions do none of the base or bitwise manipulation
  120. that the integer versions do, although a binary or hex display is
  121. provided of the INTEGER only portion. (press 'x' for hex, 'b' for
  122. binary).
  123.  
  124. The FP calculators do have the ability to do scientific or financial
  125. calculations out to 9 decimal places. The number of digits _displayed_
  126. is controlled by the (F)ix function. Even if no decimal places are
  127. displayed full internal precision is maintained. In order to display the
  128. 'invisible' digits just use fix to increase the number of displayed
  129. places (max=9). The display is limited to 16 significant digits. Beyond
  130. that shifts the display into scientific notation displaying 9 digits and
  131. an exponent. This allows the display of some pretty big numbers.
  132.  
  133. It Moves!
  134. ─────────
  135. The control_cursor keys can be used to move the calculator around the
  136. screen. The calc box often pops up over some numbers that you want to
  137. refer to while using the calculator. These keys allow it to be moved
  138. out of the way.
  139.  
  140. Help
  141. ────
  142. All versions have a simple help screen integrated into them. These are
  143. only intended as a hint as to what operations are available and which
  144. keys are used.
  145.  
  146. Acknowledgment
  147. ───────────────
  148. SemWare: provided TSE and SAL which make all sorts of catty macros
  149.          possible.
  150.  
  151. Tim Farley: Released the floating point package that made the floating
  152.             point macros possible.
  153.  
  154. Ray (Buddy) Asbury: for pointing out numerous improvements, and not a
  155.                     few errors.
  156.  
  157. 'Team TSE': The whole group of ßeta testers that upload all sorts of
  158.             good code examples.
  159.  
  160.  
  161. Important Notes:
  162. ────────────────
  163. There appears to be a bug in either Tim Farley's FP package or in UCRLIB
  164. that returns a bogus '0' value for 0.25 or 0.250 without also setting an
  165. error condition. The ASM routines are way over my head so I have failed
  166. to track where the spurious 0 value is coming from. I kludged a
  167. correction in the FP calculators by trapping this value before making
  168. the call to the FP units:
  169.  
  170.  (If InPut == '0.25' or InPut == '0.250' FPvar = FVal('0.2500') EndIf)
  171.  
  172. A version of this 'fix' is in both floating point macro's code. I don't
  173. know if any other values cause a similar problem although so far none
  174. have cropped up.
  175.  
  176. Excerpts
  177. ────────
  178. /***************************************************************************/
  179. ; Floating point package.
  180. ;
  181. ;
  182. ; Released to the public domain
  183. ; Created by: Randall Hyde
  184. ; Date: 8/13/90
  185. ;    8/28/91
  186. ***************************************************************************
  187. ; ╔═════════════════════════════════════════════════════════════════════════╗
  188. ; ║ BINKIT.ASM:  an ASM include file for use in creating TSE binary macros. ║
  189. ; ╚═════════════════════════════════════════════════════════════════════════╝
  190. ; Author: Tim Farley
  191. ; First written: 18 February 1993
  192. ; Last revision: 19 February 1993
  193. ; Last revision: 26 February 1993
  194. ;
  195. ; Release:  This file may be FREELY distributed to any and all users of
  196. ;           The SemWare Editor.  I would appreciate you mentioning my name
  197. ;           in the documentation of any BIN macros you create using this
  198. ;           file.
  199. ***************************************************************************
  200. ;
  201. ; FPLOW.ASM   -- Low-level assembly portions of the interface to the
  202. ;                UCR Standard Floating Point Library for Assembly
  203. ;                from the University of California at Riverside.
  204. ;
  205. ; Author: Tim Farley
  206. ;   Date: 24-Feb-1993
  207. ;
  208. ; Release:  This source code and the associated SAL macros are released to
  209. ;           the public domain.  Please honor any restrictions which are
  210. ;           included in current or future versions of UCRLIB, but beyond
  211. ;           that I do not restrict use.  I would appreciate it if you
  212. ;           mention my name in the docs of any derivative macros you
  213. ;           distribute.
  214. /***************************************************************************
  215.     FP.S        --  Suite of convenient high-level functions for doing
  216.                     floating point calculations.
  217.     Author:  Tim Farley
  218.       Date:  25-Feb-1993
  219.     Revised: 26-Feb-1993
  220.  
  221.     Explanation:  The UCR Floating Point library, adapted to The SemWare
  222.     Editor in UCRFP.S, provides a number of convenient floating point
  223.     functions.  These are defined in this file, along with a series
  224.     of more convenient higher-level functions to access the library.
  225.  
  226.     This file is intended to be #include'd in your macros which need
  227.     to access floating point numbers.
  228.  
  229.   Release:  This source code and the associated SAL macros are released to
  230.             the public domain.  Please honor any restrictions which are
  231.             included in present or future versions of UCRLIB, but beyond
  232.             that I do not restrict use.  I would appreciate it if you
  233.             mention my name in the docs of any derivative macros you
  234.             distribute.
  235.  
  236. ***************************************************************************/