68000 - Help with 68k assembly - jump tables? -


i'm working on reverse engineering large amiga program in ida, , i've made ton of progress. however, there stuff can't quite figure out. namely, have found several subroutines use believe "jump tables" - can't quite figure out how work. have advice?

        moveq   #0,d0         move.b  d7,d0       ; set d0 byte ctrl         subq.w  #1,d0       ; subtract 1         blt.w   finish_29aba    ; if d0 less 1, branch         cmpi.w  #$16,d0         bge.w   finish_29aba    ; if d0 greater or equal 16, branch         add.w   d0,d0       ; otherwise, double d0         move.w  dword_29918(pc,d0.w),d0         jmp dword_29918+2(pc,d0.w) ; --------------------------------------------------------------------------- dword_29918:    dc.l $400036        ; code xref: serialctrlcmd+e0j         dc.l $360036         dc.l $3601a0         dc.l $3601a0         dc.l $1a001a0         dc.l $360040         dc.l $2a01a0         dc.l $400036         dc.l $3601a0         dc.l $1a00036         dc.l $1a00036         dc.l $33fc0003         dc.l heap_3b897+$41a7   ; ctrlread3 ; ---------------------------------------------------------------------------         bra.w   finish_29aba ; ---------------------------------------------------------------------------         tst.w   (ctrl_36494).l         bne.w   return_29af6         moveq   #1,d0         lea ((heap_3b897+$2665)).l,a0         adda.w  (ctrlread1).l,a0         move.b  d7,(a0)         moveq   #0,d1         move.b  d7,d1         move.w  d1,(ctrlread2).l         move.w  (ctrlcmds).l,d1         addq.w  #1,d1         move.w  d1,(ctrlcmds).l ; increment ctrl cmds 1         move.w  d0,(ctrlread3).l         bra.w   finish_29aba 

    blt.w   finish_29aba    ; \     cmpi.w  #$16,d0         ; > these insns check index in range     bge.w   finish_29aba    ; /      add.w   d0,d0           ; since jump table contains words,                             ; multiply index 2, word index      move.w  dword_29918(pc,d0.w),d0 ; word jump table, indexed d0      jmp dword_29918+2(pc,d0.w)      ; perform indirect jump (pc,d0)      dword_29918:            ; following offsets encoded words       ; 0040 0036 0036 0036... 

this result of c switch statement.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -