A jump table (also known as a branch table) is used to transfer program control (branching) to another part of the program by storing a table of branch instructions.
Questions tagged [jump-table]
63 questions
3
votes
0 answers
A safe way to build jump tables on ARM (range checks on constants)
On ARM in thumb mode, it is possible to build a "jump table" (jump to the n-th pointer) as follows:
tbb [pc, r1]
.byte (foofoo1-.Ltable)/2
.byte (foofoo2-.Ltable)/2
This only works if each of the (foofoo1-.Ltable)/2 expressions fits…

David Monniaux
- 1,948
- 12
- 23
3
votes
2 answers
creating constant jump table; xcode; clang; asm
I have quite strange issue when try to create the jump table in my asm program for iphone (arm64):
.globl my_func
my_func:
...
//jump (switch) table
.L.f_switch:
.short .L.case0 - .L.f_switch
.short .L.case1 - .L.f_switch
…

user3124812
- 1,861
- 3
- 18
- 39
3
votes
4 answers
Function array in Java?
Maybe I think to much in C, but I don't see a solution how to solve this properly in java.
I get a response from my server which sends a string like this:
command params
The client receives that string and extracts the command. Now I would…

Devolus
- 21,661
- 13
- 66
- 113
2
votes
0 answers
Precheck ascii 0-9 using an if-statement before switch for performance
I have two functions which both check if an input char is a number (along other characters), but they do it in different ways:
foo_precheck(char c) first checks if the ascii code of char is in a certain range which denotes a number.
foo_switch(char…

glades
- 3,778
- 1
- 12
- 34
2
votes
0 answers
Store ,,procedures" in a table in NASM
Suppose I have a table in .rodata which would store procedure offsets, so I can use:
call [table + index]
in order to call the procedure defined in my code. Is it possible to achieve in PIC? How can I find these offsets and create such a table?

Funny
- 193
- 8
2
votes
1 answer
Interpreting an assembly jump table
I am trying to interpret line-by-line what is this assembly code doing but I found myself really confused when presented with this jump table which is in assembly.This is taken from the textbook exercise question 3.63 but there is no explanation on…

Megan Darcy
- 530
- 5
- 15
2
votes
2 answers
GCC Jump Table initialization code generating movsxd and add?
When I compile a switch statement with optimization in GCC, it sets up a jump table like this,
(fcn) sym.foo 148
sym.foo (unsigned int arg1);
; arg unsigned int arg1 @ rdi
0x000006e0 83ff06 cmp edi, 6 ;…

Evan Carroll
- 78,363
- 46
- 261
- 468
2
votes
3 answers
Using x86 style jump table in C
I am trying to do a jump table in C like this
cmp eax, dword 3 ;max number
ja invalid ;default
jmp [eax*4+jumptable] ;jump to handler
invalid:
retn
jumptable:
dd…

Warren Stevens
- 29
- 5
2
votes
1 answer
Switch case's jump table position within code on ARM
In C/C++ a switch statement can be lowered by the compiler to a jump table. I noticed a difference of placement of the jump table between ARM and x86.
x86
For x86 (And x86_64) the jump table is often placed outside of the function (e.g. .rodata)
…

cojocar
- 1,782
- 2
- 18
- 22
2
votes
3 answers
Avoid a repeating and simple switch case in C/C++?
I found a piece of code on the internet that has a really simple objective, yet it uses an ugly approach. Supposedly, the author is using a switch case to determine if a few (non-contiguous) values of a previously-defined Enum belong in their scope.…
user4103007
2
votes
1 answer
Function Pointer or Jump table
Before asking the question let me please provide some background:
I was reading through a technical article regarding Autosar architecture which suggested a Plug and Play approach for Application layer software components. Basically the article…

sompat
- 31
- 6
1
vote
1 answer
jmp with ds and [ ] in Assembly
Hello I would like to understand this code below, If u can explain to me I would be grateful:
jmp ds:off_100011A4[edi*4]
Why the use of this "ds" and this off_100011A4? and what means this code below:
off_100011A4 dd offset loc_10001125
dd…

Melo
- 13
- 3
1
vote
2 answers
Binary Bomb Phase 3 -- Confused about using jump table
I am trying to figure out the correct input to defuse the bomb at phase 3 of the binary bomb lab. I have figured out that the input must be two integers, and that the first integer must be less than 7. I have been using an arbitrary first value (1)…

Sam
- 11
- 1
- 2
1
vote
2 answers
Can I create a Jump table in VBA for Excel?
I wrote a simple translator / parser to process an EDI (830) document using multiple Select Case statements to determine the code to be executed. I’m opening a file in binary mode and splitting the document into individual lines, then each line is…

Versalytics
- 23
- 6
1
vote
3 answers
Is a jump table/branch the same thing as dereferencing a function pointer?
I've been trying to learn what exactly jump tables are, and I'm having trouble understanding something. From the many examples I've seen they seem to pretty much boil down to this, or at least this is one version of it:
void func1() {};
void func2()…

Zebrafish
- 11,682
- 3
- 43
- 119