Keyword
|
Example
|
Synopsis/Description
|
Notes
|
PRINT (also '?')
|
|
Prints literal Strings, Numbers,
String Variables, Numeric Variables, Functions. Supports Comma (",")
for (tabulated) spacing. A Carriage-Return is added at the end, unless
Semicolon (";") is provided. For numbers, their decimal part is printed
up to 6 figures - only meaningful digits are printed.
|
Numbers are always preceded by a blank or the minus sign.
|
LET
|
[LET] x=1
|
Assigns a value to a variable.
|
The "LET" keyword is optional.
Maximum length of identifiers is 8 chars in PIC18, 32 in PIC32,
including "$". |
DIM
|
DIM a(2,3) [=1,1,2,2,3,3]
|
Dimensionates an array. Up to
2 dimensions available in PIC18, up to 5 in PIC32. Note that
initialization values can be provided in the DIM statement.
|
|
IF
|
IF boolean-expression THEN
linenumber1 ELSE
linenumber2
|
Evaluates a test condition, and
Jumps to the Line number indicated by THEN clause or, optionally, to
the
one indicated by ELSE.
|
Every part of the condition is always evaluated,
i.e. no "short-circuit" happens. |
THEN
|
|
Part of IF statement, indicates
the line to jump to when condition is true. Though Statements are not
supported at this time, the Line Number can be an expression.
|
|
ELSE
|
|
Part of IF statement, indicates
the line to jump to when condition is false. Though Statements are not
supported at this time, the Line Number can be an expression. |
|
AND
|
|
Performs a Boolean AND between
values.
|
|
OR
|
|
Performs a Boolean OR between
values. |
|
GOTO
|
GOTO 100
|
Jumps to the specified line of
code.
|
Linenumber can be any Expression.
|
INPUT
|
INPUT a$
|
Reads a string from the Input
Stream, waiting until a Carriage Return is met.
|
|
REM (also ')
|
REM this is a note
|
Inserts a comment in the code:
the whole line is ignored.
|
|
FOR
|
FOR count=initial_value TO
final_value [STEP step]
|
Initiates a loop: a Cycle
variable is intialized to the given value. It will be incremented or
decremented by the STEP value (or +1 if omitted), and the block of code
will execute until the TO value is met.
|
|
TO
|
|
Part of the FOR statement:
indicates the ending condition.
|
|
STEP
|
|
(optional) Part of the FOR
statement: indicates the value to be added to or subtracted from the
Cycle variable at each iteration.. |
|
DO..LOOP
|
DO WHILE|UNTIL boolean .. LOOP
DO .. LOOP WHILE|UNTIL boolean
|
Creates a Loop in which the
conditional expression can be placed at the beginning or at the end.
|
|
GOSUB
|
GOSUB 100
|
Jumps to line of code, saving
the current address in order to return on completion of the subroutine.
|
|
RETURN
|
|
Returns to the address from
where the subroutine was called from.
|
|
ON..GOTO
|
|
Jumps to different Lines
according on the given number.
|
|
| ON..GOSUB |
|
Jumps to different Lines
according on the given number, and saves the Current Line number for
later RETURN.
|
|
| ON ERROR GOTO |
ON ERROR GOTO 1000
|
Sets an Error Handler, to which
program jumps when an error is encountered.
|
|
| ON IRQ GOTO |
|
Set one (or more) handler for
Interrupts.
|
(To be defined)
|
END
|
END
|
Ends the program and halts the
PIC in there (a reset is needed to restart).
|
|
RUN
|
|
Restarts the Program, clearing
all memory.
|
|
SLEEP
|
SLEEP 100
|
Stops the program flow for a
given number of milliseconds. If the argument is negative, the
processor is put into Sleep mode, waiting for an Event (IRQ or else) to
wake it up and let program continue.
|
|
STOP
|
STOP
|
Halts program execution and
waits for a keypress before continuing. Also allows exiting.
|
|
CONTINUE
|
|
Continues execution from where
it stopped (due to either an error or STOP Instruction)
|
|
POKE
|
POKE addr, value
|
Writes a 8bit value at the given
RAM location. Address can span in the whole range available. (8bit also
on PIC32)
|
|
SETPIN
|
SETPIN 1,2,0
|
Initializes a Pin of a Hardware
Pot as either input or output. Pin ranges from 1 to 8 on PIC18 and 1 to
32 on PIC32. Port ranges from 1 to 5 on PIC18 (PORTA..E) and 1 to 8 on
PIC32 (PORTA..H)
|
In third parameter, 0 is output and 1 is input.
|
OUTD
|
OUTD 1,2,1
|
Sets/Resets a given Pin on a
given Port (pin has to be set as output)
|
|
OUTDAC
|
OUTDAC 0,127
|
Outputs a value to the given DAC
Port.
|
Currently Port0 is the CVRCON reference output, Port1 is a
PWM,
Port2 is a I2C DAC, Port3 is a SPI DAC |
TONE
|
TONE 1,3,100
|
Generates a Tone (train of
pulses) at the given
frequency on the given Port's Pin.
|
|
CLS
|
CLS
|
Clears Screen: either on a LCD
module (using suitable LCD controller) or sending a VT100 sequence to a
Serial Terminal.
|
|
LOCATE
|
LOCATE 3,3
|
Positions the cursor: either on
a LCD module (using suitable LCD controller) or sending a VT100
sequence to a Serial Terminal. |
|
|
|
|
|
SIN
|
a=SIN(x)
|
Calculates the Sine of the
argument.
|
(radiant) |
COS
|
a=COS(x)
|
Calculates the Cosine of the
argument. |
(radiant) |
TAN
|
a=TAN(x)
|
Calculates the Tangent of the
argument. |
(radiant) |
LOG
|
a=LOG(x)
|
Calculates the Logarithm
(natural) of the argument. |
|
EXP
|
a=EXP(x)
|
Calculates the Exponential of
the argument. |
|
SQRT
|
a=SQRT(x)
|
Calculates the Square Root of
the argument. |
|
POW
|
a=POW(x,y)
|
Calculates the value of the
first argument raised to the power indicates by the second argument. |
|
PEEK
|
a=PEEK(address)
|
Reads a 8bit value at the given
Memory address. Address can span in the whole range available. |
(8bit
also on PIC32) |
TIMER
|
a=TIMER(ntimer)
TIMER(ntimer)=value
|
Reads current value of 16bit
Timer0..n.
Assigns a value to 16bit Timer0..n.
|
1 <= ntimer <= MAX. Maximum number of Timers available
is hardware-dependent
|
STATUS
|
a=STATUS(q)
|
Reads (and clears) hardware
peripherals status and errors (USART, etc)
|
q=0 to retrieve Reset Flags;
q=1 to read WakeUp Flags
q=2..4 to read USART1..3 status
|
IIF
|
a=IIF(boolean,expr_true,
expr_false)
|
Returns expr_true or expr_false
according to the value of the given boolean expression.
|
|
|
|
|
|
ABS
|
a=ABS(x)
|
Calculates the Absolute value of
the argument.
|
|
LEN
|
a=LEN(x)
|
Calculates the Length of the
string argument. |
|
ASC
|
a=ASC(a$)
|
Returns the ASCII value of the
first character of the string argument. |
|
ASIN
|
a=ASIN(x)
|
Calculates the Arcsine of the
argument. |
(output is in radiant) |
ACOS
|
a=ACOS(x)
|
Calculates the Arccosine of the
argument. |
(output is in radiant) |
ATAN
|
a=ATAN(x)
|
Calculates the Arctangent of the
argument. |
(output is in radiant) |
INT
|
a=INT(x)
|
Returns the Integer part of the
argument. |
|
RND
|
a=RND(10)
|
Generates a Random number in the
range 0..n. Passing a negative
argument sets the Seed of the Random Numbers Generator to the given
value. RND(0) always returns 0.
|
|
VAL
|
a=VAL("123")
|
Returns the Numeric Value of the
passed string.
|
|
VALLEN
|
a=VALLEN(a$)
|
Returns the Length of the
represented Numeric Value of the passed string. |
|
|
|
|
|
+
|
|
Performs Mathematical Addition
or concatenates two strings.
|
|
-
|
|
Performs Mathematical
Subtraction. |
|
*
|
|
Performs Mathematical
Multiplication. |
|
/
|
|
Performs Mathematical Division. |
|
MOD
|
|
Performs Mathematical Modulus
(remainder of division). |
|
AND
|
|
Performs Bitwise or Logical AND.
|
|
OR
|
|
Performs Bitwise or Logical OR. |
|
XOR
|
|
Performs Bitwise XOR. |
|
NOT
|
|
Performs Bitwise or Logical NOT.
|
|
()
|
|
Standard precedence operators.
|
|
E
|
|
Returns Euler's number i.e.
2.718282...
|
|
PI
|
|
Returns 3.141596535...
|
|
|
|
|
|
CHR$
|
a$=CHR$(65)
|
Returns a string containing one
single char, whose ASCII value is the one passed as argument.
|
|
STR$
|
a$=STR$(100) |
Returns the passed value
represented as a String.
|
|
LEFT$
|
a$=LEFT$("pippo",3) |
Returns the n leftmost characters of the given
String. |
|
RIGHT$
|
a$=RIGHT$("pippo",2) |
Returns the n rightmost characters of the given
String. |
|
MID$
|
a$=MID$("pippo",2,2) |
Returns the n characters of the given String,
starting from the given character, up to the given size. |
Also a function, to alter part of a string.
|
STRING$
|
a$=STRING$("pi",4) |
Returns the given String, duplicated n times. |
|
HEX$
|
a$=HEX$(100) |
Returns the Hexadecimal
representation of the given Number. |
|
INKEY$
|
a$=INKEY$() |
Reads the currently available
character in the input stream. Does not wait. |
|
INSTR
|
a=INSTR("pippo","ip") |
Searches for a substring into
the given string, and returns it position if found, or 0 otherwise. |
|
TRIM$
|
a$=TRIM$("
pippo ") |
Removes leading and trailing
spaces from a string.
|
|
MEM
|
PRINT MEM()
|
Returns the amount of RAM
available for variables. |
|
ERR
|
PRINT ERR(0);" at line ";ERR(1)
|
Returns the last Error Code (if
parm is 0) or the Line at which the last Error happened (if parm is 1)
|
|
ER$
|
PRINT ER$(ERR(0))
|
Returns the String corresponding
to the given Error Number.
|
|
|
|
|
|
IND
|
a=IND(1,4)
|
Returns the current value of the
given Pin on
the given Port. The pin can be set as either input or output: but the
current state of the pin (and not the latch) will be returned (i.e.
PORTx). |
|
INADC
|
a=INADC(channel)
|
Reads the value of the given ADC
channel. |
|
|
|
|
|
MOVETO
|
|
|
|
LINETO
|
|
|
|
RECTANGLE
|
|
|
|
ELLIPSE
|
|
|
|
ARC
|
|
|
|
POINT
|
|
|
|
SETCOLOR
|
|
|
|
SETBKCOLOR
|
|
|
|
GETPEN
|
|
|
|
BITBLT
|
|
|
|
|
|
|
|
|
|
|
|