ZBasic Language Reference
10
ZBasic Microcontrollers
configuration characters, the leftmost of which corresponds to the bit 7 of the port and the rightmost of
which corresponds to the least bit 0 of the port. For devices that are missing particular bits on a port or
have analog-only pins, you must use the X configuration character as a placeholder for the missing bit(s).
Certain bits of PortB and PortD have dedicated uses on some ZX devices that require a specific
configuration. Due to this requirement, those bits are protected from being changed by user-specified
configuration. By default, all bits are configured to be inputs with the pullup disabled except for the
special purpose bits.
Port Configuration Designators
Configuration
Character
Meaning
T
The corresponding bit should be a tri-state input (pull-up disabled).
P
The corresponding bit should be an input with the pull-up enabled.
D
The corresponding bit should be an input with the pull-down enabled.
0
The corresponding bit should be an output set to logic zero.
1
The corresponding bit should be an output set to logic one.
X
The corresponding bit is not a valid digital I/O pin for the device.
Note that it is not necessary to configure your ports using this option directive. The configuration may
also be done using the System Library subroutine PutPin() or the built-in registers like
Register.DDRA. Also, note that if you specify configuration directives for both the pins and the port
containing them, the last occurring directive will prevail.
Example
Option PortA "TPTP0001"
Option Base <value>
Default: 0
When an array is defined, the lower bound for each dimension may be specified explicitly (the
recommended practice) or it may be omitted. In the latter case, the compiler will utilize the default lower
bound which you can select using the Option Base directive. The <value> element of the directive
must be either 0 or 1. It is important to note that this directive has local scope, i.e., it only affects arrays
defined in the module in which the directive appears.
This option does not affect arrays defined without either the upper bound or the lower bound specified
(e.g. a Program Memory data item, an array that is a parameter to a procedure, a based array, or a ByRef
array). In these cases, the lower bound is always assumed to be 1.
Example
Option Base 1
Option Explicit
Default: Off
Traditionally, the purpose of the Option Explicit directive has been to require that each variable in
the program be explicitly defined. Historically, early Basic dialects allowed programs to be written so that
when the compiler encountered a new variable name, it automatically created a definition for it. Although
this may have been thought to be a nice feature, it turned out to be the source of many programming
errors and bugs. If you accidentally misspelled a variable name, a new variable was created entirely
unbeknownst to you. Because of this serious drawback implicit variable definition is not supported by
ZBasic. The Option Explicit directive is accepted by the compiler for compatibility reasons but
neither its presence nor its absence affects any aspect of the compilers operation.
|