in Assembly, if i have a JUMP table with the address of over 2000 labels:
.TABLE:
DD .case0
DD .case1
DD .case2
DD .case3
DD .case4
...
...
...
DD .case2000
which way is better for addressing to jump:
way 1:
mov r12d, .TABLE ; r12d or any other registers
mov ebx, [r13d] ; r13d holds the id of case * 4 so we don't need to '4 * ebx'
add ebx, r12d ; ebx = address for Jumping
jmp ebx
way 2: (Same way 1 but 'add ebx, r12d'
is removed and changed to 'jmp [ebx+r12d]'
)
mov r12d, .TABLE ; r12d or any other registers
mov ebx, [r13d] ; r13d holds the id of case * 4 so we don't need to '4 * ebx'
jmp [ebx+r12d]
way 3:
mov ebx, [r13d] ; r13d holds the id of case * 4 so we don't need to '4 * ebx'
jmp [ebx + .TABLE]
in the 'way 1', we have source code size problem due to extra functions but i think it has better performance than other ways in jumping because im going to have about 2000 jumps (Irregular jump (May be from case0 to case1000 or ...)
So for jumping performance, which way is better in a source code that has a lot of JUMP ?