Page 36 of 62
SBasic User's Manual SBasic Version 2.7 Page 36
Printed: December 5, 1999
You can make your use of POKE easier to understand if you combine it
with named constants defined with the CONST statement.
Example:
const porta = $1000 ' define address of port A
poke porta, a ' write value in A to port A
The POKEB statement writes a 8-bit value to a specific address. This
is the usual statement for writing data to 8-bit I/O ports.
Example:
pokeb $1000, a ' write low 8 bits in A to addr $1000
Note the difference in syntax between the PEEKB function and the POKEB
statement; PEEKB uses parentheses around the address argument, while
POKEB does not use parentheses.
You can make your use of POKEB easier to understand if you combine it
with named constants defined with the CONST statement.
Example:
const porta = $1000 ' define address of port A
pokeb porta, a ' write low 8 bits in A to port A
The WAITWHILE and WAITUNTIL statements provide high-speed testing
loops, for use with 8-bit I/O ports. You can use these single
statements to replace larger, less efficient wait-loops built from the
PEEKB function.
The WAITWHILE statement loops while the contents of an 8-bit port,
ANDed with an 8-bit mask, yields a non-zero result. The WAITUNTIL
statement does the opposite; it loops UNTIL the contents of an 8-bit
value, ANDed with an 8-bit mask, yields a non-zero result.
Example:
waitwhile $1000, $40 ' wait while bit 6 of $1000 is high
This statement repeatedly reads the 8-bit value at address $1000 and
ANDs that value with $40, for so long as the result is not zero. When
the result equals zero, the loop terminates.
Example:
waituntil j, n ' wait until mask of value at j is not 0