Intel 80286, 80287 manual Instruction SET

Models: 80287 80286

1 515
Download 515 pages 45.04 Kb
Page 303
Image 303

THE 80286 INSTRUCTION SET

The REP prefixes make sense only in the contexts listed above. They cannot be applied to anything other than string operations.

Synonymous forms of REPE and REPNE are REPZ and REPNZ, respectively.

The REP prefixes apply only to one string instruction at a time. To repeat a block of instructions, use a LOOP construct.

The precise action for each iteration is as follows:

1.Check the CX register. If it is zero, exit the iteration and move to the next instruction.

2.Acknowledge any pending interrupts.

3.Perform the string operation once.

4.Decrement CX by 1; no flags are modified.

5.If the string operation is SCAS or CMPS, check the zero flag. If the repeat condition does not hold, then exit the iteration and move to the next instruction. Exit if the prefix is REPE and ZF=O (the last comparison was not equal), or if the prefix is REPNE and ZF=1 (the last comparison was equal).

6.Go to step 1 for the next iteration.

As defined by the individual string-ops, the direction of movement through the block is determined by the direction flag. If the direction flag is 1 (STD was executed), SI and/or DI start at the end of the block and move backward; if the direction flag is 0 (CLD was executed), SI and/or DI start at the beginning of the block and move forward.

For repeated SCAS and CMPS operations the repeat can be exited for one of two different reasons: the CX count can be exhausted or the zero flag can fail the repeat condition. Your code will probably want to distinguish between the two cases. It can do so via either the JCXZ instruction or the condi- tional jumps that test the zero flag (JZ, JNZ, JE, and JNE).

NOTE

Not all input/output ports can handle the rate at which the repeated I/O instructions execute.

PROTECTED MODE EXCEPTIONS

None by REP; exceptions can be generated when the string-op is executed.

REAL ADDRESS MODE EXCEPTIONS

None by REP; exceptions can be generated when the string-op is executed.

8-93

Page 303
Image 303
Intel 80286, 80287 manual Instruction SET