Lookup table not jump to address in table
Posted: Thu Sep 12, 2024 10:46 pm
Hi all. I have a subroutine in nasm assembly as follows:
when i call the main subroutine (Main_Subroutine) with rax containing the subroutine number nothing happens.
Why do you think?
Code: Select all
MAX_SUBS equ 3
Main_Subroutine:
push rbx
push rbp
push rsi
push rdx
push rdi
cmp rax, 1
jb _Exit
cmp rax, MAX_SUBS
ja _Exit
jmp [_Lookup+rax]
subroutine1:
.
.
.
jmp _Exit
subroutine2:
.
.
.
jmp _Exit
subroutine3:
.
.
.
_Exit:
pop rdi
pop rdx
pop rsi
pop rbp
pop rbx
ret
SECTION .data
_Lookup dq subroutine1, subroutine2, subroutine3
Why do you think?