The loop instruction is a loop instruction. All loop instructions are short transfers, and the corresponding machine code contains the transfer displacement instead of the destination address.
The range of IP modification is -128~127.
Instruction format: loop label ((cx) = (cx)-1, if (cx) ≠ 0, move to the label for execution).
(cx) = (cx)-1; if (cx) != 0, (IP) = (IP) + 8-bit shift.
8-bit displacement = the address at the label-the address of the first byte after the loop command;
The range of 8-bit displacement is -128~127, expressed in complement;
The 8-bit displacement is calculated by the compiler at compile time.
If (cx) = 0, do nothing (program downward execution)
Reference: <<Assembly Language>> Wang Shuang