home *** CD-ROM | disk | FTP | other *** search
-
- CONTENTS
- 1.............................Introduction
- 2.............................Reverse Polish Notation
- 3.............................Functions
- 4.............................Sample Calculations
- 5.............................Miscellanious
-
-
- INTRODUCTION
-
- This program has been released into the public domain. It may not be
- sold, or contained as part of a commercial product that is for sale.
- It is for use with medium resolution.
- This calculator is designed to handle simple bit oriented
- calculations encountered during programing. It provides the user with
- integer arithmetic operations, Boolean logic functions, and base
- conversions.
-
- REVERSE POLISH NOTATION (RPN)
- If you have used a Hewlett-Packard calculator before you will have no
- problem using this program. For those of you who haven't it will take a
- little getting used to, but in the end you will agree that it is a better
- way of doing things.
- A RPN calculator uses a stack to store results of its calculations.
- All arithmetic operations are done on the top two numbers on the stack.
- This is accomplished by first placing the operands onto the stack and then
- specifying the operation to be performed. For example the operation would
- be performed in the following steps:
- 3+7=
-
- 3
- ENTER (Push)
- 7
- ENTER (Push)
- +
- Upon pressing the "+" key the top number (7) is popped from the stack,
- next the number which is now at the top of the stack (3) is also popped
- from the top of the stack. The two numbers are then added and the result
- is pushed onto the stack. On the calculator the "+" functions executes
- the enter function saving a key stroke, so the sequence is simplified to:
- 3 [Enter] 7+
- The number which is at the top of the stack is what is displayed at by the
- calculator. This is also the result of the calculation thus there is no
- need for an equal key.
- If you have never seen this before it may look strange, but it will
- become second nature with a little practice. Here is one, more more
- complicated example:
- 3(6+2)/(9-2)=?
- 3 [Enter] (* push 3 onto stack *)
- 6 [Enter] (* push 6 onto stack *)
- 2 (*2 is pushed onto stack when is hit *)
- + (* 6+2 now on top of stack *)
- * (* 3(6+2) on top *)
- 9 [Enter] (* push 9 *)
- 2 (* push 2 then subtract *)
- - (* 9-2 on top of stack *)
- / (* 3(6+2)/(9-2) *)
- Using RPN also allows the parenthesis to be left out which saves key
- strokes. For more examples of RPN look at the sample calculations shown
- later. If you are still confused you may try looking at the owners manual
- for an HP calculator.
-
- FUNCTIONS
- This section will outline and give an example of the functions
- included in the calculator. Each function can be accessed in one of two
- ways. First the mouse can be used by placing the pointer on the key to be
- pressed and clicking the mouse button. Each key has two functions
- associated with it. To access the one written on the key press the left
- button on the mouse, and for the second function which is written above the
- key press the mouses right button.
- Another way in which the calculator keys can be pressed is by using
- the ST numeric key pad, Backspace, and delete keys. For most of the keys
- the layout of the Calculator Keys and the numeric key pad are the same,
- however there are a few differences. The second function for each
- calculator key is accessed by pressing (on the ST keyboard) the sift key
- while typing the assigned key.
- The following functions are provided by the calculator.
-
- Display Modes:
- DEC- Display numbers in decimal mode. Key:. { on key pad }
- Typing this function will cause all numbers to be displayed in
- decimal.
- [HEX]- " " Hexadecimal mode Key:( { on key pad }
- [BIN]- " " Binary mode Key:)
- Before going on a few comments are in order. First changing display
- formats has no effect on the numbers which are stored in the calculator.
- These functions only effect the way in which the numbers are displayed.
- There are however some complications that arise from the display of
- negative numbers. To illustrate these lets do the following example. Do
- the following keystrokes:
- [16b] {this key explained later}
- [DEC] {decimal display mode}
- 862 {thats three key strokes}
- [HEX] { $35E is the hex display}
- [BIN] { %1101011110 is binary for 862}
-
- [+/-]- change sign Key:[Shift][-]
- Changes sign of display. If the number is outside of the signed
- range for the display mode this keystroke will be ignored. For
- example try to change the sign of 255 in 8 bit mode ( you can't).
- [2CM]- Two's compliment Key:[Shift][Enter]
- Takes the two's compliment of the number displayed. This
- function is done on the magnitude of the number. The result is
- always positive.
-
- Continuing with the above example:
- [DEC] {862 is back on the display}
- [+/-] {-862}
- [HEX] {-35E }
- [2CM] {$FCA2 this is twos comp of 862 }
- [2CM] {$35E now displayed }
- When dealing with signed numbers (or unsigned it is important to keep
- in mind that the calculator does not flag overflow errors. For example try
- the following calculation:
- [DEC]
- [8b] {8 bit mode}
- 0[Enter]
- 255[-] {-127 ! }
- In the above example the result of the calculation should have been -
- 255 however since the 8 bit signed number range is -128 to 127 the result
- was simply truncated. If the result is greater then 127 the calculator
- will represent it as an unsigned number for example:
- 0[Enter]
- 255[+] {255 is displayed }
- [AND]-bit and function Key-[Shift]9
- [OR]-bit or function Key-[Shift]8
- [XOR]-Bit Xor function Key-[Shift]7
- [COM]- Compliment all bits Key-[Shift]+
- An example of one the logical functions is shown bellow.
- 1[Enter]
- 128 {no Enter here}
- [OR] {displays 129}
- [BIN] (%10000001}
- [LSR]- Logical Shift Right Key-[Shift]6
- Shifts display one Byte to the right. 0's are shifted in and
- the least significant byte is lost.
- [ASL]- Arithmetic Shift Left Key-[Shift]*
- Shifts display one Byte to the left. 0's in and most sig. byte
- lost.
- Note that to shift one bit position instead of 8 the key
- strokes 2[*] or 2[DIV] can be used.
- [Clx]- Clear the display register Key-[Shift]BackSpace
- Set the number displayed to 0. This function does not alter the
- calculator stack.
- [Cld]- Clear low digit Key-BackSpace
- Clear low digit of display
-
- The two Cl functions are aids for entering numbers. An example
- of their use is as follows: Suppose you were entering 354
- [3][5][6] {oops! entered a 6. 356 displayed}
- [Cld] {35 displayed}
- [4] {that's better. 354 displayed}
- [Clx] {got rid of the whole. 0 displayed}
- [x|y]- exchange top two numbers on stack Key-Delete
- Switches the number displayed with the number that is next on
- the stack. Does not alter other numbers on stack.
- 5[Enter]
- 4 {4 displayed}
- [x|y] {5 now displayed}
- + {9 displayed}
- [hi]- show high word. Key-[Shift]Delete
- This function is only used to display the high 16 bits when in
- 32Bit binary display mode. If not in this mode the key is ignored.
- [HEX]
- [32b]
- FFFFAAAA
- [BIN] {1010,1010,1010,1010 this is the low word}
- [hi] {1111,1111,1111,1111, this is the high word
- note the far right , }
-
-
- SAMPLE CALCULATIONS.
-
- As a final example I will present some examples of more complex
- calculations using the calculator.
-
- 1 Find the contents of the D register after executing the following
- segment of 6809 code. It multiplies the 8 bit number at location NUM1 by
- the 16 bet number at location NUM2 and returns the result on the stack.
-
- 1 START LDA NUM1 A,B ARE 8 BIT ACCUMUL.
- 2 LDB NUM2+1 LOW BYTE
- 3 MUL RESULT IN D=A|B
- 4 PSHU D SAVE PARTIAL PRODUCT
- 5 LDA NUM1
- 6 LDB NUM2 MULT. HIGH BYTE
- 7 MUL
- 8 ADDB ,U+ ADD TO PARTIAL PROD. ON STACK
- 9 BCC NOINC
- 10 INCA PROPAGATE CARRY
- 11 PSHU D 3 BYTE RESULT ON STACK
- 12 RTS
- Suppose we were to test the above routine by setting [NUM1]=$A8
- and [NUM2]=$73F2 and single stepping through the code. By
- calculating the intermediate results of the multiplication it would
- be easier to find bugs.
-
- [32b][HEX] {set up the display mode}
- A8[Enter]
- F2[*] {$9ED0 should be in D after step 3}
- [Enter] {just like step 4}
- A8[Enter]
- 73[*] {$4B78 is partial product from step7}
- [Asl] (*$4B7800 adjusted partial prod. }
- [+] {gives us the result that should
- be on stack at return}
-
- 2 As an example of RPN, Suppose for some odd reason you wanted to evaluate
- the following expression:
- ( (2*(783+17)*3) XOR (4543 MOD 30) ) DIV 5 = ?
-
- [16b][DEC] {decimal word display }
- 2[Enter]
- 783[Enter]
- 17[+]
- [*]
- 3[*]
- 4543[Enter]
- 30[MOD]
- [XOR]
- 5[DIV] {?=962}
-
- 5 Miscellaneous
- Well that about does it. Was your favorite bit oriented or programing
- function not included? Well drop me a line including a description of the
- function and an example of its use. Also pass along in bug reports to me.
- Will this program work on a monochrome monitor? I haven't tried it.
- If you are interested in getting a monochrome version get in touch with me.
- Maybe we can make one.
- Lastly donations will be accepted and appreciated.
- Until May 87 my address will be
- Bruce Mealey
- 704 W 21st #308
- Austin, Tx 78705
- 512-320-0886
- Or Post Message to me on Sex. board
- 512-478-4282
-
- After May 87 I don't know were I will be but anything
- mailed to the address below will be forwarded to me.
- Bruce Mealey
- 6215 Hurst La
- New Orleans, La 70118
-
-