#Bruce Dawson Review
04-Jan-89 20:28:53
Sb: #28744-#Bruce Dawson Review
Fm: Richard Rae/SYSOP 76703,4253
To: microsmiths 76004,1766
Aha. Well that's the problem then; you're doing it wrong. 8) I will point out
that even if the assembler DIDN'T hink with your branches you'd have the same
problem. If one of your branches was OOR you'd have to change it to a long
yourself, and then you can't use a calculated offset into the table, because
the entries are of different sizes (unless you make them ALL longs). Blech. No,
make that double blech.
Much better is the approach I suggested in the previous message: the one I
THOUGHT you were using. Never, EVER build a table of branches, that's simply
asking for trouble (as you have pointed out). Instead, build a table of
ADDRESSES. Index into the table (which will always remain orthogonal), pick up
the address, then do an indirect jump, branch, or call as needed. Using your
example it would be something like:
LSL #2,D0 ASSUMES D0 CONTAINS BASE ZERO ORDINAL OF VECTOR
LEA MYLAB,A0 LOAD BASE OF VECTOR TABLE INTO A0
MOVEA.L 0(A0,D0.W),A0 PICK UP ADDRESS OF ROUTINE TO USE
JMP (A0) JUMP INDIRECT OFF OF A0
MYLAB:
DC.L FUNC1,FUNC2,FUNC3,…FUNCN
There are a zillion ways to code it, of course… this one is intended for
clarity.
<continued>