Transcription of RPBASIC-52 PROGRAMMING GUIDE - Remote …
1 RPBASIC-52 PROGRAMMING GUIDEiCOPYRIGHTC opyright 1996 - Remote Processing Corporation. All rights software described in this manual is furnishedunder contents of this manual and the specificationsherein may change without Processing Corportation7975 E. Harvard AvenueDenver, Co 80231 Phone: 303 690 1588 Fax: 303 690 1875email: order # 1084 Revision SUPPORTIf you have a question about RPBASIC-52 andcannot find the answer in this manual, call us at thenumber listed below during normal business you call, please have the following at hand:Your RPBASIC-52 PROGRAMMING guideYour card hardware manualA description of the problemRPBASIC-52 PROGRAMMING GUIDEiiTABLE OF 1 MANUAL 1 Symbols and 1 Basic 2 Line 2 Tasking 2 WRITING AND EDITING PROGRAMS. 2 4 Variables and 5 Passing Variables Between 5 OPERATING 6 Command and Run 6 Autorunning 6 Stopping Program 6X-ON and X-Off Flow 6 STORING 6 HARDWARE AND 7 MULTITASKING 8 COUNT 8 Serial Communication 8ON LINE 12ON COUNT 12 Assembly Language 12 Assembly language 13 ARITHMETIC 13 OBSOLETE and 13 COMMAND 8 CARD$.
2 13 CLEAR 13 CLEAR 15 CLEAR 16 CLEAR 17 CLEAR 18 COM$.. 22 COUNT (statement).. 23 COUNT (function).. 25 DATE (function).. 26 DATE (statement).. 44IF THEN 50 LINE (Function).. 51 LINE# (Function).. 52 LINEB (Function).. 53 LINE (Statement).. 54 LINE# (Statement).. 55 LINEB (Statement).. 57 LIST#.. 63ON COM$.. 64ON 67ON 68ON 70ON 72 RPBASIC-52 PROGRAMMING GUIDEiiiON 78 PEEK$.. 83 POKE$.. 87 PRINT #,.. 87?.. 110 TIME (function).. 111 TIME (command).. 117 CONFIG 118 CONFIG 118 CONFIG 119 CONFIG 120 CONFIG 121 APPENDIX A - Network example 1 APPENDIX B - Modem example 1 APPENDIX C- ERROR 1 ARITH.
3 1 ARITH. 2 ARRAY 2 BAD 2 BAD 2 CAN'T 2 DIVIDE BY 3 MEMORY 3NO 3 APPENDIX D - Data 1 STRING 1 VARIABLE 1 FLOATING-POINT 1 APPENDIX E - Software revision 1 RPBASIC-52 PROGRAMMING GUIDE1-1 PREFACEThis PROGRAMMING GUIDE is for Remote Processingcontrollers using RPBASIC-52 language. It wasderived from Intel MCS-51 BASIC, Severalcommand extensions and features have been addedto effectively speed up command serial ports. Received characters arebuffered to 256 characters. PRINT strings areput into a 256 character buffer, making it constructs such as ON LINE, ONCOM, ON COUNT, and ON KEYPAD. Linesand keypad are monitored at assembly languagespeed on every 5 ms tick time. This speeds upprogram execution because the main programno longer has to monitor these commands directly support hardware. DATE and TIME work with the real time clock.
4 AIN reads a voltage while AOT outputs cards do not have all hardware features so donot support all of the commands. Cards supported orexceptions are listed with each command. In somecases you must refer to your hardware manual forexact few original BASIC-52 commands have beenremoved. These commands were oriented aroundspecific registers in the 8052 chip or a specificdesign. For example, the PROG command assumedcode is stored in an EPROM. Remote Processingcards use a flash EPROM which uses a newprogramming algorithm. The PROG command wasreplaced with CONVENTIONSI nformation appearing on your screen is shown in adifferent :Symbols and Terminology<xxx>Paired angle brackets are used to indicate aspecific key on your keyboard. Forexample, <esc> means the escape meaning a number, simplevariable, or mathematical expressioninvolving variables and numbers.
5 Thefollowing are valid *45C*D+54 INT(D)expr can be another function. Complexity of expr is limited byavailable stack memory. Usually this is7 levels of clarity, expr may be another namesuch as position, channel, and so variables require anexpression or value. For example:AIN(channel)KEYPAD(function)Elli psis (..) follow an instruction which optionallyaccept more data[,data][,data]..READ variable[,variable]..Optional portions of an instruction are enclosed inbrackets []:DISPLAY option[,option][,option] RPBASIC-52 PROGRAMMING GUIDE1-2 Basic InterpretersThere are several types and levels of interpreters. Aslow, very basic type of interpreter figures out whateach command is supposed to do during run time. Atoken-based interpreter, such as this basic, is muchfaster. This type examines each program line as it istyped in, figures out what it should do, and convertsit to a string of Basic tokens mixed with text.
6 Atoken is a single character that represents acommand. For example, an ASCII value of 89 Hrepresents the PRINT command. After a line is processed, it is stored in memory. When you type the RUN command, each programline is scanned. A token causes a branch to anassembly language routine which carries out therequired OF A BASIC PROGRAMC ommandsCommands direct or perform an output action. Examples are PRINT, SAVE, POKE, and LOAD. Commands do not return a value used return a value used for computation. Examples are AIN, PEEK, SIN, and COM$. Functions do not cause a change in an NumbersProgram lines begin with a unique line number. Each line number may contain one or more Basicstatements separated by a colon. Line numbers arein the range of 1 - act on or convert numeric or string data. These include arithmetic (+,-,*, and /), naturallogarithmic (base "e"), trig (SIN, COS), relational(>, <, or <>), logical (.)
7 AND., .OR., .XOR.), andstring (ASC, STR) functions. Special operatorscontrol the hardware-specific features of RPBASIC-52 such as interrupts, timers, counters, and directread/write of I/O StatementsTasking statements define a condition and executionlocation when a condition is met. Statementsinclude ON COM$, ON LINE, ON COUNT, andONITR. Programs executed as a result of thesestatements are treated as subroutines. The onlydifference between a tasking routine and one calledby a GOSUB is the tasking can be called at expression is a combination of instructions,operators, data (constants, arrays or strings) andvariables which, when evaluated by Basic, isequivalent to a single numerical value. Many Basiccommands accept expressions as well as explicitdata. Expressions which are used by commands andfunctions are also called AND EDITING PROGRAMSP rogram development takes place on your PC usingyour word processor or the RPC card.
8 Programsfrom your PC are downloaded using a serialcommunication program line can contain at most 79 characters. Program lines can be entered in any properly orders line statements on a single line are allowedwhen statements are separated by colon (:) and donot exceed a total of 79 characters per program line. Ending a program line with a colon may cause aprogram to are two ways to write Basic programs. Thefirst way is to directly type in the program to thecard. All standard Remote Processing cards have ameans of storing programs to a flash type EPROM. The second way is use a text editor and downloadthe resulting file to the system. Just be sure to savefiles in DOS text programs means transferring themfrom your PC (or MAC or terminal) to the card. Uploading means transferring them from the cardback to the uploading or downloading files, select ASCII text format.
9 XMODEM, YMODEM, or otherformats are not used. RPBASIC-52 does not knowwhen you are typing in a program or if somethingRPBASIC-52 PROGRAMMING GUIDE1-3else (laptop or mainframe) is sending it characters. The upload and download file does not contain anyspecial codes; they are simply ASCII programs is simply a process of receivingan ASCII file. You or your program simply need tosend "LIST" to receive the entire a program requires transmitting anASCII file. As you type in (or download) a line, RPBASIC-52 tokenizes that line. The time to dothis depends upon its complexity and how manylines of code have been must finish compiling a line beforestarting the next one. When a line is compiled, a ">"character is sent. This should be your terminalprograms pacing character when downloading your communications program cannot look for apacing prompt, set it to delay transmission after eachline is sent.
10 A 100 ms delay is usually adequate, butyour program may be long and complex and requiremore time. A result of short transmission time ismissing or incomplete program technique used to further program documentationand reduce code space is the use of comments(REM) in a downloaded file. For example, youcould have the following in a file written on youreditor:REM Check positionREM Read output from the pot and REM calculate the position2200 a = ain(0) :REM Get positionThe first 3 comments downloaded to the cardare ignored. Similarly, the empty lines betweencomments are also ignored. Line 2200, with itscomment, is a part of the program and could belisted. The major penalty by writing a program thisway is increased download that you can write a program in lower casecharacters. RPBASIC-52 translates them to programmers put "NEW" as the first line inthe file.