Processor instruction prefixes (number of additional clock cycles)

In summary, the Intel 8086 requires 2 extra clock cycles for prefix instructions, which may vary depending on the instruction boundary and previous instructions. The REP prefix is listed as 2 clocks, but it may be 4 cycles if previous instructions were fast enough. The REP MOVSx instruction takes up 9 cycles, but it is unclear if this includes the REP overhead. If a segment override is used with the REP MOVSx, an additional 2 cycles may be added for each repetition.
  • #1
SMD1990
49
0
More specifically, this question is oriented towards the Intel 8086.

I have this manual that lists the number of clock cycles the 8086 requires to execute each of its instructions, prefixes, et cetera.

My question is about repeat string instructions. The REP prefix is listed as 2 clocks. MOVSx by itself is 18 clocks. REP MOVSx is 9 + (17 / number of repetitions).

If I wanted to count the number of clock cycles the 8086 would consume executing a REP MOVSx instruction in an instance of my code, would I include the REP prefix's 2 clocks for each repetition? Or, do I count it once, then add 9 + (17 / number of repetitions)? Or, does that 9 include the REP, meaning I should not count the prefix as consuming any clock cycles at all?

And what if I used a segment override with the REP MOVSx? Normally, I add 2 clocks for segment override. So +2 for each repetition? Just the first repetition?

Sorry. I know this is a very esoteric question. "Who cares about the 8086?" Right? I do, and I am curious about this unclear situation. So, if anyone happens to know, could they please enlighten me?



http://matthieu.benoit.free.fr/cross/data_sheets/8086_family_Users_Manual.pdf
 
Computer science news on Phys.org
  • #2
The prefix instructions only take the 2 extra cycles one time. Note that it takes 4 cycles to read memory (to fetch 16 bits of instruction data), so that 2 cycles may be 4 cycles depending on the instruction boundary, and if previous instructions were fast enough (2 to 3 cycles) to empty the pre-fetch queue. I don't know if the rep movs ... 9 cycles includes the rep overhead or not.
 
Last edited:

1. What is the purpose of processor instruction prefixes?

Processor instruction prefixes are used to modify the behavior of a specific instruction in a processor's instruction set. They allow for more complex operations to be performed by adding additional parameters or changing the way the instruction is executed.

2. How do instruction prefixes affect the number of clock cycles needed to execute an instruction?

The use of instruction prefixes can increase the number of clock cycles needed to execute an instruction. This is because the addition of extra parameters or changes in execution can make the instruction more complex and require more time to complete.

3. Are there any benefits to using instruction prefixes?

Yes, there are benefits to using instruction prefixes. They allow for more versatile and efficient use of a processor's instruction set, as well as enabling the execution of more complex operations that may not be possible without them.

4. Can instruction prefixes be used in any type of processor?

Instruction prefixes are specific to the instruction set of a particular processor. Different processors may have different prefixes and their use may vary. It is important to refer to the documentation of a specific processor to understand which instruction prefixes are supported.

5. How are instruction prefixes different from instruction operands?

Instruction prefixes and instruction operands serve different purposes. Instruction prefixes are used to modify the behavior of an instruction, while operands are the actual data or values that are operated on by the instruction. Instruction prefixes are added before the opcode, while operands are included after the opcode in the instruction code.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
8
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
4K
  • Programming and Computer Science
Replies
25
Views
2K
  • Programming and Computer Science
Replies
6
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
6
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
8
Views
13K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
2K
  • Special and General Relativity
Replies
6
Views
1K
Back
Top