(C) Copyright Ogham 1987 COMPUTER SCIENCE CALCULATOR Introduction The Computer Science Calculator is listed on the Personal Secretary Menu screem. From the Potpourri Menu, press F4 key to enter the Personal Secretary Menu. Press F9 key to enter the Computer Science Calculator program. The Computer Science Calulator has been designed for the student learning the microcomputer and for the professional programmer writing system or application programs. The unique features allows one to use the calulator without the constant referral to a User's Guide. The Computer Science Calculator provides three modes of operation: * Integer * Real (floating point) arithmetic * Keyboard interpretation Integer mode has four number bases - decimal, binary, hexadecimal and octal - with one's or two's complement and unsigned capability. Logical, arithmetic and bit manipulations is provided in this mode. The counter window is user controlled and can vary from four (4) positions to 52 positions. Real mode allows decimal point and single-precision decimal entries and stores the values in double-precision format. Results can be displayed in binary representation. Keyboard interpretation converts entered ASCII code to character or entered character to ASCII code and will display extended and control character information. Error conditions are provided in all three modes. The bottom line of the screen is used for the error message. If an error occurs, the message will remain on the screen until a key is pressed. GETTING STARTED Enter the Computer Science Calculator by the Personal Secretary Menu function key 9. Take a few moments to look over the screen. The three blocks - Decimal, Integer and 2's - are in reversed color. The reversed color is a reminder for the current mode of operation, number base and complement. The top rectangular block is the window of the x register. In integer mode the window size can vary from four (4) positions to 52 positions. Regardless of the number base in use, an error will result if the integer entered exceeds the window size of the binary representation of the integer. The number 8 in brackets following the block labeled Length is the current window size. The size is for both x and y registers. Each word or character within a block is a function of the Computer Science Calculator. Notice that the first character of a word within a block is either upper case (as in Decimal) or lower case (as in octal). To select a function, you type the first character of the word as shown. For blocks that are attached (rotate - left - right), you are required to enter two (2) keystrokes. The first key will select the function and the second key is the action to be taken. The bottom display line is used for reporting errors and action to be taken. This line is also used for instructions to exit the program or to change to a different mode. One more bit of information before starting. The carriage return bar on the keyboard has been labeled many different ways. The Computer Science Calculator presents this bar as the back arrow with a half of a tail and the word enter. For the examples in the User's Guide the is used when the carriage return bar is to be pressed. Get acquaninted session: Type 12 Type B (Binary) Type H (Hexadecimal) When in hexadecimal, lower case letters a through f are printed. You must type lower case letters for hexadecimal numbers. Type o (octal) Type L (Length) The Length of the window (x register) and the y register has been changed to 12 and the registers have been set to zero. Type K (Keyboard) Type 7 Type A (ASCII) Press Esc and then R Type 12.25 Type I (Integer) The Computer Science Calculator resets to the initial stage each time you change mode of operation. Type B (Binary) Type 3 The error message will be erased after: Type 11 Type This is first role, the x register is transferred to the y register and the x register is set to zero. Type D (Decimal) Type 24 Type W (Window) Type P (Previous) Type This is second role. When two keystrokes are used for a function, the allows an exit from the function. Other keystrokes will also allow an escape, but to be consistent use . Type + (addition) The arithmetic result is placed in the x register. More will be said about reversed polish notation in the arithmetic operations section. Type C (Clear) The x register and y register have been cleared. ARITHMETIC OPERATIONS This is a general description that applies to both Integer and Real modes. Arithmetic operations are performed by reversed polish notation. The operands (x and y) are separated by and then the operator key is pressed. The x and y registers are used in the arithmetic operations as shown in the expressions of the following table. The arithmetic operators are identified on the screen as: OPERATION OPERATOR REGISTERS Multiplication x (lower case) X x Y Addition + X + Y Subtration - X - Y Division / X / Y In addition to the above arithmetic operators, there are two operators that apply to Integer mode. Exponentiation ^ (shifted 6 key) X ^ Y Remainder Modulo X MOD Y The use of the x and y registers is shown in the following examples for integer mode. Integer mode arithmetic requires that complement must be set to 2's. Type I (Integer mode) Type s (set complement) Type 2 (two's complement) Division example: To divide 34 by 5 in Integer mode: Type 5 (divisor) Type (place divisor in y register) Type 34 (dividend in x register) Type / (division X/Y) Window (x register) displays the quotient. In Integer mode, the quotient is truncated and you can use Modulo (type M) to obtain the remainder. Modulo example: To obtain the remainder for the above example: Type C (Clear) Type 5 Type Type 34 Type M (Modulo X MOD Y) Window displays the remainder. The arithmetic operator is keyed in last in reversed polish notation. This also allows repetitive arithmetic operations. Using the result of the last example, the value 5 is in the y register and the value 4 is in the x register. Multiplication example: Type x (multiplication X x Y) Type x (multiplication X x Y) Sign change To change the sign of the value in the window, type S. Subtractation example: Type C (Clear) Type 25 Type S (Sign change) Type Type 15 Type - (subtraction X-Y) Addition example: Type S (Sign change) Type Type 15 Type + (addition X+Y) Exponentiation example: Raise 2 to the power of 6 Type C (Clear) Type 6 Type Type 2 Type ^ (shifted 6 key X^Y) Following are examples in Real mode: Division example: To divide 34 by 5 in Real mode: Type R (Real mode) Type 5 Type Type 34 Type / (division X/Y) Multiplication example: Type C (Clear) Type 12.25 Type Type 2 Type x (multiplication X x Y) or Type C (Clear) Type 1225E-2 Type Type 2 Type x (multiplication X x Y) INTEGER MODE The Computer Science Calculator stores the integer in binary representation for both the x and y registers. This is the reason for the error of exceeding length of the window. There is also a warning of positive to negative and this occurs when keying in an integer and the high order position (bit) of the window becomes a one. Number Bases Select the number base by typing in the first character of the word as shown in the number base block. Type D for decimal - accepts digits 0 through 9. Type B for binary - accepts digits 0 and 1. Type H for hexadecimal - accepts digits 0 through 9 and lower case letters a through f. Type o for octal - accepts digits 0 through 7. All of the number bases can be used for a function. For two number operators, such as arithmetic operations, you can type in an integer ,enter the value into the y register and then change to another number base for the x register. The only limitation is the value of a number cannot exceed the length of binary representation of that number. Type I (Integer mode) Type 8 Type L (Length) Type H (Hexadecimal) Type ad (-83 in decimal) Type Type D (Decimal) Type 15 Type + (addition) Window control The window control is used for displaying the previous entered integer (-83) which is in the y register, the current integer (-68) which is the x register and allows the interchange of registers by the use of swap. Using the above example: Type W (window control) Type P (previous) Type S (swap) Type (escape from window control) Window (x register) displays -83. Clear Type C to clear the x and y registers. Sign change Type S to change the sign of the value in the window (x register). Set compliment must be 1's or 2's or an error message will be displayed. Length Type in the length required for the x and y registers. Type L and the window size will be changed and the size will print in brackets alongside of the Length block. Size can vary from four (4) positions to 52 positions. In binary, each position within the registers is called a bit. And a byte is eight (8) bits. One half of a byte (4 bits) is a nibble. Two bytes (16 bits) is a word. Four bytes (32 bits) is a doubleword. These four lengths are the various lengths for the microcomputers. For the purist, there is also a length of 20 bits formed by combining a segment value (offset by hexadecimal 0) with an offset value to obtain the effective address of the microcomputer's memory. set compliment For this section, the window is eight (8) positions in length. Type I (Integer mode) Type D (Decimal) Type 8 Type L (Length) In one's or two's complement, a negative integer is recognized by a one in the high order position of the binary representation of the integer displayed in the window. In one's complement, a zero can also be a minus zero and this was the reason two's complement was invented. When a negative number is used in one's complement, arithmetic results can be erroneous. Positive integers are represented in the correct binary form. Type 3 Type B (Binary) Negative integers are represented by complementing each bit. Type s (set complement) Type 1 Type S (Sign change) One's complement in binary form of -3. Type D (Decimal) There is a difference in representing negative integers in two's complement. Type C (Clear) Type 3 Type B (Binary) Negative integers are first complemented as in one's complement and then a one is added. Type s (set complement) Type 2 Type S (Sign change) Two's complement in binary form of -3. Unsign is the absolute magnitude of an integer. A one in the high order bit of the register does not represent a negative integer. Type C (Clear) Type s (set complement) Type u Type D (Decimal) Type 255 (largest integer in a byte) Type B (Binary) For a byte (8 bits) in two's complement, the positive integer range is 0 to 127 and the negative integer range is -1 to -128. Type C (Clear) Type s (set complement) Type 2 Type D (Decimal) Type 127 Type B (Binary) Type C (Clear) Type D (Decimal) Type 128 Type B (Binary) Bit manipulation For this section, we will again set window size to a byte, use binary representation and set complement unsign. Type C (Clear) Type D (Decimal) Type 8 Type L (Length) Type s (set complement) Type u (unsign) Type B (binary) Shift left - Shift right A shift left can cause an error message of exceeding length of the window. A binary base shift left is one position, but a hexadecimal base shift left is four positions. The -- (key 4 on the numeric pad) is used to shift left and -- (key 6 on the numeric pad) is used to shift right. Type 1111 Type -- (shift left) Type -- (shift left) Type -- (shift right) In binary a shift left is multiplication and a shift right is division. Type C (Clear) Type 1 Type -- (shift left) Type D (Decimal) Type B (Binary) Type -- (shift left) Type D (Decimal) Type B (binary) Type -- (shift right) Type D (Decimal) Rotate Unlike shifting, the rotated bit is placed in the carry. When you type R, the carry is set to zero. Rotate left shifts the bits one position to the left and the carry bit is placed in the low order of the window. The bit shifted off of the high order position is placed in the carry. Type C (Clear) Type s (set complement) Type u (unsign) Type B (Binary) Type 11111111 Type r (rotate) Type l (rotate left) Type l (rotate left) Type (escape from rotate) Rotate right shifts the bits one position to the right. The carry bit is placed in the high order bit of the window and the bit dropped from the low order position of the window is placed in the carry. Type C (Clear) Type 11111111 Type r (rotate) Type r (rotate right) Type r (rotate right) Type (escape from rotate) All number bases can be used for bit manipulation, experiment and see what happens. Logical operators As with arithmetic operations, the logical operators that required two operands are performed by reversed polish notation. The operands are separated by and then the logical key is pressed. Not is the only logical operator that has one operand. For this section, set window size to a byte, set number base to binary and the set complement must be unsign. Type C (Clear) Type D (Decimal) Type 8 Type L (Length) Type s (set complement) Type u (unsign) Type B (Binary) And And is the logical product. The test reguires that the bit position of the x and y registers are 1 for the result of that bit position to be 1 else the bit position is 0. This feature is called "masking" and is used to zero out unwanted one bits within a byte or whatever length is being tested. Type 10101010 Type Type 11110000 (mask) Type A (And) Or Or is the logical sum. If either of the bit position of the x and y registers is 1, the result for that bit position will be 1 else the bit position is 0. Type C (Clear) Type 10101010 Type Type 11110000 Type O (Or) Xor Xor is the logical difference. Xor is "exclusive or" and differs from the inclusive "or" described above in that only one of the bit position being tested can be 1 for the result to be 1 otherwise the result is 0. Type C (Clear) Type 10101010 Type Type 11110000 Type X (Xor) Not Not is the logical complement. Not inverts the value of the x register and is equivalent to an integer multiplied by -1 in one's complement. Type C (Clear Type 10101010 Type N (Not) All number bases may be used for logical operations. REAL MODE Real mode allows decimal point and scientific notation (floating point) entries. A floating point number is represented by an optionally signed integer, a fraction and an exponent. A decimal point separates the integer from the fraction. The exponent is optional and is identified by the digits following the letter E and its sign (+ or -). The E means "times ten to the power of". Absence of a sign or + sign means move the decimal point to the right and a - sign means move the decimal point to the left. Any number from 2.9E-39 to 1.7E+38 (positive or negative) can be represented. See Arithmetic Operations Section for additional information. When entering real mode, the window size will be expanded to 64 positions (eight bytes). The Computer Science Calculator stores the entered values and the arithmetic results in double-precision format. Type R Type 2 Type S (Sign change) Type (place value in y register) Type .1245E+2 Type / (divide X/Y) Type B (display result in binary) Type C (Clear) Use shift left (key 4 on the numeric pad) to correct an erroneous key entry. The use of this key will backspace and erase the last entry. Follow instructions on bottom line of the monitor to exit from real mode. KEYBOARD INTERPRETATION Keyboard interpretation converts an ASCII code to the character representation. ASCII codes are zero (0) to 255. Type K (enter Keyboard interpretation) Type 13 Type A (convert ASCII code to character) Convert character to ASCII code: Type Type C (convert character to ASCII code) Type CTRL and BREAK (press both keys) Type C Follow instructions on bottom line of the monitor to exit from keyboard interpretation. ?ACyL602RT346*x FHC" o H  g + > @ 2  N-GSjl1=fs3LYq@km  XBK!#Y4Z;k.0Aq  Z;bdq&3]_r2>P\ )6]_x + = I x z | I!!!!! "\"x"z"""#K#####$$u$$$$%%'%D%d%v%%%%%%%%&i&&&&& '*'^''''''' (P(R(Z(((=)@))))*u** +%+'+7+w++++++!,q,,-L-N------..:.b.{.}...../U/d//////0^0u0000000Q11111112242B2Z2\2^2p22223373W3o33333?4S4U444445.505y5555556666S6l6n6v667\77778#868V8{88889h99999:<:h:j::::::";j;;;;/D>V>t>>>>>(?8?W?j?|?????@S@@@@@@AA A[AAAAAA"B$B&B(BRBTBBB?C|CCD^DDDDAEJEEEEEE.FAFeFFFFGFGHGGGGGGGHAH|HHHHHH9I;IhItIvIIIIB@N