Rpbasic-52 Programming Guide
Total Page:16
File Type:pdf, Size:1020Kb
RPBASIC-52 PROGRAMMING GUIDE COPYRIGHT PRODUCT SUPPORT Copyright 1996 - R emote Proc essing Corporation . If you have a question about RPBASIC-52 and All rights reserved. cannot find the answer in this manual, call us at the number listed below during norm al business hours. The software described in this manual is furnished under license. When you call, please have the following at hand: The contents of this manual and the specifications Your RPBASIC-52 programming guide herein may change without notice. Your card hardware manual A description of the problem Remote Processing Corportation 7975 E. Harvard Avenue Denver, Co 80231 Phone: 303 690 1588 Fax: 303 690 1875 email: [email protected] Internet: www.remotep.com Document order # 1084 Revision 1.4 i RPBASIC-52 PROGRAMMING GUIDE TABLE OF CONTENTS CLEAR COM ....................... 15 PREFACE .......................... 1 CLEAR DISPLAY ................... 16 MANUAL CONVENTIONS ........... 1 CLEAR TICK ...................... 17 Symbols and Terminology .......... 1 CLEAR KEYPAD ................... 17 Basic Interpreters .................. 2 COM .............................. 18 Commands ....................... 2 COM$ ............................. 19 Functions ........................ 2 CONT ............................. 20 Line Numbers .................... 2 COS .............................. 21 Operators ........................ 2 CR ................................ 22 Tasking Statements ................ 2 COUNT (statem ent) .................. 23 Expressions ...................... 2 COUNT (function) ................... 24 WRITING AND EDITING PROGRAMS . 2 DATA ............................. 25 Uppercase/Low ercase .............. 4 DATE (function) .................... 26 Variables and Constants ............ 4 DATE (statement) ................... 27 Subroutines ...................... 5 DBY .............................. 28 Passing Variables Between Programs .. 5 DIM .............................. 29 Addresses ........................ 5 DISPLAY .......................... 30 Arrays .......................... 5 DO-UNTIL ......................... 33 Strings .......................... 5 DO-WHILE ........................ 34 OPERATING MODES ................ 6 END .............................. 35 Command and Run Modes .......... 6 EXECUTE ......................... 36 Autorunning Programs ............. 6 EXP ............................... 37 Stopping Program Execution ........ 6 FOR-TO-STEP-NEXT ................ 38 X-ON and X-Off Flow Control ....... 6 FREE ............................. 40 STORING PROGRAMS ............... 6 GET .............................. 41 HARDWARE AND SOFTWARE GOSUB ........................... 42 INTERRUPTS .................... 7 GOTO ............................. 43 MULTITASKING CONSTRUCTS ...... 8 IDLE .............................. 44 COUNT Multitasking .............. 8 IF THEN ELSE ..................... 45 Serial Communication Multitasking ... 8 INPUT ............................ 46 ON LINE Multitasking ............ 12 INT ............................... 47 ON COUNT M ultitasking .......... 12 KEYPAD .......................... 48 Assembly Language Interface .......... 12 LD@ .............................. 49 Assembly language development LEN .............................. 50 environment ................. 12 LINE (Function) ..................... 51 OPERATORS ...................... 13 LINE# (Function) .................... 52 ARITHMETIC OPERATORS ......... 13 LINEB (Function) ................... 53 OBSOLETE and MODIFIED LINE (Statement) .................... 54 COMMANDS ................... 13 LINE# (Statement) ................... 55 COMMAND GROUPS ............... 14 LINEB (Statement) .................. 56 LIST .............................. 57 COMMANDS LIST# ............................. 58 ABS ............................... 1 LOAD ............................. 59 AIN ................................ 2 LOG .............................. 60 ASC ............................... 3 MTOP ............................. 61 ATN ............................... 4 NEW .............................. 62 BLOAD ............................ 5 NULL ............................. 63 BSAVE ............................ 6 ON COM$ ......................... 64 CALL .............................. 8 ON COUNT ........................ 65 CARD$ ............................ 9 ONERR ........................... 67 CBY .............................. 11 ON GOSUB ........................ 68 CHR .............................. 12 ON GOTO ......................... 69 CLEAR ........................... 13 ONITR ............................ 70 CLEAR S .......................... 13 ON KEYPAD ....................... 72 ii RPBASIC-52 PROGRAMMING GUIDE ON LINE .......................... 73 APPENDIX A - Network example program .... 1 ONTICK .......................... 75 PEEKB ............................ 76 APPENDIX B - Modem example program ..... 1 PEEKF ............................ 77 PEEKW ........................... 78 APPENDIX C- ERROR MESSAGES ........ 1 PEEK$ ............................ 79 A-STACK ........................... 1 PI ................................ 80 ARITH. UNDERFLOW ............... 1 POKEB ........................... 81 ARITH. OVERFLOW ................. 2 POKEF ............................ 82 ARRAY SIZE ....................... 2 POKEW ........................... 83 BAD ARGUMENT ................... 2 POKE$ ............................ 84 BAD SYNTAX ...................... 2 POP .............................. 85 C-STACK ........................... 2 PH0. .............................. 86 CAN'T CONTINUE ................... 2 PH1. .............................. 86 DIVIDE BY ZERO ................... 2 PRINT ............................ 87 I-STACK ........................... 3 PRINT #, .......................... 87 MEMORY ALLOCATION ............. 3 P. ................................ 87 NO DATA .......................... 3 ? ................................. 87 PUSH ............................. 88 APPEND IX D - Data storage ............... 1 PWM ............................. 89 STRING STORAGE .................. 1 READ ............................. 90 VARIABLE STORAGE ............... 1 REM .............................. 91 FLOATING-POINT FORMAT .......... 1 RESTORE ......................... 92 RETI .............................. 93 APPENDIX E - Software revision history ..... 1 RETURN .......................... 94 RND .............................. 95 SAVE ............................. 96 SGN .............................. 97 SIN ............................... 98 SPC ............................... 99 STOP ............................ 100 STR ............................. 101 STRING .......................... 105 SQR ............................. 106 ST@ ............................. 107 TAB ............................. 108 TAN ............................. 109 TICK ............................ 110 TIME (function) .................... 111 TIME (comm and) .................. 112 UI0 .............................. 113 UI1 .............................. 113 UO0 ............................. 114 UO1 ............................. 114 USING ........................... 115 U. ............................... 115 WDOG ........................... 116 XBY ............................. 117 CONFIG COMMANDS ................. 118 CON FIG AIN ...................... 118 CONFIG BAUD ................... 119 CONFIG DISPLAY ................. 120 CONFIG LINE ..................... 121 iii RPBASIC-52 PROGRAMMING GUIDE PREFACE MANUAL CONVENTIONS This programming guide is for Remote Processing Information appearing on your screen is shown in a controllers using RPBASIC-52 language. It was different type. derived from Intel MCS-51 BASIC, V1.1. Several command extensions and features have been added Example: to effectively speed up command execution. RPBASIC-52 V1.0 Copyright Remote Processing (1995) Bytes free: 27434 M Buffered serial ports. Received characters are buffered to 256 characters. PRIN T strings are Symbols and Terminology put into a 256 character buffer, making it much faster. <xxx> Paired angle brackets are used to indicate a specific key on your keyboard. For M Multi-tasking constructs such as ON LINE, ON example, <esc> means the escape key. COM, ON COUNT, and ON KEYPAD. Lines and keypad are monitored at assembly language expr Term m eaning a num ber, simple speed on every 5 ms tick time. This speeds up variable, or mathematical expression program execution because the main program involving variables and numbers. The no longer has to monitor these points. following are valid expr: M Softw are comm ands directly support hardw are. 45.3 DATE and TIM E wo rk with the real time clock. B AIN reads a voltage while AOT outputs one. CYCLE B*45 Some cards do not have all hardware features so do C*D+54 not support all of the commands. Cards supported or INT(D) exceptions are listed with each command. In some cases you must refer to your hardware manual for expr can be another function. exact ranges. Complexity of expr is limited by available stack memory. Usually this is A few original BASIC-52 commands have been 7 levels of parentheses. removed. These commands were oriented around specific registers in the 8052 chip or a specific For cla rity, expr may be another name design. For example, the PROG command assumed such as position, channel, and so on. code is stored in an EPROM. Remote Processing cards use a flash EPROM which uses a new italic Italicized variables require an programming algorithm. The PROG command