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
0
votes
3 answers
Difference between a lookup table and a jump table
I know that jump tables are mainly used to create switch statements in assembly:
int a = 5;
switch (a){
case 5:
...
break;
...
}
In this case, jump is just a pointer to a memory address which has instructions to do case 5 work.
If i'm not…

Anthon
- 3
- 3
0
votes
1 answer
How to reference deeply nested function pointer array in C?
I have essentially this:
void **a;
typedef void (*ExampleFn)();
void
foo() {
puts("hello");
}
void
init() {
ExampleFn b[100] = {
foo
};
a = malloc(sizeof(void) * 10000);
a[0] = b;
}
int
main() {
init();
ExampleFn x =…

Lance
- 75,200
- 93
- 289
- 503
0
votes
1 answer
Difference between Control tables and Jump tables?
What's the difference between the two? To my understanding they both control program flow, and the first is more loosely defined than the latter, but I can't see what distinguishes the two other than that.

warmtea
- 107
- 9
0
votes
2 answers
Array of jump tables in C
I'm trying to optimize access to some jump tables I have made, they are as follows:
int (*const usart_ctrl_table[USART_READ_WRITE_CLEAR])() =
{zg_usartCtrlRead, zg_usartCtrlWrite, zg_usartCtrlClr};
int (*const…

BitShift
- 977
- 2
- 9
- 28
0
votes
1 answer
Short jump offset table usage
I am trying to use a table with short jump offsets:
mov $4, %eax
j1:
movzbl offset(%eax),%edx # load jump offset
jmp *(%edx)
r1:
...
offset:
.byte 0, 1, 2, 3, 4 # Example…

qwr
- 9,525
- 5
- 58
- 102
0
votes
2 answers
Faster way to read a keyword list
I'm writing a simple lexer for a general purpose programming language and one of the token types is a 'keyword' that has some predefined control flow tokens such as 'if', 'else', 'while', 'return'.
I want to know the fastest way to check if some…

h0m3
- 104
- 9
0
votes
0 answers
Passing arguments while using a function pointer
I'm trying to understand how to implement a two-dimension table of function pointers (to simplify a semi-complex switch/case/if construct).
The following worked - after some wrangling - as desired.
#include
void AmpEn(void)…

mike65535
- 483
- 2
- 10
- 21
0
votes
1 answer
high-speed case construct assembler + load DPTR fast - 8051
I'm currently implementing a serial routine for an 8051 IC (specifically AT89C4051) and I don't have much stack space or memory left, and in order for me to achieve a decent baud rate on the serial port (38K or better), I need to make a high speed…

Mike -- No longer here
- 2,064
- 1
- 15
- 37
0
votes
1 answer
function pointers in array (nix c++)
I'm getting a compiler error when I'm trying to initialize my array with function pointers. Without using a class I'm able to run the code fine, but when I incorporate the code in a class I'm getting the error. I suppose this is more of a problem…

Mr B
- 3
- 3
0
votes
0 answers
Export C/C++ switch/case jump table information
In C/C++ on x86-64, if a switch/case statement is relatively large (more than 3 or 4 entries), a jump table would be generated by LLVM, instead of conditional jump instructions.
In Clang/LLVM, how to export these tables' base, index, and scale…

WindChaser
- 960
- 1
- 10
- 30
0
votes
3 answers
Fastest way to call a javascript function (or method) via a lookup table of function names?
I am simulating an 8-bit microprocessor with JavaScript. I have stored each opcode function name in an array, and call each of the 256 functions relative to the opcode read from my virtual memory, as follows:
this.OP[opcode] =…

rjcostello
- 1
- 4
0
votes
1 answer
Jump/Branch Table in C Programming
Kindly Help Me With The following piece of code
//jmp_common.h
typedef void (*jmp_Handler_t)(void);
#define JMP_CMD_HANDLER(com) extern void Jmp_Handler_##com(void)
#define JMP_DEF_COM(com) extern void Jmp_Handler_##com(void);
#include…

theadnangondal
- 1,546
- 3
- 14
- 28
0
votes
1 answer
Format of a jump table
I am reading an example on a course about jump tables. They call gdb x/8g 0x123456
The resulting output looks like:
0x123456 0x000000000000134234 0x0000000000005f424
0x123487 0x0000000000001dd1ac 0x000000000000ef327
I thought a jump…

teaLeef
- 1,879
- 2
- 16
- 26
0
votes
1 answer
How to deal with jump table embedded in the .text section in nasm?
Basically I use IDA Pro to disassemble some binaries from SPEC2006, and do some modification work to make it nasm-reassmeble on Windows 7 32bit.
I find one problem in the disassembled asm code generated from IDA Pro like this:
;this is…

lllllllllllll
- 8,519
- 9
- 45
- 80
-1
votes
1 answer
How can I use a jump table with the JMP instruction?
This is my code (I know this wrong):
org 100h
sert dw 1
mov si, 1
shl si, 1
lea ax,[si]
jmp ax
1:
PRINTN "Number 1"
jmp end
2:
PRINTN "Number 2"
jmp end
3:
PRINTN "Number 3"
jmp end
4:
PRINTN "Number 4"
jmp end
end:
mov ah, 0
int…