
ST BASIC for the Atari ST uses the traditional names but allows defining 8/16/32 bit memory segments and addresses that determine the size. The Sinclair QL has PEEK_W and POKE_W for 16-bit values and PEEK_L and POKE_L for 32-bit values. The East-German "Kleincomputer" KC85/1 and KC87 calls them DEEK and DOKE. BASIC XL for the Atari 8-bit family uses a "D" (for "double") prefix: DPEEK and DPOKE. Some BASICs, even on 8-bit machines, have commands for reading and writing 16-bit values from memory. Setting or reading a 16-bit value on such machines requires two commands, such as PEEK ( A ) + 256 * PEEK ( A + 1 ) to read a 16-bit integer at address A, and POKE A, V followed by POKE A + 1, V / 256 to store a 16-bit integer V at address A. > DIM S% 20 : REM reserve 20 bytes of memory pointed to by S% > $ S% = "MINCE PIES" : REM store string 'MINCE PIES', terminated by &0D > PRINT $( S% + 6 ) : REM retrieve string, excluding &0D terminator, and starting at S% + 6 bytes PI ES 16 and 32-bit versions Īs most early home computers used 8-bit processors, PEEK or POKE values are between 0 and 255. As an example of a POKE-driven support chip control scheme, the following POKE command is directed at a specific register of the Commodore 64's built-in VIC-II graphics chip, which will make the screen border turn black:
#C FILE PEEK SOFTWARE#
The address locations that are POKEd or PEEKed at may refer either to ordinary memory cells or to memory-mapped hardware registers of I/O units or support chips such as sound chips and video graphics chips, or even to memory-mapped registers of the CPU itself (which makes software implementations of powerful machine code monitors and debugging/simulation tools possible). A valid address in this context is an address within the computer's address space, 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. The address and value parameters may contain complex expressions, as long as the evaluated expressions correspond to valid memory addresses or values, respectively. Integer_variable = PEEK ( address ) POKE address, value The PEEK function and POKE commands are usually invoked as follows, either in direct mode (entered and executed at the BASIC prompt) or in indirect mode (as part of a program): The terms peek and poke are sometimes used colloquially in computer programming to refer to memory access in general. As such the notions of PEEK and POKE commands are generally seen as antiquated. Today it is unusual to control computer memory at such a low level using a high-level language like BASIC. manipulate a game program to allow the user to cheat). Alternatively programmers might use these commands to copy software or even to circumvent the intent of a particular piece of software (e.g. The PEEK and POKE commands were conceived in early personal computing systems to serve a variety of purposes, especially for modifying special memory-mapped hardware registers to control particular functions of the computer such as the input/output peripherals. One of the earliest references to these commands in BASIC, if not the earliest, is in Altair BASIC. These commands are comparable in their roles to pointers in the C language and some other programming languages. These commands are particularly associated with the BASIC programming language, though some other languages such as Pascal and COMAL also have these commands. These commands originated with machine code monitors such as the DECsystem-10 monitor

POKE sets the memory byte at the specified address. PEEK gets the byte located at the specified memory address. In computing, PEEK and POKE are commands used in some high-level programming languages for accessing the contents of a specific memory cell referenced by its memory address.


PEEK and POKE in line 100 of a Commodore Basic program on a CBM 3016
