LIST

From C64-Wiki
Jump to navigationJump to search
BASIC keyword
Keyword: LIST
Abbreviation: L Shift+I
Type: Command
Token code: 155/$9B
Handling routine
in BASIC ROM:
42652–42774
$A69C–A716
List of all BASIC keywords


Remark: This article describes the BASIC command LIST in BASIC V2 of the Commodore 64.

Type: Command
General Programming-Syntax: LIST [[First Line]-[Last Line]]

The BASIC command LIST displays the BASIC program currently in memory: By default this listing is sent to the screen, but it can also be sent to e.g. a printer. Since program memory and the LISTing of its content is also used to retrieve and display the directory of a disk, LIST is also used to display such directories.

When LIST is used without any line numbers the entire program is listed. During listing of a long program, the user may cancel the listing immediately by pressing <RUN/STOP>, or slow down the scrolling speed (e.g. to allow reading) by holding down the <CTRL> key.

By default, LIST displays its output on the screen, but the BASIC-Command CMD may be used to re-direct the listing to a printer, a file on a disk drive, or other peripheral devices.

LIST is mainly used in direct mode, but may also be used as part of a BASIC program to make the program output a "dump" of itself during run-time. But due to the special internal handling of the LIST command inside the BASIC ROM, the program always terminates (as if there was an END command) after executing the LIST command, leaving the user with the "READY." prompt and cursor. This behavior changed with BASIC 3.5 and successive versions. Even though LIST may contain line numbers in its parameter list they won't be corrected if a program is renumbered using RENUMBER.

Examples[edit | edit source]

LIST 10     Only line 10 of this program is listed.
LIST -10    All lines until line 10 of this program are listed.
LIST 10-    All lines beginning with line 10 of this program are listed.
LIST 10-100 All lines beginning with line 10 and ending with line 100 are listed.

ROM details[edit | edit source]

LIST is handled by ROM at 42652–42817/$A69C–A741: The part of this routine that prints out characters and tokens from the BASIC program text, is vectored through address 774–775/$306–$307. Part of creating BASIC extensions involves re-directing this and other vectors to "new" routines to facilitate the extra BASIC keywords.

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