Download Print this page

Casio FX-890P Owner's Manual

Casio personal computer owner's manual  .
Hide thumbs

Advertisement

PERSONAL COMPUTER
FX-890P / Z-1 / Z-1GR
OWNER'S MANUAL
This manual has been written by a non-Japanese speaking CASIO fan to help other
non-Japanese speaking CASIO fans to make the best out of their FX-890P, Z-1GR,
Z-1GRa or Z-1GR pocket computer. It is based on the Japanese Z-1 users' manual,
the FX-880 & PB2000C English manuals, and all kind of other information gathered
on the web. Even if most of the content is based on material with a CASIO copyright,
the company CASIO cannot be held responsible for any inaccuracy within this
document.
This document is not intended for any commercial purpose. Do not pay anything for
it, and use it at your own risk.
Thanks to Ledudu.com, Daniel Pratlong, Marcus von Cube, and all the other guys
whose information posted on the web helped me with this project.
1

Advertisement

   Summary of Contents for Casio FX-890P

  • Page 1

    FX-880 & PB2000C English manuals, and all kind of other information gathered on the web. Even if most of the content is based on material with a CASIO copyright, the company CASIO cannot be held responsible for any inaccuracy within this document.

  • Page 2: Table Of Contents

    CONTENTS 1   Unit Configuration ....................5   1.1   General Guide ....................5   1.2   Operational Functions ..................6   1.3   Symbol Display....................9   1.4   Keyboard ....................... 10   1.4.1   Keytop Functions ..................10   1.4.2  ...

  • Page 3

    6.1.1   C and the other programming languages ..........76   6.1.2   Learning about C with your pocket computer ......... 77   6.1.3   Meet the Casio C interpreter..............77   6.2   C Program Input .................... 78  ...

  • Page 4

    6.3   C Command Reference................111   6.3.1   Manual Commands................111   6.3.1   Fundamental commands ..............112   6.3.1   Mathematical Functions................ 118   6.3.2   String Functions..................123   6.3.3   Graphical Functions................125   6.4   C Commands Index..................126  ...

  • Page 5: Unit Configuration

    1 Unit Configuration 1.1 General Guide Power Switch Answer Key Backspace/Clear Line Key Shift Key Engineering Key Clear Screen / Home Key Volatile Shift Key Alphabet Keys Menu / Sub Menu Key Numeric Keys Space Key Calculator Key Decimal Key CAPS Key Program Area Keys Arithmetic Operator Keys...

  • Page 6: Operational Functions

    1.2 Operational Functions Power Switch Slide up to switch power ON and down to switch power OFF. Shift Key ( S ) Used to enter BASIC commands and symbols noted above the keys of the keyboard. Each press of this key causes the symbol “[S]” to switch on and off on the display. Throughout this manual, this key is represented by Shift in order to distinguish it from the alphabetic S key.

  • Page 7

    Switches the alphabet keys between upper case and lower case characters. The upper case mode is indicated by the “CAPS” symbol on the display. Cursor Keys (  ,  ,  ,  ) Move the cursor on the screen. Each press moves the cursor in the direction noted on the keys pressed, while holding down the keys causes continuous, high speed movement.

  • Page 8

    Menu / Sub Menu Key ( MENU / SUB MENU) Used in combination with numeric keys to specify operational modes. MENU 1 …. Serial Port communication mode MENU 2 …. BASIC mode (program writing/editing) MENU 3 …. C mode (program writing/editing) MENU 4 ….

  • Page 9: Symbol Display

    1.3 Symbol Display The symbols noted on the display illustrated below appear to show the current status of a calculation CAPS . BASIC . DEG . RAD . GRA . CAPS: Upper case alphabetic characters (lower cases when not displayed) Shift mode (commands/functions marked above the keys can be input BASIC: BASIC mode (BASIC program input, editing, execution)

  • Page 10: Keyboard

    1.4 Keyboard A look at the keyboard of the unit reveals characters and symbols located above the keys. These are accessed using the CAPS and Shift keys. 1.4.1 Keytop Functions Normal Mode In this mode, each key inputs the characters, symbols, or commands noted on the keys themselves.

  • Page 11: Functions Noted Above The Keys

    1.4.2 Functions Noted Above the Keys The BASIC one-key commands, and the symbols and commands noted above the keys are entered when the corresponding keys are pressed following the Shift key. Note, however, that pressing the numeric keys ( 0 - 9 ) after Shift in the CAL mode executes the BASIC program in the corresponding program area.

  • Page 12: Screen Editor

    1.5.3 Screen Editor Any program lines or data included on the virtual screen can be edited. First the portion of the program or data is brought onto the actual screen, and then the cursor is located at the position to be edited 1.5.4 Display Contrast CONTRAST The display may appear dark or dim depending upon the strength of the batteries or...

  • Page 13: Power Supply

    Characters which cannot be displayed using keyboard input can be displayed using the CHR$ function. 1.7 Power Supply This unit is equipped with a main power supply (four AA Alkaline batteries) and a backup power supply (one CR2032 lithium battery). Batteries should be replaced whenever the display remains dim, even after contrast adjustment.

  • Page 14

    Note: This hardware test will erase all programs and data stored in the unit. Selecting one of the options of the self-test menu will allow following tests 0. Test of the Read Only Memory, computing check sum and XOR check 1.

  • Page 15: Fundamental Operation

    2 Fundamental Operation This section covers the various modes available with the computer using a series of simple examples. These procedures should be mastered before attempting more complex operations. 2.1 CAL Mode The CAL mode is in effect each time the power of the unit is switched ON. Arithmetic calculations, function calculations, formula storage calculations, program execution can be performed in this mode.

  • Page 16: Basic Mode

    Now, calculate the selling prices of the following: PURCHASE PRICE PROFIT $1000 $960 CALC PURCHASE?_ 1000 . PURCHASE?1000 PROFIT?_ 0 . 3 . PURCHASE?1000 PROFIT?0.3 SELL= 1428.571429 CALC PURCHASE?_ 960 . PURCHASE?960 PROFIT?_ . 25 . PURCHASE?960 PROFIT?.25 SELL= 1280 As can be seen in this example, once a formula is input, it can be used repeatedly by simply assigning values for the variables.

  • Page 17: C Mode

    2.4 C Mode The C mode is used for the creation, execution and editing of C programs. The C mode can be entered from another mode by pressing MENU 3 . EXAMPLE: Create and execute a program that prints HELLO. PROGRAM INPUT MENU <...

  • Page 18: Calculation Function

    3 Calculation Function This section covers fundamental arithmetic calculations and function calculations, which are performed manually. 3.1 Manual Calculation Preparations Switch the power of the unit ON CAPS . . BASIC . DEG . . . The display illustrated above appears whenever the power is switched ON. It indicates the CAL mode in which manual calculations can be performed.

  • Page 19

    EXAMPLE: 33 x 5 + 16 = 181 For the sake of the example, the above calculation will be performed with the value 33 mistakenly entered as 34. 34 * 5 + 16 . 34*5+16 .   . (Move cursor to position for correction.) 34*5+16 33*5+16 ....

  • Page 20: Priority Sequence

    EXAMPLE 3: (4.5 x 10 ) x (-2.3 x 10 ) = -0.01035 OPERATION: 4.5 IE 75 * - 2.3 IE - 78 . 4.5E75*-2.3E-78 -0.01035 Exponents are entered by pressing the IE key (or the alphabetic E key) before entering the value.

  • Page 21: Scientific Calculations

    3.1 Scientific Calculations The scientific functions can be used either with BASIC programs or for manual calculations. For the sake of the explanation, all the examples here will cover only manual calculations. 3.1.1 Trigonometric and Inverse Trigonometric Functions SIN (Sine), COS (Cosine), TAN (Tangent), ARCSIN (Arc Sine), ARCCOS (Arc Cosine), ARCTAN (Arc Tangent).

  • Page 22: Formula Storage Function

    4 Formula Storage Function The formula Storage function is very useful when performing repeat calculations. Three different keys are used when working with the formula Storage function. IN key……. Stores presently displayed formula. OUT key…… Displays formula stored in memory. CALC key….

  • Page 23: Utilization For Preparing Tables

    Y= 3.397 X?15 Y=3.313 22 . X?15 Y=3.313 X?22 Y= 3.180 . Y=3.313 X?22 Y= 3.180 27 . X?22 Y= 3.180 X?27 Y= 3.056 . Y= 3.180 X?27 Y= 3.056 31 . X?27 Y= 3.056 X?31 Y= 2.940 Y= 3.056 X?31 Y= 2.940 The CALC key can be used in place of the ....

  • Page 24

    OPERATION: SHIFT SET F 3 . Specification of number of decimal places P = X * Y : Q = X / Y Storing the formula CALC 4 . 27 . X?4.27 1 . 17 . X?4.27 Y?1.17 P= 4.996 ....

  • Page 25

    CALC RADIUS[M]?_ 1 . 205 . RADIUS[M]?1.205 HEIGHT[M]?_ 2 . 227 . RADIUS[M]?1.205 HEIGHT[M]?2.227 CYLINDER[M3]= 10.16 . RADIUS[M]?1.205 HEIGHT[M]?2.227 CYLINDER[M3]= 10.16 CONE[M3]= 3.39 . HEIGHT[M]?2.227 CYLINDER[M3]= 10.16 CONE[M3]= 3.39 RADIUS[M]?_ 2 . 174  CYLINDER[M3]= 10.16 CONE[M3]= 3.39 RADIUS[M]?2.174 HEIGHT[M]?_ And so on…...

  • Page 26: Basic Programming

    5 BASIC Programming Standard BASIC is employed as the programming language for this unit, and this section covers application of the BASIC language. 5.1 Features of BASIC 1. BASIC is much easier to use than other programming languages such as FORTRAN, making it suitable even for novices.

  • Page 27: Basic Program Configuration

    5.2 BASIC Program Configuration 5.2.1 BASIC Program Format The following is a typical BASIC program, which calculates the volume of a cylinder. EXAMPLE: 10 REM CYLINDER 20 R=15 30 INPUT “H=”;H 40 V=PI*R^2*H 50 PRINT “V=”;V 60 END As can be seen, the BASIC program is actually a collection of lines (six lines in the above program).

  • Page 28: Basic Program Input

    51146B : Capacity (number of bytes) remaining in area for writing programs and data (free area). This number depends on the type of unit (FX-890P, Z1), the presence of the optional RP-33 memory module, and will decrease as storage space is used.

  • Page 29: Program Editing

    EXAMPLE: Line 50 input 50 Shift PRINT Shift “ V = Shift “ ; V . 5.3.3 Program Editing The procedure used for making corrections or changes to a program depends upon what step of program input the changes are to be made. 1.

  • Page 30

    Again, the . key must be pressed to store the corrected line into memory after changes are made. Changes within a program already input The LIST command displays the program stored in the current program area form beginning to end. Shift LIST ....

  • Page 31: Basic Program Execution

    .. .. (displays line 30 to 60) 30 INPUT “H=”;H 40 V=PI+R^2*H 50 PRINT “V=”;V 60 END Here, a correction will be made in line 40. .. (Displays line 40 to 60, line 40 at the upper line of the display) ..

  • Page 32: Commands

    1. Executions that produce errors 2. Irregular execution that do not produce errors (mostly logic errors) Execution that produce errors Simple programming errors. This is the most common type of program error and is generally caused by mistakes in program syntax. Such errors result in the following message being displayed: SN error P0-10 This message indicates that a syntax error has been detected in line 10 of the...

  • Page 33: Rem

    of the data read from line 180, followed by the square root and cube root of the sum. Program execution is terminated when the operator enters a zero. Clear current total assigned to S 10 S=0 Specifies read operation should begin with 1 data item 20 RESTORE Input the number of data items to be read...

  • Page 34: Goto

    and assigns a value of 5 to N when the original value is greater. When a value of 5 or less is originally assigned to N, execution proceeds to the next line, with N retaining its original value. Line 50 checks whether or not value assigned to N is zero. In the case of zero, program execution jumps to nine 130, while execution proceeds to next line (line 60) when N is any other value besides zero.

  • Page 35: Labels

    Note: GOSUB routines can also be used to branch to other program areas, as in GOSUB #3 (branches to program area 3). Note, however, that a return must be made back to original program area using the RETURN command before an END command is executed.

  • Page 36: Operators

    5.6 Operators The following are the operators used for calculations, which involves variables. Operators Arithmetic operators Signs Addition Subtraction Multiplication Division Power Integer division ¥ Integer remainder of integer division Relational operators Equal to Does not equal <>, >< Less than <...

  • Page 37: Constants And Variables

    Logical Operators The operands of logical operations are truncated to integers and the operation is performed bit-by-bit to obtain the result. X AND Y X OR Y X XOR Y NOT X NOT Y String Operators Strings may be concatenated using a + sign. The result of the operation (including intermediate results) may not exceed 255 characters.

  • Page 38: Variables

    5.7.2 Variables Numeric Variables The following shows the numeric variables included in the sample program on page PROGRAM NUMERIC VARIABLES 20 R=15 30 INPUT “H=”;H 40 V=PI*R^2*H Numeric variables are so named because their contents are handled as numbers. Numeric variable names can be up to 15 characters long, and are used within programs to store calculation results or constants in memory.

  • Page 39

    EXAMPLE: Declare array variable A for storage of 9 numeric data items. 10 DIM A (8) Note: a declared value of 8 makes possible to store 9 data items. A(0) A(1) A(2) A(3) A(4) A(5) A(6) A(7) A(8) EXAMPLE: Recall value stored in element 4 of array A Y=A(4) X=4:Y=A(X) The value that specifies an element in an array (4 above) is called a subscript.

  • Page 40: Summary

    5.7.3 Summary Variable types The three following types of variable are available for use with this unit. 1. Numeric variables (up to 12-digit mantissa) A, a, NUMBER, POINTS 2. String variables (up to 255 characters) A$, STRING$ 3. Array variables Numeric array A(10), XX(3,3,3) String array...

  • Page 41: Basic Command Reference

    5.8 BASIC Command Reference 5.8.1 Format elements The method for entering statements is explained below. • Words in bold type are command or functions, and they must be entered as shown. • Braces indicate that one of the parameters enclosed must be specified. •...

  • Page 42: Manual Commands

    5.8.2 Manual Commands PASS PURPOSE: Specifies or cancels a password FORMAT: PASS “password” String expression EXAMPLE: PASS”TEXT” PARAMETERS: 1. Registering a single password makes it the password for all BASIC program areas (P0-P9) and for C language and Assembler program areas (F0-F9). 2.

  • Page 43

    CLEAR PURPOSE: Clears all variables and determines the memory mapping in accordance with the parameters entered. FORMAT: CLEAR [ [strings area size] [ , assembler area size , variables area size ] ] Numeric expression Numeric expression Numeric expression EXAMPLE: CLEAR CLEAR 400 CLEAR 4096,512,6144 PARAMETERS:...

  • Page 44

    SYSTEM PURPOSE: Shows main system status. FORMAT: SYSTEM EXAMPLE: SYSTEM PRINT OFF TRACE OFF CLEAR 4096,512,6144 FREE 83703 V:4096 EXPLANATION: Data returned by the SYSTEM statement are: 1. PRINT mode (ON/OFF) 2. TRACE mode (ON/OFF) 3. CLEAR followed by 3 numbers. These are the parameters of the last CLEAR statement entered.

  • Page 45

    LIST [ALL] PURPOSE: Displays all or part of the currently specified program. FORMAT: [start line number] [end line number] ] Line number Line number LIST [ALL] *Label Label name EXAMPLE: LIST LIST 100 LIST 100-300 LIST -400 LIST*Root PARAMETERS: 1. Start line number: integer in the range of 1≤ line number ≤ 65535 (first line number when omitted) 2.

  • Page 46

    EDIT PURPOSE: Enters the BASIC edit mode. FORMAT: [start line number] Line number or period EDIT *Label Label name EXAMPLE: EDIT 100 PARAMETERS: 1. Start line number: integer in the range of 1 ≤ line number ≤ 65535 (first line number when omitted) 2.

  • Page 47

    PURPOSE: Executes a program. FORMAT: [start line number] Line number or period *Label Label name EXAMPLE: RUN RUN 100 RUN*Root PARAMETERS: 1. Start line number: Interger in the rage of 1 ≤ line number ≤ 65535 2. Label: Name of a label in the program.. Entering an unknown label will generate an “UL error”.

  • Page 48: Fundamental Commands

    5.8.3 Fundamental Commands PURPOSE: Terminates program execution. EXPLANATION: 1. Terminates program execution, and the computer stands for command input 2. Closes all files that are open 3. Variables and arrays are not cleared. 4. Any number of END statements can be used in a single program. Program execution is terminated and open files are closed automatically at the end of a program even if an END statement is not included.

  • Page 49

    GOTO PURPOSE: Branches unconditionally to a specified branch destination. FORMAT: branch destination line number Line number GOTO # program area number Single character; 0-9 *Label Label name EXAMPLE: GOTO 1000 GOTO #7 GOTO *Finish PARAMETERS: 1. Branch destination line number: integer in the range of 1≤ line number ≤65535 2.

  • Page 50

    GOSUB PURPOSE: Jumps to a specified subroutine. FORMAT: branch destination line number Line number GOSUB # program area number Single character; 0-9 *Label Label name EXAMPLE: GOSUB 100 GOSUB #6 GOSUB *Root PARAMETERS: 1. Branch destination line number: integer in the range of 1≤ line number ≤65535 2.

  • Page 51

    ON GOTO PURPOSE: Jumps to a specified branch destination in accordance with a specified branching condition. FORMAT: branch destination line number Line number Condition GOTO [ # program area number Numeric expression Single character; 0-9 *Label Label name branch destination line number Line number [ , [ # program area number...

  • Page 52

    ON GOSUB PURPOSE: Jumps to a specified subroutine in accordance with a specified branching condition. FORMAT: branch destination line number Line number Condition GOSUB [ # program area number Numeric expression Single character; 0-9 *Label Label name branch destination line number Line number [ , [ # program area number...

  • Page 53

    IF-THEN-ELSE / IF-GOTO-ELSE PURPOSE: Executes the THEN statement or GOTO statement when the specified condition is met. The ELSE statement is executed when the specified condition is not met. FORMAT: THEN statement statement condition [ : statement ELSE [ : statement Numeric expression GOTO branch destination branch destination...

  • Page 54

    FOR-NEXT PURPOSE: Executes the program lines between the FOR statement and NEXT statement and increments the control variable, starting with the initial value. Execution is terminated when value of the control variable exceeds the specified final value. FORMAT: control variable initial value final value Numeric variable name...

  • Page 55

    7. The control variable retains the value that exceeds the final value (and terminates the loop) when loop execution is complete. With the loop FOR I=3 to 10 STEP 3 for example, the value of control variable I is 12 when execution of the loop is complete. 8.

  • Page 56

    DATA PURPOSE: Holds data for Reading by the READ statement. FORMAT: DATA [ data ] [ data ] Constant Constant EXAMPLE: DATA 10,5,8,3 DATA CAT,DOG,LION PARAMETERS: 1. Data: String constants or numeric constants 2. String constants: Quotation marks are not required unless the string contains a comma that is part of the data.

  • Page 57: Mathematical Functions

    5.8.4 Mathematical Functions PURPOSE: Returns the absolute value of the argument. FORMAT: (argument) Numeric expression The parenthesis enclosing the argument can be omitted when the argument is a numeric value or variable. EXAMPLE: ABS (-1.1) PARAMETERS: argument : numeric expression SEE: SGN PURPOSE: Returns the angle value for which cosine (angle value) = argument.

  • Page 58

    PURPOSE: Returns the angle value for which sine (angle value) = argument. FORMAT: (argument) Numeric expression The parenthesis enclosing the argument can be omitted when the argument is a numeric value or variable. EXAMPLE: ASN (0.1) PARAMETERS: argument must be within the [-1 , +1] range EXPLANATION: 1.

  • Page 59

    PURPOSE: Returns the cubic root of the argument. FORMAT: (argument) Numeric expression The parenthesis enclosing the argument can be omitted when the argument is a numeric value or variable. EXAMPLE: Y = CUR (X) PARAMETERS: argument: numeric expression. SEE: SQR (argument) PURPOSE: Returns the value of e FORMAT:...

  • Page 60

    PURPOSE: Returns the integer part of the argument. FORMAT: (argument) Numeric expression The parenthesis enclosing the argument can be omitted when the argument is a numeric value or variable. EXAMPLE: FIX (-1.5) PARAMETERS: argument : numeric expression SEE: INT, FRAC FRAC PURPOSE: Returns the fractional part of the argument.

  • Page 61

    HYPASN PURPOSE: Returns the value for which hyperbolic sine (value) = parameter. FORMAT: HYPASN (argument) Numeric expression The parenthesis enclosing the argument can be omitted when the argument is a numeric value or variable. EXAMPLE: HYPASN (-150) PARAMETERS: argument must be within the ]-5x10 , 5x10 [ range EXPLANATION:...

  • Page 62

    HYPSIN PURPOSE: Returns the value of the hyperbolic sine of the argument. FORMAT: HYPSIN (argument) Numeric expression The parenthesis enclosing the argument can be omitted when the argument is a numeric value or variable. EXAMPLE: HYPSIN (1.5) PARAMETERS: argument must be within the [-230.2585092 , +230.2585092] range. EXPLANATION: 1.

  • Page 63

    PURPOSE: Returns the common logarithm of the argument. FORMAT: (argument) Numeric expression The parenthesis enclosing the argument can be omitted when the argument is a numeric value or variable. EXAMPLE: LOG (7922) -100 PARAMETERS: argument must be within the ]10 , 10 [ range.

  • Page 64

    PURPOSE: Returns the permutation nPr for the values of n and r. FORMAT: ( n value r value ) Numeric expression Numeric expression EXAMPLE: X = NPR(69,20) PARAMETERS: n value and r value should follow: 0 ≤ r ≤ n < 10 EXPLANATION: 1.

  • Page 65

    RAN# PURPOSE: Returns a random value in the range of 0 to 1. FORMAT: RAN# (argument) Numeric expression The parenthesis enclosing the argument can be omitted when the argument is a numeric value or variable. EXAMPLE: RAN# * 10 PARAMETERS: argument : numeric expression EXPLANATION: 1.

  • Page 66

    ROUND PURPOSE: Rounds the argument at the specified digit. FORMAT: ROUND ( argument digit ) Numeric expression Numeric expression The parenthesis enclosing the argument can be omitted when the argument is a numeric value or variable. EXAMPLE: ROUND (A, -3) PARAMETERS: 1.

  • Page 67

    PURPOSE: Returns the square root of the argument. FORMAT: (argument) Numeric expression The parenthesis enclosing the argument can be omitted when the argument is a numeric value or variable. EXAMPLE: SQR (4) PARAMETERS: argument must be positive. SEE: CUR PURPOSE: Returns the value of the tangent of the argument. FORMAT: (argument) Numeric expression...

  • Page 68: String Functions

    5.8.5 String Functions PURPOSE: Returns the character code corresponding to the character in the first (leftmost) position of a string. FORMAT: (string) String expression EXAMPLE: ASC (“A”) PARAMETERS: String : string expression EXPLANATION: 1. Returns the character code corresponding to a character. The character code for the first (leftmost) character only is returned for a string of two or more characters long.

  • Page 69

    &H PURPOSE: Converts the 1 through 4-digit hexadecimal value following &H to a decimal value. FORMAT: &H argument Hexadecimal value EXAMPLE: A = &HAF PARAMETERS: Hexadecimal value in the [0, FFFF] range. EXPLANATION: 1. The hexadecimal value is expressed using values 0 to 9, plus characters A to 2.

  • Page 70

    LEFT$ PURPOSE: Returns a substring of a specified length counting from the left of a string. FORMAT: LEFT$ ( string , number of characters ) String expression Numeric expression EXAMPLE: LEFT$ (“ABCDEF”, 3) PARAMETERS: 1. String: string expression 2. Number of characters: numeric expression truncated to an integer in the [0 , 256[ range.

  • Page 71

    MID$ PURPOSE: Returns a substring of a specified length from a specified position within a string. FORMAT: MID$ ( string position number of characters ] ) String expression Numeric expression Numeric expression EXAMPLE: MID$ (A$, 5, 3) PARAMETERS: 1. String: string expression 2.

  • Page 72

    STR$ PURPOSE: Converts the argument (numeric value or numeric expression value) to a string. FORMAT: STR$ (argument) Numeric expression EXAMPLE: STR$ (123), STR$ (255+3) PARAMETERS: Argument: numeric expression EXPLANATION: 1. Converts decimal values specified in the argument to strings. 2. Converted positive values include a leading space and converted negative values are preceded by a minus sign SEE: VAL PURPOSE: Converts a numeric character string to a numeric value.

  • Page 73: Graphical Functions

    5.8.6 Graphical Functions DRAW PURPOSE: Draws a line segment between two graphic coordinates. FORMAT: DRAW [ ( x1 , y1 ) - ( x2 , y2 ) Numeric expression Numeric expression Numeric expression Numeric expression EXAMPLE: DRAW (0,0)-(50,50) DRAW-(100,50) PARAMETERS: 1.

  • Page 74

    POINT PURPOSE: Returns the status of a pixel FORMAT: POINT , y ) Numeric expression Numeric expression EXAMPLE: POINT(50,50) PARAMETERS: (x, y) is a graphic coordinate. 1. x should be in the [0 , 191] range. 2. y should be in the [0 , 63] range. EXPLANATION: Value returned is 1 if the pixel is active (black), 0 if the pixel is inactive.

  • Page 75: Basic Commands Index

    5.1 BASIC Commands Index &H 69 LOAD# 57 LOCATE ANGLE 57 LOG, LN 68 LPRINT ASN, ACS, ATN 58 MID$ BEEP CHR$ NEW [ALL] CLEAR 43 NEW# CLOSE ON ERROR GOTO 59 ON GOSUB DATA 56 ON GOTO DEFSEG OPEN 68 PASS PAUSE DMS$...

  • Page 76: C Programming

    6 C Programming 6.1 The Basics of C 6.1.1 C and the other programming languages Early history of C C is a programming language that incorporates such concepts as module programming and structural syntax along the lines of ALGOL. Another well-known offshoot of ALGOL is PASCAL, and forebears of C are the CPL and BCPL languages.

  • Page 77: Learning About C With Your Pocket Computer

    All of that changed with the introduction of the Casio PB-2000C pocket computer and its successors. It is now possible for everyone to enjoy the many benefits of programming in C.

  • Page 78: C Program Input

    With an interpreter, the program is entered and executed in the same environment, for easier operation. The Casio unit features a C interpreter. After you enter the program, all you have to do is enter the RUN command to execute it.

  • Page 79: Using The Editor

    3. Pressing the key 3 will lead to the C sub-menu allowing writing, compiling, running and editing programs in C language. < C > 2 3 4 5 6 7 8 9 51113B F1>Run/Load/Source You can use the   cursor keys to select the program area 0 - 9 The S key allows to start writing the source code with the editor.

  • Page 80

    To create a new program from the MENU mode 1. Press the MENU key to enter in the main menu. MENU < MENU > 1:F.COM 2:BASIC 3:C 4:CASL 5:ASMBL 6:FX 7:MODE 2. Press the key 3 to enter in the C mode <...

  • Page 81

    Editing a C program Once in the editor, there are two modes for editing: the INSERT mode and the OVERWRITE mode. Switch between these two modes by pressing the INS key. The INSERT mode is automatically specified when you enter the editor. The insert mode is indicated by a cursor thet looks like “_”.

  • Page 82: C Program Execution

    }↵ < 3> Note that the line number displayed at the lower right is the one requested. Now, let’s execute our program. 6.1 C Program Execution 6.1.1 To execute a program You can exit the editor by pressing the SUB MENU key, which will go back to the C mode menu.

  • Page 83

    To illustrate operation of the TRACE mode, we will add a sub() procedure at the top of our HELLO program, and call it in the main(). Here is how the modified program will look like: sub(){ printf(“WORLD¥n”); main(){ printf(“HELLO¥n”); sub(); Loading and running this program will generate following output: HELLO WORLD...

  • Page 84: Introduction To C

    To interrupt execution of the TRACE mode Lets run again the program in TRACE mode: .R U N . >run (F1-5) printf(“HELLO¥n”); Break?_ 1. You can press T or . to execute the line and carry on the TRACE mode. 2.

  • Page 85

    Enter the following program: .M A I N ( ) Shift { . SPC .P R I N T F ( “ CAPS H CAPS O W SPC A R E SPC .Y. .O. .U. Shift Shift ¥ N ” .).

  • Page 86

    Making your program easy to read You have probably noticed by now that we have been writing and editing our C programs in a certain format. The previous program was written and entered as: main(){ printf(“How are you?¥n”); printf(“Fine,thank you¥n”); We could have just as easily written and input it as: main(){ printf(“How are you?¥nFine,thank you¥n”);...

  • Page 87

    Note that there is a direct relationship with • the 1 % construction and the 2 argument • the 2 % construction and the 3 argument • the 3 % construction and the 4 argument. printf(“D=%d H=%x F=%f¥n”65,65,65.0); You just have to be careful to ensure that the proper % construction is matched with the proper value, or else you will get strange results.

  • Page 88: Variable Types And Operations

    The following results would be displayed: .R U N . >run D=65 O=101 H=41 C=A >_ 6.2.2 Variable types and operations Declaring variable types With C programs, you have to declare the type of data that will be assigned to each variable before you can use the variable.

  • Page 89

    The first four operations are addition, subtraction, multiplication and division. The value for “e” will be the modulus (remainder) of 49 divided by 12. When you execute the program, the display should appear as follows: .R U N . >run >_ The following statement in the first line of the program declares that all five variables will be for the storage of 16-bit integers.

  • Page 90: Entering Characters And Values

    6.2.3 Entering characters and values Entering a single character from the keyboard Here we will create a program that outputs a character and its corresponding character code in hexadecimal format. If you press the key for the letter “B”, for example, the format will be: Char=B Hex=0x42 The standard function getchar() is used to tell the computer to get one character...

  • Page 91

    Entering Values Now, let’s try a program that calculates the sine and cosine of values that you enter from the keyboard. Since we can be expecting decimal values for input and output, we will be defining the variable as floating-point. The program to accomplish this task would appear as follows: /* Compute sine &...

  • Page 92: Using Selection Statements

    6.2.4 Using selection statements Using the “if” selection statement You can use the “if” statement to tell the computer to shift the flow of control if certain conditions are met. The “if” statement has two basic formats. 1. if (condition) statement. Here, the statement is executed if the condition is met (true = any value other than 0), and not executed if the condition is not met (false = 0).

  • Page 93

    /* Quadratic equation */ /* #include <stdio.h> */ /* #include <math.h> */ main(){ double a,b,c,D,q,r; scanf(“%lf %lf %lf“,&a,&b,&c); D=b*b-4.0*a*c; if (d>=0){ q=(-b+sqrt(D))/a/2.0; r=(-b-sqrt(D))/a/2.0; printf(“%If, %If¥n“,q,r); else{ r=sqrt(-D)/a/2.0; q=-b/a/2.0; printf(“%lf+%lfi “,q,r); printf(“%lf-%lfi¥n“,q,r); The variables “a”, “b” and “c” correspond to the “a”, “b”, and “c” in the quadratic equation, while the “D”...

  • Page 94: Using Loops

    6.2.5 Using loops Using the “while” loop The “while” loop makes it possible to repeat execution of statements until a specific condition is met. The format of the “while” loop is as follows: while (condition) Statement The “while” loop first executes the condition. If the condition is met (true, returning a value other than 0), the statement is executed, and execution loops back to the “while”...

  • Page 95

    Using the #define statement Lines 3 and line 4 of the program contain the #define statement. The #define statement defines a name for a particular string of characters. In the above program, “#define STR ‘0’ “ tells the computer that anytime it comes across the name “STR”, it should replace it with the character “0”.

  • Page 96

    Using the “do – while” loop The “do – while” loop is another method that you can use for repeat execution. The format of the “do – while” loop is as follows: Statement while (condition); Unlike the “while” loop, the “do – while” loop executes the statement first and then checks whether or not the condition has been met or not.

  • Page 97

    Note the following: for (i=0; i<10; i++) printf(…) This tells the computer to execute the printf() statement starting from a count of 0 which is incremented by 1 which each pass of the loop, until the count reaches 10. As with the “if” and “while” loops, multiple statements within a “for” loop are enclosed in braces.

  • Page 98

    Nested loops The term nested loop means simply “loops inside of loops”. To better understand how nested loops work, let’s have a look at a very short, simple representative program. /* nested loops example */ /* #include <stdio.h> */ main(){ float a[3][3];...

  • Page 99: Defining Functions

    We have now the value assignment nested loop we saw before, followed by a similar set of loops to read and display the values after they are stored. The only new item is the “%8.2f” which specifies that each value will be displayed in an area of at least 8 characters, with two decimal places (right flush).

  • Page 100

    Arguments Arguments are used to pass values to the function when it is called. If no values are passed, the arguments can be omitted. If the arguments are omitted, the following argument type declaration is also omitted. Argument type declaration Declares the types of the arguments specified above.

  • Page 101

    /* 100 squares 3 */ /* #include <stdio.h> */ double dsquare(x) /* square */ double x; return (x*x); main(){ double d; for (d=1.0; d<=100.0; d+=1.0) printf(“(%lf)^2=%f¥n”,i,dsquare(d)); getchar(); /* waits ret key */ Variables are now declared as double precision floating-point. Variables declaration has to happen before using them in a statement.

  • Page 102: Constants And Variables

    6.1 Constants and Variables 6.1.1 Local variables and global variables Local variables A local variable is one that is declared within a function for use within that particular function only. Since such variables are local, you can use the same variable name in multiple functions without any problem –...

  • Page 103: Pointers And Variable Storage Locations

    Here, variable “i” is declared outside of any function, so “i” will be treated as a global variable. Consequently, it will retain its current value regardless of whether execution is in main() or pr(). In this program, variable “i” is assigned a value by the “for” loop in main(), and then the value of “i”...

  • Page 104: Data Types And Lengths

    Finally, the printf() statement displays the value of “xy” which is the result, no matter which arithmetic operation is performed. 6.1.3 Data types and lengths The following table shows the data types and their respective lengths for the interpreter. These are almost identical on all computers, except for the integer (int) that may change.

  • Page 105

    Code Hex Code Name Meaning ¥a 0x07 Bell (BEL) Sound buzzer ¥n 0x0A New Line (NL) Carriage return + Line feed ¥t 0x09 Horizontal tab (HT) Horizontal tab ¥b 0x08 Backspace (BS) Backspace (one character) ¥r 0x0D Carriage return (CR) Returns to line start ¥f 0x0C...

  • Page 106: Storage Classes

    Floating-point constants and double precision floating-point constants Decimal values can be defined as float type or double type constants using the format shown below. Exponents are indicated by the letter “E” or “e”. Example: 3.1416 -1.4141 1.0e-4 1.23456E5 The following shows the ranges of float and double. float 0, ±1e-63 ±9.99999e+63...

  • Page 107: Arrays And Pointers

    Note: The interpreter does not allow declaring a local “auto” variable within the code of a function. func(a) func(a) func(a) double a; double a; double a; int i,j,x; int i,j,x; int i,j; float fx,fy; long lx,ly; float fx,fy; for(i=0;i<5;i++){ long lx,ly; long lx,ly;...

  • Page 108: Operators

    This is because a string is actually a pointer to the first character, the “null” character (0) being added after the last character to close the string. Now, lets assume we want to access the third letter of the string “Casio”. We need to increment the pointer p by 2. *(p+2) is character “s”.

  • Page 109

    The following table shows all of the operators used by C and their functions, explained in their order of precedence. Primary Operators ( ), func( ) Parenthetical, function argument operations. x[ ], y[ ][ ] Specify array elements. Unary Operators Specifies content indicated by a pointer.

  • Page 110: Cast Operator

    The following table shows the precedence of associativity of the C operators. Precedence Operators Associativity High ( ), [ ] → Left to right Unary !, ~, ++, --, -, (type), *, &, sizeof ← Right to left Multiplication, *, /, % →...

  • Page 111: C Command Reference

    6.3 C Command Reference 6.3.1 Manual Commands PURPOSE: Execution of a C program. EXAMPLE: RUN RUN>”PRN:” PARAMETERS: You can specify the output console being the printer instead of the screen. EXPLANATION: Execution starts at the beginning of the main() function of the program currently loaded.

  • Page 112: Fundamental Commands

    6.3.1 Fundamental commands abort() PURPOSE: Program termination. FORMAT: void abort(); EXPLANATION: 1. Calling abort() function will cause the program to terminate immediately, indicating an unsuccessful termination. 2. The following may occur: file buffers are not flushed, streams are not closed, and temporary files are not deleted.

  • Page 113

    if() else PURPOSE: Executes one statement when the specified condition is true (not zero). A second optional statement following the “else” is executed when the specified condition is false (0). FORMAT: if (condition) statement 1 else statement 2 PARAMETERS: Condition can be any variable or expression that will be considered true if not 0. EXPLANATION: 1.

  • Page 114

    while() PURPOSE: Executes repeatedly a statement as long as the specified condition is true (not zero). . FORMAT: while (condition) statement PARAMETERS: Condition can be any variable or expression that will be considered true if not 0. EXPLANATION: 1. The “while” loop first executes the condition. If the condition is met (true, returning a value other than 0), the statement is executed, and execution loops back to the “while”...

  • Page 115

    for() PURPOSE: Executes repeatedly a statement as long as the specified condition is true (not zero). FORMAT: for (expression 1; condition; expression 2) statement PARAMETERS: 1. expression 1 sets initial state. 2. condition allows the loop to repeat. 3. expression 2 is executed after the statement. EXPLANATION: 1.

  • Page 116

    switch() case default PURPOSE: executes various statements depending on the value of the parameter. FORMAT: switch (expression) { [case constant i: statement i ]; default: statement; }; PARAMETERS: 1. expression must be an integer type (char, int, long, signed or unsigned). 2.

  • Page 117

    goto PURPOSE: Branches unconditionally to a specified destination label. FORMAT: goto label; PARAMETERS: label is the name of a label defined within the same function. EXPLANATION: 1. the goto statement and label concept are similar to the ones used in BASIC. 2.

  • Page 118: Mathematical Functions

    6.3.1 Mathematical Functions The math functions are part of a standard library in ANSI C, and it is recommended to add the following comment at the beginning of your program: /* #include <math.h> */ abs() PURPOSE: Returns the absolute value of an integer. FORMAT: int abs(n) int n;...

  • Page 119

    asinh() PURPOSE: Returns the value for which hyperbolic sine (value) = parameter. FORMAT: double asinh(x) double x; PARAMETERS: x must be within the ]-5x10 , 5x10 [ range EXPLANATION: 1. The mathematical formula for reverse hyperbolic sine is: asinh(x) = ln ( x + √ ) where ln is the natural logarithm.

  • Page 120

    cosh() PURPOSE: Returns the value of hyperbolic cosine (parameter). FORMAT: double cosh(x) double x; PARAMETERS: x must be within the [-230.2585092, +230.2585092] range. EXPLANATION: 1. The mathematical formula for hyperbolic cosine is: cosh(x) = (e ) / 2 where e is 2.7182818284590452353602874713526... 2.

  • Page 121

    pow() PURPOSE: Returns x to the power of y. FORMAT: double pow(x, y) double x,y; PARAMETERS: 1. x is a double precision floating-point number. 2. y is the power. EXPLANATION: 1. pow(x,y) is essentially computed using the method x = exp(y * log(x)). This means that any negative x may generate a mathematical error, despite the fact that x is mathematically valid.

  • Page 122

    tan() PURPOSE: Returns the value of tangent (parameter). FORMAT: double tan(x) double x; PARAMETERS: x must be within the ]-1440°, +1440°[ or [-8π , 8π Radians ] range. EXPLANATION: 1. The unit of the parameter x is specified using the angle() function. 2.

  • Page 123: String Functions

    6.3.2 String Functions The string functions are part of a standard library in ANSI C, and it is recommended to add the following comment at the beginning of your program: /* #include <string.h> */ strcat() PURPOSE: Appends a source string after the destination string. FORMAT: char *strcat(dest, source) char *dest, *source;...

  • Page 124

    strcpy() PURPOSE: Copies the source string into the destination string. FORMAT: char *strcpy(dest, source) char *dest, *source; PARAMETERS: 1. Destination string. 2. Source string. EXPLANATION: 1. The source string stays untouched. 2. The content of the source string is copied to the memory pointed by the destination string parameter.

  • Page 125: Graphical Functions

    6.3.3 Graphical Functions clrscr() PURPOSE: Clears display and moves cursor to upper left of screen FORMAT: void clrscr() ; getpixel() PURPOSE: Returns the status of a pixel FORMAT: int getpixel(x, y) unsigned int x, y; PARAMETERS: (x, y) is a graphic coordinate. 1.

  • Page 126: C Commands Index

    6.4 C Commands Index abort 112 if 118 inp acos, asin, atan 118 inport acosh, asinh, atanh 118 int angle 118 line auto linec beep log, log10 break 115 long breakpt 112 main call malloc calloc case 116 outport char clearerr printf clrscr...

This manual also for:

Z-1gr, Z-1

Comments to this Manuals

Symbols: 0
Latest comments: