Figure 3-37 Example of an intersegment branch.

CODE1        SEGMENT
                .
                .
                .
               JMP    FAR PTR CONTINUE
                .
                .
                .
CODE1        ENDS
                .
                .
                .
CODE2        SEGMENT
                .
                .
                .
   CONTINUE:   MOV    AX,BX
                .
                .
                .
CODE2        ENDS

3-5 LOOP INSTRUCTIONS

Post-test loops are most often constructed as shown in Fig. 3-38.

Figure 3-38 Typical structure of a post-test loop.

If the CX register is used as the counter and N contains the number of repetitions, then a post-test loop could be implemented on the 8086 as follows:

          MOV    CX,N
BEGIN:     .      \
           .       >Body of loop
           .      /
          DEC    CX
          JNZ    BEGIN

The loop instructions are designed to simplify the decrementing, testing, and branching portion of the loop.

From the definition of the LOOP instruction it is seen that the above post-test loop implementation could be simplified to:

          MOV    CX,N
BEGIN:     .
           .
           .
          LOOP   BEGIN

The loop instructions for the 8086 all have the form

where D8 is a 1-byte displacement from the current contents of IP.
Table of Contents | Next page | Previous page

This is page 35.