2. Exceptions

As mentioned in the instruction summary in past articles, the QL processor runs in two modes - user and supervisor - and some instructions cannot be run in user mode without causing an exception to be generated. I promised to explain what these exceptions are, so here goes ....

An exception is an event or happening that causes the processor to deviate from its normal course of action and to jump to a predetermined place in the operating system where it starts executing a piece of code that handles such events. In QDOS (the QL's operating system) many of these routines have been 'botched' in an effort to save on memory and others simply do nothing. This is unfortunate, however, all is not lost.

All 68000 series processors have an area of memory set aside to hold the exception table. This table is 1024 bytes long and holds a full set of exception vectors - basically a long word holding the address of the sub-routine that handles the appropriate exception. In QDOS this table is only partially there as will become clear. There are 256 vectors normally, each one being 4 bytes long. Vector zero is at address zero in the memory map and vector 255 is at address $3FC.

The vector table should look like the following :

Table 6.1. MC6800x Exception Table

VectorAddressPurpose
0000000Reset - SSP value
0010004Reset - USP value
0020008Bus Error
003000CAddress Error
0040010ILLEGAL Instruction
0050014Divide by zero
0060018CHK instruction
007001CTRAPV instruction
0080020Privilege violation
0090024Trace
0100028Line 1010 emulator
011002CLine 1111 emulator
0120030Reserved for Motorola
0130034Reserved for Motorola
0140038Reserved for Motorola
015003CUninitialised Interrupt
0160040Reserved for Motorola
.........
0240060Spurious interrupt
0250064Interrupt level 1
0260068Interrupt level 2
027006CInterrupt level 3
0280070Interrupt level 4
0290074Interrupt level 5
0300078Interrupt level 6
031007CInterrupt level 7
0320080TRAP #0
0330084TRAP #1
0340088TRAP #2
035008CTRAP #3
0360090TRAP #4
0370094TRAP #5
0380098TRAP #6
039009CTRAP #7
04000A0TRAP #8
04100A4TRAP #9
04200A8TRAP #10
04300ACTRAP #11
04400B0TRAP #12
04500B4TRAP #13
04600B8TRAP #14
04700BCTRAP #15
04800C0Reserved for Motorola
.........
0640100User vector 1
.........
25503FFUser vector 192

It can be seen that a huge number of the vectors are reserved for Motorola to use in future processors. The User vectors look interesting, but have been obliterated by some of the code in QDOS and cannot be used.

On the QL, the vectors are as follows :

Table 6.2. QDOS Exception Table

VectorAddressPurpose
0000000Reset - SSP value
0010004Reset - USP value
0020008Bus Error - IGNORED
003000CAddress Error - MAY BE REDEFINED
0040010ILLEGAL Instruction - MAY BE REDEFINED
0050014Divide by zero - MAY BE REDEFINED
0060018CHK instruction - MAY BE REDEFINED
007001CTRAPV instruction - MAY BE REDEFINED
0080020Privilege violation - MAY BE REDEFINED
0090024Trace - MAY BE REDEFINED
0100028Line 1010 emulator - UNUSABLE
011002CLine 1111 emulator - UNUSABLE
0120030Reserved for Motorola - UNUSABLE
0130034Reserved for Motorola - UNUSABLE
0140038Reserved for Motorola - UNUSABLE
015003CUninitialised Interrupt - UNUSABLE
0160040Reserved for Motorola - UNUSABLE
.........
0240060Spurious interrupt - IGNORED
0250064Interrupt level 1 - IGNORED
0260068Interrupt level 2 - QL System interrupt
027006CInterrupt level 3 - IGNORED
0280070Interrupt level 4 - IGNORED
0290074Interrupt level 5 - IGNORED
0300078Interrupt level 6 - IGNORED
031007CInterrupt level 7 - HANGS THE QL - MAY BE REDEFINED
0320080TRAP #0 - Make a call to QDOS
0330084TRAP #1 - Make a call to QDOS
0340088TRAP #2 - Make a call to QDOS
035008CTRAP #3 - Make a call to QDOS
0360090TRAP #4 - Make a call to QDOS
0370094TRAP #5 - IGNORED - MAY BE REDEFINED
0380098TRAP #6 - IGNORED - MAY BE REDEFINED
039009CTRAP #7 - IGNORED - MAY BE REDEFINED
04000A0TRAP #8 - IGNORED - MAY BE REDEFINED
04100A4TRAP #9 - IGNORED - MAY BE REDEFINED
04200A8TRAP #10 - IGNORED - MAY BE REDEFINED
04300ACTRAP #11 - IGNORED - MAY BE REDEFINED
04400B0TRAP #12 - IGNORED - MAY BE REDEFINED
04500B4TRAP #13 - IGNORED - MAY BE REDEFINED
04600B8TRAP #14 - IGNORED - MAY BE REDEFINED
04700BCTRAP #15 - IGNORED - MAY BE REDEFINED
04800C0Reserved for Motorola - UNUSABLE
.........
0640100User vector 1 - UNUSABLE
.........
25503FFUser vector 192 - UNUSABLE

Note

All vectors marked 'UNUSABLE' have been botched in the ROM and have bits of code in place of the vectors. So you can see not much is left. The designers of QDOS didn't have enough room in the early ROMs to fit all the code in - some QLs even came with a 'dongle' hanging out of the external ROM slot so that they could fit all the code in. Later versions got rid of the dongle, but the vector table had been 'redesigned' to make the code fit. Luckily they did allow a number of the exceptions to be redefined so that programmers could write their own routines to handle these exceptions.