C-64 Programmer's reference guide

Page 223

C64PRG10 STA USER+10 LDA #>MYINP STA USER+11 LDX #<USER LDY #>USER CLC JSR VECTOR ... USER *=*+26

;ALTER SYSTEM

ERROR CODES The following is a list of error messages which can occur when using the KERNAL routines. If an error occurs during a KERNAL routine , the carry bit of the accumulator is set, and the number of the error message is returned in the accumulator. +-----------------------------------------------------------------------+ | NOTE: Some KERNAL I/O routines do not use these codes for error | | messages. Instead, errors are identified using the KERNAL READST | | routine. | +-----------------------------------------------------------------------+ +-------+---------------------------------------------------------------+ | NUMBER| MEANING | +-------+---------------------------------------------------------------+ | 0 | Routine terminated by the <STOP> key | | 1 | Too many open files | | 2 | File already open | | 3 | File not open | | 4 | File not found | | 5 | Device not present | | 6 | File is not an input file | | 7 | File is not an output file | | 8 | File name is missing | | 9 | Illegal device number | | 240 | Top-of-memory change RS-232 buffer allocation/deallocation | +-------+---------------------------------------------------------------+ 306 BASIC TO MACHINE LANGUAGE ~ USING MACHINE LANGUAGE FROM BASIC There are several methods of using BASIC and machine language on the Commodore 64, including special statements as part of CBM BASIC as well as key locations in the machine. There are five main ways to use machine language routines from BASIC on the Commodore 64. They are: 1) 2) 3) 4) 5)

The BASIC SYS statement The BASIC USR function Changing one of the RAM I/O vectors Changing one of the RAM interrupt vectors Changing the CHRGET routine

1) The BASIC statement SYS X causes a JUMP to a machine language subroutine located at address X. The routine must end with an RTS (ReTurn from Subroutine) instruction. This will transfer control back to BASIC. Parameters are generally passed between the machine language routine and the BASIC program using the BASIC PEEK and POKE statements, and their machine language equivalents. The SYS command is the most useful method of combining BASIC with machine language. PEEKs and POKEs make multiple parameter passing easy. There can be many SYS statements in a program, each to a different (or even the same) machine language routine. 2) The BASIC function USR(X) transfers control to the machine language Pagina 223


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.