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

3) Any of the input/output or BASIC internal routines accessed through the vector table located on page 3 (see ADDRESSING MODES, ZERO PAGE) can be replaced, or amended by user code. Each 2-byte vector consists of a low byte and a high byte address which is used by the operating system.

The KERNAL VECTOR routine is the most reliable way to change any of the vectors, but a single vector can be changed by POKES. A new vector will point to a user prepared routine which is meant to replace or augment the standard system routine. When the appropriate BASIC command is executed, the user routine will be executed. If after executing the user routine, it is necessary to execute the normal system routine, the user program must JMP (JuMP) to the address formerly contained in the vector. If not, the routine must end with a RTS to transfer control back to BASIC.

4) The HARDWARE INTERRUPT (IRQ) VECTOR can be changed. Every 1/60th of a second, the operating system transfers control to the routine specified by this vector. The KERNAL normally uses this for timing, keyboard scanning, etc. If this technique is used, you should always transfer control to the normal IRQ handling routine, unless the replacement routine is prepared to handle the CIA chip. (REMEMBER to end the routine with an RTI (ReTurn from Interrupt) if the CIA is handled by the routine).

This method is useful for tasks which must happen concurrently with a BASIC program, but has the drawback of being more difficult.

NOTE:ALWAYS DISABLE INTERRUPTS BEFORE CHANGING THIS VECTOR!
5) The CHRGET routine is used by BASIC to get each character/token. This makes it simple to add new BASIC commands. Naturally, each new command must be executed by a user written machine language subroutine. A common way to use this method is to specify a character (@ for example) which will occur before any of the new commands. The new CHRGET routine will search for the special character. If none is present, control is passed to the normal BASIC CHRGET routine. If the special character is present, the new command is interpreted and executed by your machine language program. This minimizes the extra execution time added by the need to search for additional commands. This technique is often called a wedge.

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