Bruce Dawson Review
05-Jan-89 22:23:05
Sb: #28974-Bruce Dawson Review
Fm: Dean Brown 72250,2677
To: Richard Rae/SYSOP 76703,4253
Rick,
Here's how I handle it assuming all references fit into a single source
file.
The code fragment:
lsl.w #1,d0 ;multiply index by 2 for table offset
lea cmdtable(pc),a0 ;get address of table
move.w 0(a0,d0.w),d0 ;get routine offset
adda.w d0,a0 ;calculate routine address
jsr (a0) ;jsr to routine
The table: cmdtable:
dc.w (FUNC1 – cmdtable)
dc.w (FUNC2 – cmdtable)
…
The advantage of this is that there is no relocation data needed in the
load file, which makes the code directly ROMable and self-relocating. If you
for some reason need a long offset, the assembler will let you know by telling
you the value is too large to fit into the defined word. You can then fix it by
simply doing a S/R for a 'dc.w' and replace with a 'dc.l', and finally changing
the 'lsl.w #1,d0' to a 'lsl.w #2,d0'.
-Dean