I've been learning Arm32 assembly on my Raspberry Pi recently and all is going well but I would like to create a jump table and have no idea how. The bl (branch and link) instruction needs an address label, but I would like to simulate a switch statement by creating a jump table of addresses that can be jumped to but I don't know how to do this. As I'm emulating an 8-bit computer with 256 possible opcodes I need to be able to define 256 opcode handlers and set up a jump table containing the address of these handlers so I can bl to them based on the opcode as an index. How may I accomplish this task?
Many thanks in advance!
Okay, I see how it's done almost 2/3 of the way through this web page : http://thinkingeek.com/2013/08/23/arm-assembler-raspberry-pi-chapter-16/
Is this correct? I'll try this out when I get home. It's frustratingly difficult to find an actual guide or doc on this.
Yup, the approach in the above link worked.
looks overly complicated
Pseudo code:
LD byte,[programcounter]
LD PC,[table+byte*8]
table:
long opcode0, opcode1, opcode2, opcode3
....
long opcode255
opcode0: