First page Back Continue Last page Overview Text

Notes:


Subroutines will be discussed in more detail later, but are presented here so that you can use them in your programs. The following example code fragment shows a call to a subroutine that adds 2 to the value in accumulator A. The RTS statement in the subroutine returns to the STAA PORTS statement. The stack pointer needs to be loaded (only once) using an LDS #$c00 statement. The stack pointer must be loaded prior to the subroutine call.

JSR Add2ToA
STAA PORTS

Add2ToA: ADDA #2
RTS