For efficiency I want to use a table of addresses that I can index by a register to jmp to within an assembler routine.
An example might make this clearer...
.CODE
...
AppendByte PROC
XOR RAX, RAX
MOV AL, CL ; Get this 0-7 index from somewhere else
JMP QWORD PTR[RAX + OFFSET APPENDBYTETABLE]
AppendByte ENDP
AppendByte_7:
; Do stuff...
RET
AppendByte_6:
; Do stuff...
RET
...
AppendByte_0:
RET
.DATA
APPENDBYTETABLE QWORD AppendByte_0, AppendByte_1, AppendByte_2,
AppendByte_3, AppendByte_4, AppendByte_5,
AppendByte_6, AppendByte_7
END
This compiles in VS2017 but I then get a linker error. I think this relates to using FAR addresses. How do I generate NEAR offsets and perform a SHORT jmp to offsets stored in a table in the DATA segment?
Note that if I put the AppendByte_x labels inside my proc then the compiler croaks.
RESOLVED! EDIT after advise from Fuz...
XOR RAX, RAX
MOV AL, REG_PREFIXCODEBITS
LEA RCX, APPENDBYTETABLE
JMP QWORD PTR [RCX + RAX * 8]