1/46
Looks like no tags are added yet.
Procedures
Considered the most important innovation in the development of programming languages.
Subroutines
Procedures are also known as subroutines.
Reentrant procedure
A reentrant procedure is a procedure that can be implemented in such a way that more than one process can execute it at the same time without any conflict.
Call instruction (CALL)
This branches from the present location to the procedure.
Near CALL
A Near CALL is an instruction to call a procedure that is in the same code segment as the CALL instruction that calls it, while the Far CALL is used to call a procedure from a different segment.
Return instruction (RET
This returns the control to the place from which a procedure was called. Thus, it is the last instruction in any procedure.
CALL Address
This instruction pushes the current IP value onto the stack and causes a jump to the entry point of the procedure by placing the address of the entry point in the IP. This basically calls a procedure of a function.
CALL Label (Near)
This instruction pushes the content of the IP onto the stack and jumps to the offset address in the current code segment.
CALL Label (Far)
This instruction pushes the content of the IP onto the stack and jumps to the offset address in any memory location.
CALL Memory (Near)
This instruction pushes the content of the IP onto the stack and jumps to the offset address in the memory register of the current code segment.
CALL Memory (Far)
This instruction pushes the content of the IP onto the stack and jumps to the offset address of the register at any memory location.
RET
This instruction returns the address from a near procedure.
RETF
This instruction returns the address from a far procedure.
Conditional branches
These branch instructions may or may not cause branching, depending on some specified conditions.
Branch instruction
A branch instruction contains the address of the next instruction to be executed as one of its operands (Stallings, 2019).
Direct
The instruction contains the target address.
Indirect
The instruction specifies where the target address is to be found.
Relative
The instruction specifies the differences between the current and the target address.
Branch
In computer organization, a branch may also refer to the act of switching execution to a different instruction sequence as a result of executing a branch instruction.
Forward
Instructions with higher addresses
Backward
Instructions with lower addresses
Unconditional branches
These instructions always result in branching.
Jump instructions
Jump instructions facilitate the transfer of the program sequence to the memory address given in the operand, based on the specified flag.
Unconditional Jump Instructions
These are used to jump on a particular location unconditionally. Thus, there is no specific condition that needs to be satisfied for the jump to take place.
Near JMP
This procedure targets memory location within the same code segment (intra-segment).
Short JMP
This procedure targets memory location within the same code segment (intra-segment), but the offset is 1byte long.
Far JMP
This procedure targets memory location that is outside the segment (inter-segment), and the size of the instruction pointer is a double word.
Conditional Jump Instructions
In implementing conditional jumps, the processor must check for a specific condition for the jump to take place. Each status flag, or a combination of the status flags, is tested for a conditional jump.
Status flags
C – carry flag, P – parity flag, A – auxiliary carry flag, Z – zero flag, S – sign flag, and O – overflow flag.
JA Label
Short jump if the 1st operand is above the 2nd operand (as set by the CMP instruction); Unsigned
JAE Label
Short jump if the 1st operand is above or equal to the 2nd operand (as set by the CMP instruction); Unsigned
JB Label
Short jump if 1st operand is below the 2nd operand (as set by the CMP instruction); Unsigned
JBE Label
Short jump if 1st operand is below or equal to the 2nd operand (as set by CMP instruction); Unsigned
JC Label
Short jump if carry flag is set to 1
JE Label
Short jump if 1st operand is equal to 2nd operand (as set by the CMP instruction); Either signed or unsigned
JG Label
Short jump if 1st operand is greater than the 2nd operand (as set by the CMP instruction); Signed
JMP Label
Unconditional jump; Transfers control to another part of the program; 4byte address may be entered in the form: 1234h:5678h, where the 1st value is a segment and the 2nd value is an offset
JNP Label
Short jump if no parity (odd); Only the 8 low bits of the result are checked; Set by the CMP, SUB, ADD, TEST, AND, OR, or XORinstructions
JP Label
Short jump if parity (even); Only the 8 low bits of the result are checked; Set by the CMP, SUB, ADD, TEST, AND, OR,or XOR instructions
JNS Label
Short jump if not signed (if positive); SetbyCMP, SUB,ADD, TEST, AND, OR, or XOR instructions.
JS Label
Short jump is signed (if negative); Set by CMP, SUB, ADD, TEST, AND, OR, or XOR instructions.
JO Label
Short jump if overflow
Loop
Block of statements that are repeatedly executed until a specific condition is satisfied.lock of statements that are repeatedly executed until a specific condition is satisfied.
LOOP Label
Decreases the CX; Jump to label if CX is not zero.
LOOPE/LOOPZ Label
Decrease the CX; Jump to label if CX is not zero and the value of Z is one (equal).
LOOPNE/LOOPNZ Label
Decrease the CX; Jump to label if CX is not zero and the value of Z is zero (not equal).
JCXZ Label
Short jump if CX register is 0.