Device number

From C64-Wiki
(Redirected from device number)
Jump to: navigation, search

Device numbers are numbers that identify various peripheral devices connected to (or, in some cases, built into) the C64: The device number is used when creating logical files through the KERNAL file system; see OPEN (BASIC command) and OPEN (KERNAL routine).

The first four device numbers relate to various hardware that requires the CPU, memory and other resources of the core C64:

Device numbers above 3 all refer to devices connected through the serial port. They are all handled in exactly the same way from KERNAL's point of view, but by convention:

Often the default device number of printers, plotters and disk drives can be changed via dip-switches.

Example Code[edit]

The following code can be used to change, temporarily, the device number of Commodore disk drives (such as 1541 or 1571) to a number between 8 and 30:

OPEN 15,8,15:PRINT#15,"M-W";CHR$(119);CHR$(0);CHR$(2);CHR$(device number+32)+
CHR$(device number+64):CLOSE 15