What Is Programmed Instruction?
Branch instructions are instructions that are not executed according to the program's statement flow, such as jump instructions, call instructions, jmp instructions, and so on.
Program control instruction
- Chinese name
- Branch instruction
- Foreign name
- Transfer instructions
- Classification
- Conditionally and unconditionally, etc.
- Nature
- Industrial process terminology
- Field
- Assembly language
- Branch instructions are instructions that are not executed according to the program's statement flow, such as jump instructions, call instructions, jmp instructions, and so on.
- Such instructions include unconditional branch instructions, conditional transition instructions, branch instructions that test CX / ECX values to 0, and they can be used to implement branching of a program. Branch instructions can use branch addressing to form a branch address. Specific applicability Varies by instruction. [1]
Introduction to branch instructions
- Branch instructions are relative to pipeline instructions. Branch instructions are instructions that are not executed according to the program's statement flow, such as jump instructions, call instructions, jmp instructions, and so on.
- Branch instructions are divided into the following categories:
jmp Branch instruction Unconditional branch instruction (such as: jmp)
- (1) Absolute jump instruction AJMP addr11; (PC) + 2 PC, addr10 ~ 0 PC10 ~ 0 [2]
- This is an unconditional branch instruction within the 2KB addressing range. It is an absolute jump. The destination address of the jump must be within the same 2KB addressing range as the first byte of the next instruction of AJMP. This is because the destination address of the jump is higher than the first byte of the next instruction of AJMP by 5 Bits addr15 to 11 are the same. This instruction is reserved for compatibility with MCS-48 and is currently rarely used. [2]
- (2) Relative jump instruction SJMP rel; (PC) + 2 rel PC [2]
- When this instruction is executed, the content of the PC is increased by two, and then the relative offset rel is added to calculate the jump destination address. rel is a signed number of bytes. It is represented by two's complement in the program. Its value ranges from -128B to + 127B. When rel is positive, it indicates a positive jump, and when it is negative, it indicates a negative jump. [2]
- (3) Long jump instruction LJMP addr16 addr16 PC [2]
- When this instruction is executed, the upper and lower 8 bits of the 16-bit operand are loaded into the PCH and PCL of the PC, respectively, and the instruction is unconditionally transferred to the specified address. The jump destination address can be anywhere in the 64KB program memory address space without affecting any flag bits. [2]
- (4) Indirect jump instruction JMP @ A + DPTR [2]
The function of this instruction is to add the 8-bit unsigned number in accumulator A to the 16-bit address in the data pointer DPTR, and add the 16-bit new address to the PC. The instruction execution process does not change the contents of the accumulator and data pointer, nor does it affect the flags. [2]
jcxz Branch instruction conditional branch instruction (eg jcxz)
- Function: Take the state of the flag bit or the logic operation result of the flag bit as the transfer basis. If the transfer condition is met, the instruction is directed to the target address to execute otherwise the next instruction is executed. It must be pointed out that the offset of the branch address of the conditional branch instruction is limited to the range of -128 to +127 bytes, and the relative branch method is used (relative branch instruction refers to the current address as the reference and the relative offset for the jump during the jump) Transfer, usually jump within this address segment. If you need to jump to a distant place, such as jump to another address segment, you need to add the address of the jump target segment). [3]
loop Branch instruction loop instruction (such as loop)
- Can control program loop. [1]
Branch instruction process
- Such as subroutine call and return instructions. [1]
Branch instruction interrupt
- The process of causing the computer to temporarily suspend the executing process and switch to processing an event. After processing, resume the execution of the original process. [1]