Apple II Technical Notes _____________________________________________________________________________ Developer Technical Support Apple IIGS #18: Do-It-Yourself SCC Interrupts Revised by: Mike Askins, Matt Deatherage & Jim Mensch November 1988 Written by: Mike Askins June 1987 This Technical Note describes how to get the IIGS to pass control to you for SCC interrupt handling when you are not using the serial firmware. _____________________________________________________________________________ The Apple IIGS serial firmware is a robust environment for almost every serial programming application; however, there may be times when you must go around the firmware to handle things yourself (despite popular belief, these times are the exception rather than the rule). If you want to handle SCC interrupts on the IIGS without using the serial firmware, there are two procedures you may follow. The first method calls your interrupt handling routine instead of the built-in serial firmware when an interrupt is generated. This routine is always the second one called when an interrupt occurs (AppleTalk is first) and should give your routine plenty of time to handle the interrupt. You must confirm that the serial port was the source of the interrupt. If so, perform your task, clear the carry bit and perform an RTL. If not, set the carry bit and perform an RTL. You enter your routine in full-native mode with an eight-bit accumulator and registers, and you must exit the same way. Your routine must also preserve the data bank register. Implementing this method is easy. To do so, simply use GetVector and SetVector in the Miscellaneous Tools to save the current vector (always a good idea so you can replace it when your interrupt handler is removed) and replace it with a vector to your routine. The reference number for the SCC interrupt vector is $0009. The second method calls your interrupt handler last. It simply tells one of the serial ports not to claim a generated interrupt. Control then passes through the entire interrupt handling chain to the user interrupt vector at $3FE and $3FF. The procedure for implementing this method follows: 1. Set your bank $00 handling address at the usual place in $3FE and $3FF. 2. Set a system interrupt flag byte, SerFlag. The ROM version determines the method of finding the address of SerFlag. In ROM 2.0 and later, you can get the address with a call to the Miscellaneous Tools GetAddr using a reference number of $000E. Although you should not need to write a special case for earlier ROM versions, you can do so if you wish; the address of SerFlag in ROM 1.0 is $E10104. Refer to the Apple II Miscellaneous Technical Note #7 for information on identifying Apple IIGS ROM versions. Once you have the correct address of SerFlag, preserve the byte's current value, then turn on the bits in the byte which reflect the port from which you will be handling interrupts. The bits for the different ports are as follows: Port 1: ORA #%00111000 Port 2: ORA #%00000111 When you are finished handling interrupts from the chosen port (i.e., when you terminate), you should restore the byte to its original value. Further Reference o Apple IIGS Toolbox Reference Manual, Volume 1 o Apple IIGS Firmware Reference Manual o Apple II Miscellaneous Technical Note #7, Apple II Family Identification