references:
"Assembly language programming"
...............................................................................................................................................................................................
Learning control process executed when the program encounters an unconditional branch, instruction pointer automatically jump to another location, an unconditional branch may be used in three ways:
Jumps, calls, interrupts
Each branch unconditionally behavior in the program are different, you can decide which one to use in the program logic, the following look at the differences between these types of, and implement them in assembly language program
A Jump
Jump assembly language programming is the most basic type of branch, similar to GOTO statements in high-level language, but using goto would be considered poor coding, but the compilation will not think so.
In fact a single assembler jump instructions are compiled into one of three different types of jump operation codes:
Short Jump, near jump, far jump
These three types of jump is determined by the distance between the memory locations and the memory location of the destination point of the current instruction. Jump using that type determined based on the number of bytes to skip
For chestnut:
1 .section .text 2 .globl _start 3 _start: 4 nop 5 movl $1, %eax 6 jmp overhere 7 movl $10, %ebx 8 int $0x80 9 overhere: 10 movl $20, %ebx 11 int $0x80
Execution of the program: echo $?
Results: 20
1 objdump -D jmptest 2 3 jmptest: 文件格式 elf64-x86-64 4 5 6 Disassembly of section .text: 7 8 0000000000400078 <_start>: 9 400078: 90 nop 10 400079: b8 01 00 00 00 mov $0x1,%eax 11 40007e: eb 07 jmp 400087 <overhere> 12 400080: bb 0a 00 00 00 mov $0xa,%ebx 13 400085: cd 80 int $0x80 14 15 0000000000400087 <overhere>: 16 400087: bb 14 00 00 00 mov $0x14,%ebx 17 40008c: cd 80 int $0x80