Re : A92: 111 Emulator error.


[Prev][Next][Index][Thread]

Re : A92: 111 Emulator error.



here is a file which is a part of a doc i will be releasing within a few
days...
I hope it will be usefull  to you !

Mathieu, <hm lacage@aol.com>

*****************************************************************************
*                            exception vectors table                        *
*****************************************************************************

The aim of this file is to describe the exception vectors table of which we
talked in the "newbies.txt" file. Then, to explain how different errors
generated by the processor are handled.

1) The table

A trap or exception routine is a program which is called by some internal
( software ) or external ( hardware ) routines.
To each trap, we associate a vector ( the adress to the program to be
executed ). On the 68000 processor, there are 255 vectors. These vectors are
longwords stored at the begening of the memory in the exception vector table.
This table begins at $000000 and is over at $0003FF

here is this table:
adresses   |  Vector   |   Description
( hex )    |  number   |
000000     |    0      |   initialisation vector ( special: 64 bits )
000008     |    2      |   Bus Error
00000C     |    3      |   Adress Error
000010     |    4      |   Illegal Instructions
000014     |    5      |   Division by zero
000018     |    6      |   "Chk" instruction
00001C     |    7      |   "Trapv" instruction
000020     |    8      |   Privilege violation
000024     |    9      |   Trace
000028     |   10      |   Line 1010 emulator
00002C     |   11      |   Line 1111 emulator
000030/    |   12/     |   Reserved or
000060     |   24      |   useless
000064     |   25      |   Auto-Interrupt level 1
000068     |   26      |   Auto-interrupt level 2
00006C     |   27      |   Auto-interrupt level 3
000070     |   28      |   Auto-interrupt level 4
000074     |   29      |   Auto-interrupt level 5
000078     |   30      |   Auto-interrupt level 6
00007C     |   31      |   Auto-interrupt level 7
000080/    |   32      |   Trap instruction 
0000BF     |   47      |   vectors
           |  48/63    |   Reserved
000100     |  64/255   |   User interrupt vectors


2 ) Internal exceptions

a ) "normal traps"

  *  Division by Zero: this trap is called when the divisor of a DIVU or DIVS
  instruction is equal to zero. The programmer may freely redirect this trap
  to a self made one to , for exemple, recalculate the divisor or to
  exit from the program.
  *  "CHK": The instruction "Chk" allows usto test if an operand is into a
  certain interval. If not, the Chk trap is called: the programmer may well
  redirect  this trap to his own use.
  *  TrapV: if the V flag is set during the execution  of this instruction,
  the trap  is called: again, the programmer may redirect this trap.
  *  Trap: this instruction allows us to redirect our program to one of the
  32/47 vector: you need just to type: " Trap <number_of_vector> "

b ) Programmation errors

  * Adress Error: this happens, for exemple, when you write or read a word
  at an odd adress.
  * Privilege violation: this happens when, in the user mode, a program
  tries to execute a supervisor mode instruction.
  supervisor inst are:
  Stop
  Reset
  Rte
  Move.w source,SR
  and.w  #data,SR
  Eor.w  #data,SR
  Or.w   #data,SR
  move.l An,USP
  move.l USP,An
  You don' t need to bother about these instructions ( i have put all this
  here just for documentation purposes ) : priviliege violation traps occur
  when you haven' t set the S bit of the system byte and yo are trying to do
  meddle so stuff in memory: it doesn' t happen often in game programmers...
  * Illegal istructions: an instruction is invalid if the processor doesn' t
  recognize the instruction... As we are using a compiler which code the
  instructions, there are only two reasons to such a phenomenon:
   * you have branched to a label which wasn' t a label with instructions (
   for exemple, a label to a table or some data you use... ) : thus, the
   processor is trying to execute ... well... nothing at all... at best, you
   get an illegal instuction ( at best cause this could lead to destrying
   memory, or other such things)
   * the processor executed one of the folowing code: $4AFA, $4AFB or 4AFC
   the first 2 ones are reserved and the last one may be used to force an
   illegal instruction ( in fact, it is what we do when we write " illegal"
   to make a breakpoint: see newbies.txt, end of the file )
  * line 1111 emulator or line 1010 emulator: these happen when $4AFA or
  $4AFB is executed: as sooner, it often happens when you are trying to
  execute random data...
  * Trace: when the T bit of the status register, after each instruction,
  the trace vector is launched.

3 ) the system byte of the status register

the system byte is: |T|0|S|0|0|I2|I1|I0|

*  The T ( trace ) bit is set by the Raven debugger: it allows to "trace" a
program: when set, after eache instruction, it launches the trace vector
( it launches the program which the trace vector points to )
*  The S ( system ) bit : when set, it allows to modify freely the system byte
and to have access to the supervisor resources.
*  I2,I1 and I0 are the bits of the interupt mask.

4 ) The interrupt mask

the 3 bits of the status register are used to set the interrupt mask: in fact,
it means that they are set to an interupt level: if a trap is generated whose
level is higher than the interrupt mask, then the trap is executed. Otherwise
it is ignored.
Here is how these bits are set:
          I2 | I1 | I0 |
level 0 |  0    0    0 |  ---------> lowest priority
level 1 |  0    0    1 |
level 2 |  0    1    0 |
level 3 |  0    1    1 |
level 4 |  1    0    0 |
level 5 |  1    0    1 |
level 6 |  1    1    0 |
level 7 |  1    1    1 |  ---------> highest priority

*****************************************************************************
*                     vectors.txt  ver 1.0, 10 august 1997                  *
*****************************************************************************
thanks:

    * david ellsworth for the great FARGO !!!!!!!!!!! ( why fargo, david ? )
    * all those who helped me to learn asm...
    * special thanks to bryanr2 on IRC for his modesty and his beeing polite

If u want to reach me, email at : 

mathieu: <hm lacage@aol.com>

on ex-list fargo: A92 ( available at calc-ti.org

on IRC: on #calc-ti, my nick is fly_craze and i am there usually between 22h
and 23 h 30 ( paris time ) .

my adress:
Mr LACAGE Mathieu
2 Rue de la Lavande
34430, Saint Jean de Vedas
FRANCE