Questions tagged [jump-table]

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.

63 questions
1
vote
3 answers

Is it faster in C to use a written jump table or switch statement?

So, I am trying to see if there is any difference between using a jump table of function pointers versus a switch statements for performing many, one command operations like these. This is the code to assembly link i made Here is my actual code as…
Josh Weinstein
  • 2,788
  • 2
  • 21
  • 38
1
vote
1 answer

GAS x86: Reading a jump table / interpreting a switch statement

I'm trying to reverse engineer some assembly, and I've gotten to this point: 40073f: 89 45 fc mov %eax,-0x4(%rbp) 400742: 83 7d fc 05 cmpl $0x5,-0x4(%rbp) 400746: 77 37 ja 40077f…
1
vote
1 answer

Assembly Code and Switch Statement Cases

I'm having a bit of trouble understanding how the cases 50, 52, etc were determined through the assembly language. From what I understand, the jump table corresponds to the actions to do in each case and that the check that edx > 5 means that the…
Crowning
  • 167
  • 1
  • 2
  • 10
1
vote
0 answers

Aligning jump table ops in FPC ASM

I have a jump table something like this: jmp rax @@table: jmp @@seg1 jmp @@sge2 jmp @@seg3 ... This was working perfectly with the understanding that the jmp code is two bytes in length. I have subsequently added code to the @@seg? code segments,…
IamIC
  • 17,747
  • 20
  • 91
  • 154
1
vote
2 answers

Interrupt vector table: why do some architectures employ a "jump table" VS an "array of pointers"?

On some architectures (e.g. x86) the Interrupt Vector Table (IVT) is indeed what it says on the tin: a table of vectors, aka pointers. Each vector holds the address of an Interrupt Service Routine (ISR). When an Interrupt Request (IRQ) occurs, the…
Gyom
  • 3,773
  • 5
  • 29
  • 38
1
vote
1 answer

MASM Assembly, creating loops

.386 .MODEL FLAT ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD Include io.h cr equ 0DH Lf equ 0AH .STACK 4096 .DATA string byte 40 Dup (?) number dword ? rejected byte cr, Lf, "Rejected", 0 .code _start: main…
Mutating Algorithm
  • 2,604
  • 2
  • 29
  • 66
1
vote
1 answer

Jump Table not found in Assembly code

I'm learning Assembly. I wrote the below c program containing switch case, created the object file(gcc -o filename filename.c), then took the object dump. But I didn't find the Labels and jump tables in the object dump. Can anybody tell me why the…
bhakta288
  • 9
  • 2
1
vote
1 answer

jump table & code pointers

My code looks like this: (n is a number among 0,1,2 and 3, and loc_A/B/C/D each represents a block of code) int test(int n){ static void *jt[7]= {&&loc_A, &&loc_B, &&loc_C, &&loc_D}; goto *jt[n]; loc_A: ...... loc_B: ...... …
Allen
  • 47
  • 7
0
votes
0 answers

Optimizing a branch like a jump table?

I was wondering if I have a branch bool condition = x > y; // just an example if(condition) { // do the thing... } else { // do the other thing... } It can be optimized to something like this because condition will be either 0 or 1, and rest of…
0
votes
0 answers

Locate jump tables in x86 assembly

Where are jump tables located in x86 elf code? progname: file format elf64-x86-64 Disassembly of section .text: 0000000000000000
: 0: 55 push %rbp 1: 48 89 e5 mov %rsp,%rbp 4: 48 83…
qwerty
  • 85
  • 2
  • 6
0
votes
1 answer

Does each language compile jump tables to custom locations, or are there specific places within ELF / PE headers for them to be?

I'm trying to figure out where jump tables (a data table pairing subroutine names with their addresses) are placed within an executable, and whether it's based on the language, the compiler, or if there's a standard placement perhaps within the…
J.Todd
  • 707
  • 1
  • 12
  • 34
0
votes
1 answer

how to get case number for jump table from a switch statement

I'm on this textbook, Randal E. Bryant, David R. O’Hallaron - Computer Systems. A Programmer’s Perspective [3rd ed.] (2016, Pearson) and I am stuck at figuring out how the author is able to work out the case number for the switch table, as shown…
Megan Darcy
  • 530
  • 5
  • 15
0
votes
1 answer

Qt No such slot using jump tables

I'm trying to create multiple QCheckBox without repeating code using a for. The problem is that for the connect I need a jump table array. The jump table declaration it's okey but then Qt don't find the slot. Here is a simplified…
Serk
  • 136
  • 2
  • 11
0
votes
0 answers

Why can't I refactor those accumulating ifs by using a jump table?

I try to do a minor refactoring, but it breaks all tests. I have a lot of ifs that I'd like to get rid off by using a jump table. I want to go from here : export class Pharmacy { constructor(drugs = []) { this.drugs = drugs } …
A Mehmeto
  • 1,594
  • 3
  • 22
  • 37
0
votes
0 answers

Is there a way to add *called* and *called by* functions within C code comments for Doxygen to pick up?

I am working on an C project that is principally a command based system. Most functions are called from a central command handler that parses a command string which then calls the appropriate function via a function pointer stored in a large array…
jct70
  • 1
  • 3