POKE

From C64-Wiki
Jump to navigationJump to search
BASIC keyword
Keyword: POKE
Abbreviation: P Shift+O
Type: Command
Token code: 151/$97
Handling routine
in BASIC ROM:
47140–47148
$B824–B82C
List of all BASIC keywords


Remark: This article describes the BASIC command POKE in BASIC V2 at the Commodore 64.

Typ: Command
General Programming-Syntax: POKE <Memory address>,<number>

The BASIC command POKE changes the content of any address in the memory address, ranging from 0 to 65535, to the given byte value in the range 0 through 255. If either number is outside these limits, the 64 will display the error message ?ILLEGAL QUANTITY  ERROR IN line.

Caution: A misplaced POKE may cause the C-64 to lock up, or garble or delete the program currently in memory. To restore a locked-up C-64 without a reset button fitted, one has to momentarily turn off the power, thereby losing any program or data in RAM!

Examples

POKE 53280,1 The screen frame color will be changed into white
F1=53281: W=1: POKE F1,W The background color will be changed into white over variables
POKE 53281, PEEK (53280) The background color is set to the same color as the screenframe color
POKE 788,52 Deactivate <RUN/STOP> and also halts TI$
POKE 808,225 Deactivated the key combination <RUN/STOP>+<RESTORE> and makes TI$ unusable
POKE 775,119 LIST-Command will be blocked

ROM details

POKE is handled in BASIC ROM at 47140–47148/$B824–B82C: It uses another subroutine, GETPAR, to read the two parameters of the POKE command as a 16-bit unsigned integer and a byte, respectively. The 16-bit address comes out in a zeropage pointer, and so the short POKE handling routine (a mere 9 bytes long) simply sets the Y index register to zero and uses an indirect indexed STA to store the given byte in the designated address.

If POKE given a parameter to the BASIC ROM region, the write will instead be redirected to the underlying RAM. This may be used to copy the ROM into RAM in order to a user's own version.

Also see the BASIC-Command PEEK.

BASIC V2.0 (second release) Commands

ABS | AND | ASC | ATN | CHR$ | CLOSE | CLR | CMD | CONT | COS | DATA | DEF | DIM | END | EXP | FN | FOR | FRE | GET | GET# | GOSUB | GOTO | IF | INPUT | INPUT# | INT | LEFT$ | LEN | LET | LIST | LOAD | LOG | MID$ | NEW | NEXT | NOT | ON | OPEN | OR | PEEK | π | POKE | POS | PRINT | PRINT# | READ | REM | RESTORE | RETURN | RIGHT$ | RND | RUN | SAVE | SGN | SIN | SPC | SQR | STATUS/ST | STEP | STOP | STR$ | SYS | TAB | TAN | THEN | TIME/TI | TIME$/TI$ | TO | USR | VAL | VERIFY | WAIT