HP COM HP DOC/ % HP 1.0 - E.Meyer 9/84 !9"12~!:*]6!t6 #G!t:2}FʟB+-*ʔ^ʣ/ʅ%u&f|Q~> =) SsRr!!ut2{>2}!:!t:X:}!z{> 2t!"]>2~3!]6#3ͮ>2~3ͮ*]*_"_"]/ͮ*]|/g}/o#"]/ͮͦ|g}o"_/ͮͦ|g}o]ͮͦ*]ͮͦ*]ͮͦ ]ͮͦz´!]BKT] x] øͮͦR]ͮͦ]ͮF41_!m:]w#:^w/ͮF41_!m:~(~2]#~2^/+-*^/%&~=|sSrRF!4ʿ#J_ͮHqDzBʃCʌ!s9Ò!nÒ!Ò!)2s"q"7/**]*_:}!t^:~"]2~>->-/!_]!jl:s->>-> -MD!> گ)گ)= {ʰMD!>2"R?N*:=7i`~o o60#_sͲ͆W#͆_͗#_͗؃~Aڣ_0Ұ7~0¯#²Ͳ'd ~:ү0 گ=#~#01ðxGy$Oh&Ͳ~o&9d|G}GXX0:--> -dd|'ڌ„}ڌ u>0-|ګ£}ګ Ô>0-|¾}d ó>0-  >0-0-EyOx>0>1-d} -@>?>->^--_ɯ-#:!>-> -HGENERAL DESCRIPTION ENTERING NUMBERS THE BACKSPACE KEY DOING ARITHMETIC STACK OPERATIONS MEMORY OPERATIONS THE ESCAPE KEY PRACTICE EXAMPLES : HP.COM is a simple "calculator" for programmers. It is modelled after a Hewlett-Packard with RPN logic. It can do addition, subtraction, multiplication, exponentiation, quotient, remainder, and bitwise logical operations. It has an 8-word stack and 3 memories. Best of all, it can display in any of four modes: hexadecimal, decimal, binary, and character. HP has been kept relatively small and simple, since I wanted to implement a RAM-resident version of it for use under CP/M Plus. This version, which can be used even from within other programs, is now available as HP+.COM. See HP+.DOC for details. All internal storage and arithmetic is unsigned 16 bit. Thus 65537 becomes 00001, -1 becomes 65535, and so on. Multiplication overflow and division by 0 generate errors, except that in binary and character modes, the display shows only the lowest 8 bits of 16, so 8-bit overflow does NOT usually cause an error. When you run HP, it will display its single operating line: A>hp HP 1.0 - E.Meyer 9/84 H> 0000 The "H" indicates Hex display mode, and the "0000" is the calculator display. The stack and memory are initialized to zero. Try pressing the following sequence of keys: "2", "+", 4, "*". You should see "00008", which is (0+2)*4. Type control-C (^C) to exit HP. This should give you the idea; now read on. If you have never used an RPN calculator, you'd better learn to first. : ENTERING NUMBERS: Your "enter" (or "return") key, which I will henceforth call "", corresponds to the RPN "enter" key. It is used to separate two numbers entered in a row (or to intentionally duplicate the number in the display register on the stack). Typically you enter a string of digits, then hit to put the number on the stack. You do NOT hit after every number entry, as the other function keys ("+", etc) automatically terminate digit entry also. A maximum of 8 digits can be entered, after which the leading digits will begin to be discarded. On hitting (or another function key), the bell will ring if the string entered is not acceptable in the current display mode. You must then correct the string and try again. : THE BACKSPACE KEY: Your backspace key (^H) works like the "<-" key on an HP-41C; it has two functions. During digit entry, it deletes the last digit typed. Otherwise, it zeros the current display (X) register, and leaves the stack lift disabled. : DOING ARITHMETIC: The operations available, and the keys to invoke them are: "+" (addition, Y+X), "-" (subtraction, Y-X), "*" (multiplication, Y*X), "^" (exponentiation, Y^X), "/" (integer quotient, INT(Y/X)), "%" (remainder, X*(Y/X-INT(Y/X))), "&" (bitwise and, X&Y), "|" (bitwise or, X|Y), and "~" (negation [2's complement], ~X). Negation affects only the X register; the other operations use the values in the first two stack registers (X and Y), and return the result in the display (X), dropping the stack. The bell will ring if an undefined key is pressed as an operator. It will also ring, and multiplication "*" (also "^") will refuse to complete, if 16-bit overflow occurs. The same thing happens with "/" and "%" if division by 0 is attempted. The stack is left unchanged. Delete the offending operand and try again, if you wish. : STACK OPERATIONS: You can clear the stack with control-X (^X) at any time. (Memory registers are not affected by ^X.) Also, you can exchange the contents of the two lowest registers (X<>Y) with the "=" exchange function. HP.COM does not have stack roll functions. : MEMORY OPERATIONS: There are three memory registers (1-3), accessed with the commands "S" (or "s") for Store, and "R" (or "r") for Recall. To store the number in the display in register 2, for example, type "S2". To recall register 1 to the stack display, type "R1". : THE ESCAPE KEY: Your escape key (ESC, or ^[) has two functions. First, it allows changing the display mode. You can type ESC H, ESC D, ESC B, or ESC C, and the display mode will change accordingly to Hex, Decimal, Binary, or Character. In hex mode, numbers display as four hex digits from 0000-FFFF. In decimal mode, you get five decimal digits from 00000-65535. In binary mode, the least significant byte of the number displays as 8 binary digits, 00000000-11111111. In character mode, the least significant 7 bits of the number display as an ASCII character, if printable, or as a "^" code otherwise. (Note: code 7F, DEL, will display as "^?".) Second, the ESC key allows you to enter as a digit those characters that would otherwise be calculator functions, namely "+-*^/%&|~=sSrR". For example to enter the character "s", use ESC s, not just "s" (or you will initiate a store to memory). Note that control codes (and the space, 20H) cannot be entered as data in character mode. : EXAMPLES Now it's time for some more practice. Try the following sample calculations. Press the keys shown, and see whether the answer you get is correct. In the problems, the "h" suffix indicates a hex number. (1) What is (122+31)*8 ? PRESS: ^X ESC D 1 2 2 3 1 + 8 * ANSWER: D> 01224 (2) How many 128-byte records are between addresses D000h and E100h? PRESS: ^X ESC H E 1 0 0 D 0 0 0 - ESC D 1 2 8 / ANSWER: D> 00034 (3) What character results from MVI A,'w' ANI 5FH (that is, "w"&5Fh) ? PRESS: ^X ESC C w ESC H 5 F & ESC C ANSWER: C> W (4) What does -115 look like in binary? PRESS: ^X ESC D 1 1 5 ~ ESC B ANSWER: B> 10001101 (5) What is 5 to the 4th power? PRESS: ^X ESC D 5 4 ^ ANSWER: D> 00625 XA 1: