PEEK and POKE |
: This article is about the BASIC statements. For other meanings of these words, see peek and poke.
In Computing, PEEK is a BASIC programming language function used for reading the contents of a memory cell at a specified memory address. The corresponding command to set the contents of a memory cell is POKE.
=Statement syntax=
The PEEK function and POKE command are usually invoked as follows, either in direct mode (entered and executed at the BASIC command prompt) or in indirect mode (as part of a computer program):
integer_variable = PEEK( address ) POKE address , value
Note that address and value may stand for arbitrarily complex expression (programming)s*, as long as the evaluation of those expressions end up as valid memory addresses or values, respectively. A valid address in this context is an address within the computer s total address space or the central processing units addressing range, whichever is the smallest, while a valid value is (typically) an unsigned value between zero and the maximum unsigned number that the minimum addressable unit (memory cell) may hold.†
Example: A typical early 1980s home computer could have 32 kilobyte main memory and an 8-bit microprocessor CPU with a 16-bit address range, leading to the following restrictions on PEEK and POKE parameter values:
0|
|