CODE Resource ID=0: Jump Table Implementation


CODE resource ID=0 in an application is used to implement a jump table for
routines that are called from one code segment but reside in another code
segment of the application. The first 8 bytes of CODE 0 include such
information as the jump table length, the offset from register A5, and so
on.

Beginning at the ninth word (usually referred to as "word 8", because
numbering starts at 0) are the actual jump table entries for each of the
routines that are called from outside their segments. Each entry is four
words long. The first word is the offset in hex of the routine being
called. This offset is from the beginning of the segment to which the
routine belongs.

The next three words are the instructions that will be executed; they have
the format:

MOVE.W #$0001,-(A7)
_LoadSeg

The #$0001 word identifies the segment that is to be loaded and contains
the routine. In the example above, code segment 1 contains the routine. In
hex, a sample jump table entry is:

WORD 1 2 3 4
298C 3F3C 0001 A9F0

1) The offset
2) MOVE.W
3) The code segment
4) _LoadSeg


Published Date: Feb 18, 2012