You are on page 1of 9

Near and Far Jump

• The jump location may be in the same code segment, in which case it
is near jump. For a near jump, the value of CS remains the same, but
the value of IP will change. This is also called an intra-segment (within
segment) jump.
• The jump location may be in a different code segment – then it is
called a far jump. In this case, both CS and IP will have to take on new
values. This is an inter-segment (between segments) jump.
Loop Instruction
• LOOP label
The register CX is assigned to decrement every time LOOP executes.
When CX = 0, the looping is exited.
String Instructions

• The 8086 has a set of instructions for handling blocks of data in the form of
bytes or words.

• They are called ‘string’ instructions. A string is an array of data of the same
type – for example, a character string or a byte string.

• String instructions can be seen to be useful when in the memory, data has to
be moved, searched or compared in blocks (arrays).
Pre-requisites for using String Instructions

• Two segments are to be defined i.e., the data segment and the extra
segment. This means that the corresponding segment registers DS and ES
have to be initialized and used. The data segment is the source segment
and the extra segment is the destination segment.

• The DI registers and SI registers should act as pointers to the data


segment and extra segment respectively. This means that, initially, SI
should contain the address (offset) of the first location in the data
segment. Similarly, DI should contain the address (offset) of the first
location in the extra segment.
Pre-requisites for using String Instructions

• There is a control flag called the direction flag which is used


exclusively for string operations. Its purpose is that in string
operations, if the flag is set, the pointer registers get automatically
decremented and if reset, the reverse occurs. So whenever string
instructions are being used, the direction flag (DF) should be set or
reset depending on the direction the addresses are to be modified
after each operation.

• The counter CX should be loaded with the count of the number of


operations required.
The MOVS Instruction
Small Model Program
The CMPS Instruction -- CMPSB/CMPSW

This instruction is for string comparison, byte by byte or word by word


as the case may be.
String Instructions Summary

You might also like