Hi
I started learning assembly language and I tested jmp instruction with a small program.
Here are my code
section .data
pointer dd one,two,three
dis1 dd "One"
dis2 dd "Two"
dis3 dd "Three"
lendis1 equ $-dis1
lendis2 equ $-dis2
lendis3 equ $-dis3
section .bss
var resd 1
section .text
global main
main:
mov eax,3
mov ebx,0
mov ecx,var
mov edx,1
int 80h
mov edx,var
mov eax,[pointer + edx*4]
jmp [eax]
one:
mov eax,4
mov ebx,1
mov ecx,dis1
mov edx,lendis1
int 80h
jmp exit
two:
mov eax,4
mov ebx,1
mov ecx,dis2
mov edx,lendis2
int 80h
jmp exit
three:
mov eax,4
mov ebx,1
mov ecx,dis3
mov edx,lendis3
int 80h
jmp exit
exit:
mov eax,1
int 80h
When I ran this as following
root@kalihost:~# nasm -f elf64 jump.asm
root@kalihost:~# gcc -o jump jump.o
root@kalihost:~# ./jump
1
Segmentation fault
root@kalihost:~#
root@kalihost:~#
Please find me the error.