beautypg.com

Remote Processing CAMBASIC User Manual

Page 8

background image

Concepts - 2

Line Labels

You can write a program to GOTO or GOSUB to a label instead of a line number. T his makes for more readable code.

90 A3 = AIN(0)
100 GOSUB ..FILTER
110 IF FL > 138 THEN GOTO ..OVER_LIMIT
.
.
.
5460 ..FILTER
5470 FL=.875

*

FL+.125*A3

5480 RETURN
.
.
.
8950 ..OVER_LIMIT
8960 OUT 49,3 :’shut down

Using line labels makes it easier to review code. You would pr obably know what “F ILTER ” does before r emember ing the
line number it is on.

Line labels must be the first and only information on a line.

NOTE:

Labels may not be used with ON GOTO, ON GOSUB, RESTORE, or RESUME.

When labels are used with GOTO, etc., no other statements may follow the label on the same line.

Debugging

CAM BASIC provides you with sev eral m ethods to help de bug your progr am. As with all de bugging, technique is usu ally
more impor tant than tools. See the Debugging Program s Chapter for m ore information.

Bit Manipulation

CAM BASIC has commands for manipulating and reading bits. The BIT statement and BIT function can modify and read
individual bits. In order to modify a bit at an I/O port, the port m ust first be r ead, the appro priate bit set an d the byte
written back to the port. The BIT statement does this automatically. The BIT function reads back individual bits. It
retur ns a “ 1” o r “ 0” to reflects the state of the bit.

Communications Ports

CAM BASIC supports two serial ports, COM 1 (console) and COM2. Once the serial ports are configured, they can
simultaneously capture data in the background while the program executes. If the ON COM $ statement is used,
CAM BASIC will branch to the user’s routine to handle the incoming data when the message is complete.

Both ports also have output buffering. W hen the PRINT statement is executed, the characters to be printed are sent to the
multitasker and program execution continues at the next statement. The program does not wait until all the characters are
printed. This is especially useful when data is being transmitted at a low baud rate over a m odem or radio link. The
output buffers are 255 characters long.

Real time Multitasking

CAM BASIC can perform several kinds of tasks at assembly language speed while the program is running. See the
Multitasking Chapter for mor e information.