Search code examples
memorymemory-addresscpu-registersx86-16segment

Which of these two operations on an 8086 CPU will be faster in execution and why?


Which of these two operations on an 8086 CPU will be faster in execution and why?

  1. Read the word 0x000A from the address 0x0000B
  2. Read the word 0x000B from the address 0x0000A

Solution

  • A transfer from memory to register on a 8086 CPU takes 8 clocks + the clocks needed to calculate the effective address.

    mov ax,[0x000B]  ; Executes in 8+6+4 clocks
    

    Aligning data on a word boundary ensures faster fetch times so one would expect that line 2 could be faster. And it is!

    mov ax,[0x000A]  ; Executes in 8+6 clocks
    

    Why do you specify the contents at those addresses? I don't expect that to influence the reading speed.