[Prev] [Next] [Contents] [Commodore] [New] [Search] [Home]

PEEK

TYPE: Integer Function
FORMAT: PEEK(<numeric>)

Action: Returns an integer in the range of 0 to 255, which is read from a memory location. The <numeric> expression is a memory location which must be in the range of 0 to 65535. If it isn't then the BASIC error message ?ILLEGAL QUANTITY occurs.

EXAMPLES of PEEK Function:
   10 PRINT PEEK(53280) AND 15   (Returns value of screen border color)

   5 A%=PEEK(45)+PEEK(46)*256    (Returns address of BASIC variable table)

POKE

TYPE: Statement
FORMAT: POKE <location>,<value>

Action: The POKE statement is used to write a one-byte (8-bits) binary value into a given memory location or input/output register. The <location> is an arithmetic expression which must equal a value in the range of 0 to 65535. The <value> is an expression which can be reduced to an integer value of 0 to 255. If either value is out of its respective range, the BASIC error message ?ILLEGAL QUANTITY occurs.

The POKE statement and PEEK statement (which is a built-in function that looks at a memory location) are useful for data storage, controlling graphics displays or sound generation, loading assembly language sub- routines, and passing arguments and results to and from assembly language subroutines. In addition, Operating System parameters can be examined using PEEK statements or changed and manipulated using POKE statements. A complete memory map of useful locations is given in Appendix G.


[Prev] [Next] [Contents] [Commodore] [New] [Search] [Home]
This page has been created by Sami Rautiainen.
Read the small print. Last updated November 14, 1998.