home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / MATH / HP.LBR / HP.DOC < prev   
Text File  |  2000-06-30  |  6KB  |  102 lines

  1. GENERAL DESCRIPTION
  2. ENTERING NUMBERS 
  3. THE BACKSPACE KEY
  4. DOING ARITHMETIC
  5. STACK OPERATIONS
  6. MEMORY OPERATIONS
  7. THE ESCAPE KEY
  8. PRACTICE EXAMPLES
  9.  
  10. :     HP.COM is a simple "calculator" for programmers.  It is modelled
  11. after a Hewlett-Packard with RPN logic.  It can do addition, subtraction,
  12. multiplication, exponentiation, quotient, remainder, and bitwise logical
  13. operations.  It has an 8-word stack and 3 memories.  Best of all, it can
  14. display in any of four modes: hexadecimal, decimal, binary, and character.
  15.      HP has been kept relatively small and simple, since I wanted to
  16. implement a RAM-resident version of it for use under CP/M Plus.  This
  17. version, which can be used even from within other programs, is now
  18. available as HP+.COM.  See HP+.DOC for details.
  19.      All internal storage and arithmetic is unsigned 16 bit.  Thus 65537
  20. becomes 00001, -1 becomes 65535, and so on.  Multiplication overflow and
  21. division by 0 generate errors, except that in binary and character modes,
  22. the display shows only the lowest 8 bits of 16, so 8-bit overflow does
  23. NOT usually cause an error.
  24.      When you run HP, it will display its single operating line:
  25.          A>hp
  26.          HP 1.0 - E.Meyer 9/84        H>    0000
  27. The "H" indicates Hex display mode, and the "0000" is the calculator
  28. display.  The stack and memory are initialized to zero.  Try pressing the
  29. following sequence of keys: "2", "+", 4, "*".  You should see "00008",
  30. which is (0+2)*4.  Type control-C (^C) to exit HP.  This should give you
  31. the idea; now read on.  If you have never used an RPN calculator, you'd
  32. better learn to first.
  33.  :    ENTERING NUMBERS:  Your "enter" (or "return") key, which I will
  34. henceforth call "<E>", corresponds to the RPN "enter" key.  It is used
  35. to separate two numbers entered in a row (or to intentionally duplicate
  36. the number in the display register on the stack).  Typically you enter a
  37. string of digits, then hit <E> to put the number on the stack.  You do
  38. NOT hit <E> after every number entry, as the other function keys ("+",
  39. etc) automatically terminate digit entry also.
  40.      A maximum of 8 digits can be entered, after which the leading digits
  41. will begin to be discarded.  On hitting <E> (or another function key),
  42. the bell will ring if the string entered is not acceptable in the current
  43. display mode.  You must then correct the string and try again.
  44. :     THE BACKSPACE KEY:  Your backspace key (^H) works like the "<-" key
  45. on an HP-41C; it has two functions.  During digit entry, it deletes the
  46. last digit typed.  Otherwise, it zeros the current display (X) register,
  47. and leaves the stack lift disabled.
  48. :     DOING ARITHMETIC:  The operations available, and the keys to invoke
  49. them are: "+" (addition, Y+X), "-" (subtraction, Y-X), "*" (multiplication,
  50. Y*X), "^" (exponentiation, Y^X), "/" (integer quotient, INT(Y/X)), "%"
  51. (remainder, X*(Y/X-INT(Y/X))), "&" (bitwise and, X&Y), "|" (bitwise or,
  52. X|Y), and "~" (negation [2's complement], ~X).  Negation affects only the
  53. X register; the other operations use the values in the first two stack
  54. registers (X and Y), and return the result in the display (X), dropping
  55. the stack.è     The bell will ring if an undefined key is pressed as an operator.
  56. It will also ring, and multiplication "*" (also "^") will refuse to
  57. complete, if 16-bit overflow occurs.  The same thing happens with "/"
  58. and "%" if division by 0 is attempted.  The stack is left unchanged.
  59. Delete the offending operand and try again, if you wish.
  60. :     STACK OPERATIONS:  You can clear the stack with control-X (^X) at
  61. any time.  (Memory registers are not affected by ^X.)  Also, you can
  62. exchange the contents of the two lowest registers (X<>Y) with the "="
  63. exchange function.  HP.COM does not have stack roll functions.
  64. :     MEMORY OPERATIONS:  There are three memory registers (1-3), accessed 
  65. with the commands "S" (or "s") for Store, and "R" (or "r") for Recall.
  66. To store the number in the display in register 2, for example, type
  67. "S2".  To recall register 1 to the stack display, type "R1".
  68.  :    THE ESCAPE KEY:  Your escape key (ESC, or ^[) has two functions.
  69. First, it allows changing the display mode.  You can type ESC H, ESC D,
  70. ESC B, or ESC C, and the display mode will change accordingly to Hex,
  71. Decimal, Binary, or Character.  In hex mode, numbers display as four hex
  72. digits from 0000-FFFF.  In decimal mode, you get five decimal digits
  73. from 00000-65535.  In binary mode, the least significant byte of the
  74. number displays as 8 binary digits, 00000000-11111111.  In character
  75. mode, the least significant 7 bits of the number display as an ASCII
  76. character, if printable, or as a "^" code otherwise.  (Note: code 7F,
  77. DEL, will display as "^?".)
  78.      Second, the ESC key allows you to enter as a digit those characters
  79. that would otherwise be calculator functions, namely "+-*^/%&|~=sSrR".
  80. For example to enter the character "s", use ESC s, not just "s" (or you
  81. will initiate a store to memory).  Note that control codes (and the space,
  82. 20H) cannot be entered as data in character mode.
  83. :                              EXAMPLES
  84.      Now it's time for some more practice.  Try the following sample
  85. calculations.  Press the keys shown, and see whether the answer you get
  86. is correct.  In the problems, the "h" suffix indicates a hex number.
  87. (1)  What is (122+31)*8 ?
  88.      PRESS:  ^X  ESC D  1 2 2 <E> 3 1 + 8 *
  89.      ANSWER: D>    01224
  90. (2)  How many 128-byte records are between addresses D000h and E100h?
  91.      PRESS:  ^X  ESC H  E 1 0 0 <E> D 0 0 0 -  ESC D  1 2 8 /
  92.      ANSWER: D>    00034
  93. (3)  What character results from MVI A,'w' ANI 5FH (that is, "w"&5Fh) ?
  94.      PRESS:  ^X  ESC C  w  ESC H  5 F &  ESC C
  95.      ANSWER: C>        W
  96. (4)  What does -115 look like in binary?
  97.      PRESS:  ^X  ESC D  1 1 5 ~  ESC B
  98.      ANSWER: B> 10001101
  99. (5)  What is 5 to the 4th power?
  100.      PRESS:  ^X  ESC D  5 <E> 4 ^
  101.      ANSWER: D>    00625
  102.  XA 1: