PEEK and POKE

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

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 gets the byte located at the specified memory address.[1] POKE sets the memory byte at the specified address.[2] These commands originated with machine code monitors such as the DECsystem-10 monitor;[3] 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 are comparable in their roles to pointers in the C language and some other programming languages.

One of the earliest references to these commands in BASIC, if not the earliest, is in Altair BASIC.[4] 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. Alternatively programmers might use these commands to copy software or even to circumvent the intent of a particular piece of software (e.g. manipulate a game program to allow the user to cheat). Today it is unusual to control computer memory at such a low level using a high-level language like BASIC. As such the notions of PEEK and POKE commands are generally seen as antiquated.

The terms peek and poke are sometimes used colloquially in computer programming to refer to memory access in general.

  1. ^ "PEEK". Microsoft QuickBasic 4.5 Advisor. Microsoft. 1990. Archived from the original on 2011-05-16. Retrieved 2007-12-28.
  2. ^ "POKE". Microsoft QuickBasic 4.5 Advisor. Microsoft. 1990. Archived from the original on 2011-05-16. Retrieved 2007-12-28.
  3. ^ "What is the oldest reference to PEEK, POKE, and USR?". Archived from the original on 14 August 2020. Retrieved 15 August 2020.
  4. ^ Altair 8800 BASIC Reference_Manual 1975, Page 68 of PDF