beautypg.com

Rpbasic-52 programming guide – Remote Processing BASIC 52 User Manual

Page 5

background image

RPBASIC-52 PROGRAMMING GUIDE

1-2

Basic Interpreters

Ther e are se veral ty pes an d leve ls of inte rpreter s. A
slow, very basic type of interpreter figures out what
each com man d is sup posed to do du ring run time . A
token-based interpreter, such as this basic, is much
faster. This type exa mines ea ch program line as it is
typed in, figures out w hat it should do, and c onverts
it to a stri ng of B asic to kens m ixed w ith text . A
token is a single character that represents a
command. For example, an ASC II value of 89H
repres ents th e PR INT com man d.

After a line is p rocess ed, it is st ored in mem ory.
When you type the RUN command, each program
line is scanned. A token causes a branch to an
assembly language routine which carries out the
required action.

ELEMENTS OF A BASIC PROGRAM

Commands

Com man ds dire ct or pe rform an out put ac tion.
Exam ples ar e PR INT , SAV E, PO KE, a nd LO AD .
Comm ands do not return a value used for
computation.

Functions

Func tions re turn a v alue u sed for c omp utation .
Exam ples ar e AIN , PEE K, SIN , and C OM $.
Functions do not cause a ch ange in an ou tput.

Line Numbers

Progra m line s begin with a uniqu e line n umb er.
Each line nu mber m ay contain on e or more B asic
statemen ts separated by a colon. Line num bers are
in the range of 1 - 65535.

Operators

Ope rators a ct on o r conv ert num eric or s tring da ta.
These include arithmetic (+,-,*, and /), natural
logarithmic (base "e"), trig (SIN, COS), relational
(>, <, or <>), logical (.AND., .OR., .XOR.), and
string (ASC , STR) func tions. Special ope rators
c o n tr o l t h e h a rd w a re - sp e c if i c f e at u re s o f R P B A S I C -
52 such as interrupts, timers, counters, and direct
read/write of I/O ports.

Tasking Statements

Tasking statements define a condition and execution
location wh en a condition is m et. Statemen ts
include ON COM $, ON LINE, ON COUN T, and
ONITR . Programs executed as a result of these
statemen ts are treated as subro utines. The only
difference between a tasking routine and one called
by a GOSUB is the tasking can be called at any
time.

Expressions

An expression is a comb ination of instructions,
operators, data (constants, arrays or strings) and
variables wh ich, when ev aluated by B asic, is
equivalent to a sin gle nume rical value. Ma ny Basic
comm ands accep t expressions as w ell as explicit
data. Expressions which are used by commands and
functions are also called arguments.

WRITING AND EDITING PROGRAMS

Program development takes place on your PC using
y o ur w or d p ro c es so r o r t he R P C c a rd . P r og ra m s
from your PC are downloaded using a serial
c o m m un ic a ti on p ro g ra m .

Each progra m line can co ntain a t mos t 79 ch aracte rs.
Program lines can be entered in any sequence.
RPBA SIC-52 properly orders line numbers.

Multiple statements on a single line are allowed
when statements are separated by colon (:) and do
not ex ceed a total o f 79 cha racters per pro gram line.
Ending a program line with a colon may cause a
program to hang.

There are two ways to write Basic programs. The
first way is to directly type in the program to the
card. All standard Remote Processing cards have a
mea ns of sto ring pro gram s to a fla sh type EPR OM .
The second way is use a text editor and download
the resulting file to the system. Just be sure to save
files in DOS text format.

Downloading programs means transferring them
from y our PC (or M AC or term inal) to the ca rd.
Uploading means tran sferring them from the card
b a c k t o th e P C .

When uploading or dow nloading files, select A SCII
text format. XMODEM , YMODEM , or other
formats are not used. RPBASIC-52 does not know
when you are typing in a program or if something