
Each flag can be either 1 or 0, set or not set. Each bit in this register is called a flag. The FLAGS register contains the current state of the processor. The IP register cannot be accessed by the programmer directly. The IP register points to where in the program the processor is currently executing its code.

With the general registers, there are additionally the: The other data registers can be addressed in this way by changing the suffix - "X" for e xtended, "H" for high, and "L" for low.Ĭollectively the data and address registers are called the general registers. For example, in the AX register, the AH register addresses the upper eight bits of the AX register, and the AL register addresses the lower eight bits of the AX register.
ADDING MNEMONICS IN CX PROGRAMMER CODE
In other words, the two ways to exit the loop are CX = 0 or ZF = 0, then after the processor starts executing the next instruction present after LOOPE/LOOPZ.Įxample for LOOPE/LOOPZ : The following code segment compares the elements of ARRAY with 00FFH, it exits if they are unequal.Each register is specialized for a certain task, and operations that deal with that task are often run more efficiently if the right register is used.Įach data register can be broken up into two eight-bit registers - that is 16 bits of data in a 16 bit register can be addressed 8 bits at a time: the upper eight and the lower eight bits, and can be treated as registers in their own right. If CX equals 0, or if the zero flag gets cleared within the loop, the loop will terminate. For every iteration or every time the LOOPE/LOOPZ instruction executes, it decrements the CX register by one without affecting flags and performs a short jump to the target address (i.e., to the address with signed 8-bit relative displacement in the range of -128 bytes to +127 bytes from the instruction address after LOOPE/LOOPZ instruction) until the condition CX ≠ 0 and ZF = 1 is maintained.

Firstly the count register CX is loaded with a value of the number of times the instructions are to be repeated. This instruction is similar to LOOP except that it checks for both CX and ZF conditions to be satisfied before the jump can take place. When CX = 0, the execution of the loop will stop and the instructions after the LOOP will start execution. This loop will continue until the CX becomes zero. The CX register will perform the LOOP operation on the instructions to be iterated.įor every execution of LOOP instruction, the CX is automatically decremented by one without affecting flags and performs a short jump to the target address. The number of iterations will depend on the condition to be satisfied. The LOOP instruction executes the group of instructions a number of times and it uses relative addressing mode. Let us see briefly each LOOP instruction.


CX register must be loaded with the number of iterations to be performed, prior to entering the section of the code terminated by LOOP instructions. The condition is to check the CX register and zero flag (ZF) or can be only to check the CX register.
ADDING MNEMONICS IN CX PROGRAMMER SERIES
The various LOOP instructions and their functions are listed below.ĭecrements CX by one, if CX ≠ 0, jump to "short-label".ĭecrements CX by one, if CX ≠ 0 and ZF = 1, jump to "short-label".ĭecrements CX by one, if CX ≠ 0 and ZF = 0, jump to "short-label".Īll the above instructions are iteration control instructions and are used to execute a series of instructions repeatedly on the successful satisfaction of the condition. Basically, the LOOP instructions are short jump instructions on a condition i.e., when the condition satisfies a short jump is taken whose destination or target address is in the range of -128 bytes to +127 bytes from the instruction address after LOOP instruction. The loop instructions cause the microprocessor to execute a series of instructions repeatedly. LOOP Instructions of 8086 Microprocessor : These instructions are called LOOP instructions. Similarly, the designers of the 8086 microprocessor came up with a group of instructions to perform repeated execution of a series of instructions a specified number of times much easier. In all the programming languages there are some specific structures to express this repeated execution of instructions. Sometimes while executing a program there will be a need for repeated execution of some instructions a specified number of times.
