GForce Programming
  Home     Greg's 68k Programming Reference     ticalc.org Author Profile     Detached Solutions     Really Old News  

Exception Vector Processing

ABOUT

The 68000 processor used by the TI-89 keeps a #1024 byte vector table beginning at $000000. This table contains pointers to routines used by the cpu, operating system, and the user. The vectors are refered to with an index from #0 through #255. This document describes some of these vectors as they relate to the AMS.

           

Exception Vector Assignment Table

Address Vector Function Vector # (Decimal)

Vector # (Hexadecimal)

$000 Reset Vector - Contains initial SSP & PC 0 $0
$008 Bus Error 2 $2
$00C Address Error 3 $3
$010 Illegal Instruction 4 $4
$014 Zero Divide 5 $5
$018 CHK Instruction 6 $6
$01C TRAPV Instruction 7 $7
$020 Privilege Violation 8 $8
$024 Trace 9 $9
$028 Line 1010 Emulator 10 $A
$02C Line 1111 Emulator 11 $B
$030 Unassigned: Reserved by Motorola 12-14 $C-$E
$03C Uninitialized Interrupt Vector 15 $F
$040 Unassigned: Reserved by Motorola 16-23 $10-$17
$060 Spurious Interrupt 24 $18
$064 Level 1 Interrupt Autovector 25 $19
$068 Level 2 Interrupt Autovector 26 $1A
$06C Level 3 Interrupt Autovector 27 $1B
$070 Level 4 Interrupt Autovector 28 $1C
$074 Level 5 Interrupt Autovector 29 $1D
$078 Level 6 Interrupt Autovector 30 $1E
$07C Level 7 Interrupt Autovector 31 $1F
$080 TRAP $0   (#0) 32 $20
$084 TRAP $1   (#1) 33 $21
$088 TRAP $2   (#2) 34 $22
$08C TRAP $3   (#3) 35 $23
$090 TRAP $4   (#4) 36 $24
$094 TRAP $5   (#5) 37 $25
$098 TRAP $6   (#6) 38 $26
$09C TRAP $7   (#7) 39 $27
$0A0 TRAP $8   (#8) 40 $28
$0A4 TRAP $9   (#9) 41 $29
$0A8 TRAP $A   (#10) 42 $2A
$0AC TRAP $B   (#11) 43 $2B
$0B0 TRAP $C   (#12) 44 $2C
$0B4 TRAP $D   (#13) 45 $2D
$0B8 TRAP $E   (#14) 46 $2E
$0BC TRAP $F   (#15) 47 $2F
$0C0 Unassigned: Reserved by Motorola 48-49 $30-$31
$0C8 AMS Jump Table Pointer 50 $32
$0CC Unassigned: Reserved by Motorola 51-63 $33-$3F
$100 User Interrupt Vectors 64-25 $40-$FF
$400 End of Exception Vector Table



VECTOR ASSIGNMENTS ON THE TI-89


Line 1010 ($A) Emulator

Triggered when an op code beginning with 1010 is encountered; the operating system uses this to throw errors. The general format is $Axxx where xxx is the error code. The error codes are the same as printed in the calculators manual. Some error codes are not documented.

Line 1111 ($F) Emulator

Triggered when an op code beginning with 1111 is encountered.

AMS < 2.04 Print Line 1111 Emulator and Freeze.

AMS =>2.04 Call routine in jump table format is $F800 + JumpTableIndex.
Example: ClrScr is $19E in the jump table. $F800 + $19E = $F99E. So dc.w $F99E (or .word 0xF99E 'as' style) would call ClrScr. When using this method, the call takes 2 bytes compared to 6 bytes and is much slower than the traditional methods.

Auto Interrupts 1-7

The interrupt level can be set with OSSetSR or Trap #1. Setting an interrupt mask above $500 will disable the calculator's ability to save state information if there is a power outage.
There are 8 levels of interrupts available on the TI-89:

Interrupt Mask Settings

Interrupt Mask Short Description Disabled Interrupts
$700 Disable All Interrupts

Auto Interrupts 1, 2, 3, 4, 5, 6

$600 Disable ON key & Below Auto Interrupts 1, 2, 3, 4, 5, 6
$500 Disable Timers & Below Auto Interrupts 1, 2, 3, 4, 5
$400 Disable Link & Below Auto Interrupts 1, 2, 3, 4
$300 Disable Slow Clock & Below Auto Interrupts 1, 2, 3
$200 Disable Keyboard & Below Auto Interrupts 1, 2
$100 Disable Key Scan Auto Interrupts 1
$000 Enable All Interrupts <NONE>

 

Auto Interrupt Descriptions

Interrupt Number

Description With Respect to the AMS

Auto Interrupt 1 Status Line: By default, it triggers about 395 times per second. Draws the status line.
Auto Interrupt 2 Keypress: Triggered when a key is pressed. A single keypress can generate multiple interrupts!
Auto Interrupt 3 Slow Clock: Not used by the AMS. Triggers exactly one time per second on HW2 calcs. On HW1 calcs, it triggers ~0.616322 times per second.
Auto Interrupt 4 Link:Triggered by the linking hardware for varoius reasons.
Auto Interrupt 5 Timers: Controls the 6 timers used by the TIOS (1-6 inclusive). This interrupt is triggered at 20 times per second if the programmable rate generator has not been altered. TIGCC hooks this interrupt to provide vector timers.
Auto Interrupt 6 ON KEY: Triggers when the ON KEY is pressed. A single keypress can generate multiple interrupts! It also seems to be triggered when battery power is low. That explains why doorsos breaks out of programs sometimes when STO is pressed.
Auto Interrupt 7 Protected Memory Violation: Triggers when a write is attempted at any address below $120 or any address from $E00000 - $FFFFFF. This is to prevent damage to the Exception Vector Table from a stack overflow for example. The user stack begins at $4BFF and grows backwards to $400, so most of the user vectors will be damaged before this interrupt triggers. To avoid this interrupt, you can add $40000 to the address that you want to write to. A second method is to clear bit #2 at $600001 to disable the interrupt; setting the bit enables the interrupt once again.

Notes: The following instructions may be of interest in this interrupt...
...
MOVE USP,A0        ;the address to the user stack is in a0
CMPA.L #$400,A0        ;compare with $400
BHI...    ;if higher, then 'Protected Memory Error' is thrown...
        ;else 'Memory Error' is Thrown

Auto Interrupt 7 cannot be disabled via the SR because it is not maskable. Instead, use port .........where did alh's page go =P

 

---to do--- clean this up... get rid of ugly table....

Trap Exception Table

Trap

Description

Input

Output

Notes

Trap #0     ($0) Execute various supervisor mode functions. D0 = function code

Known Functions:

0 sets the power state, switches flash to low power mode
1 Idle
2 Clear Break
3 Check Break
4 Reset
5
6 Error Lockup
Trap #1    ($1) Interrupt Mask D0.w = new interrupt mask D0.l = old SR OSSetSR uses this trap.
Trap #2    ($2) Reset none The calculator is reset. On ams 2.xx, the archive will be intact. Used by Trap #8, so redirect this trap to avoid a reset if you use it.
Trap #3    ($3) OSenqueue parameters on stack C style:
(short data, void* Queue)
D0.w = 1 on success 0 on failure
Assume that D1-D2/A0-A1 are destroyed
This will not work if you want to use OSenqueue becuase OSenqueue expects to be run in user mode. It peforms rts instead of rte at the end of the routine.
Trap #4    ($4) Turns the calculator off Calculator is off... waits for the ON key to be pressed or a link interrupt to turn back on.
Trap #5    ($5 Prints Trap 5 with black bar and hangs
Trap #6    ($6) Prints Trap 6 with black bar and hangs
Trap #7    ($7) Prints Trap 7 with black bar and hangs
Trap #8    ($8) Runs a block in supervisor mode. LE_WORD Size;BYTE Code[]; The code is called (passed a5 with the end address), trap #2 is then called (put on the stack as the return address)
Trap #9    ($9) Returns pointers to various system functions and tables D0.w = function id A0.l = pointer

Input Table

D0.w Pointer
0 OSContrastUp
1 WinOpen
2 OSLinkReset
3 TIMERV *OSTimerVectors;
4 BYTE *OSContrast;
(end of LCD_MEM)
5 WinStr
6 KEY_QUEUE *KeyBuffer;
7 OSqclear
8 CHARTYPE* CharTbl;
9 OSContrastUp
10 OSContrastDn
11 OSClearBreak
12 KEYCODE* KeyCodes;
13 OSCheckBreak
14 LCD_MEM
15 OSdequeue
16 RAMTest
17 WinMoveTo
Trap #10    ($A) Self Test
Trap #11    ($B) Handles all of the FLASH operations for the operating system. This trap needs to execute from the ram if writing is to be peformed. D3 = function number
D4 = size
A2 = addr1
A3 = addr2
 
D3 Function
0 write
1 erase
2 addcert
3 getcert
4 cgetvernum

If (flen) function is copied and executed in RAM.

Trap #12    ($C) Enter Supervisor Mode none d0.w contains previous SR upon return. RTE won't work to restore user mode because this trap pop's the sr off of the stack and then peforms rts which pops the return address off of the stack
Trap #13    ($D) Prints Trap 13 with black bar and hangs
Trap #14    ($E) Prints Trap 14 with black bar and hangs
Trap #15    ($F) Prints ER_throw with black bar and hangs.

Copyright © 2000 - by Greg D. All Rights Reserved.

External Links
Detached Solutions
Techno-Plaza ASM Lessons
TIGCC Cross Compiler
www.ticalc.org
www.calc.org


GForce Programming