4

In assembly language, instruction

MOV A B

means moving the content of B (source) to A (destination).
I suddenly came up with the instruction

MOV D D

What does it imply?

I have seen this in my lab manual. Screenshot:

enter image description here

haccks
  • 104,019
  • 25
  • 176
  • 264

3 Answers3

7

The 8085 register-to-register MOV instructions are orthogonal. That is, there are opcodes to move any of the 8-bit registers to any of the other 8-bit registers. So MOV D,D moves the contents of the D register to the D register. It doesn't do anything useful and doesn't affect any of the flags, but it's a valid instruction just as are MOV A,A, MOV B,B, etc.

Copying a register to itself is effectively a "no operation" or NOP instruction. The "official" 8085 NOP is opcode 00, but any of the register-move-to-itself instructions have the same effect.

It's really just an artifact of the way the processor was designed. There are some tricks you can do that make use of those instructions, but they're not generally useful.

Jim Mischel
  • 131,090
  • 20
  • 188
  • 351
  • When we need `NOP` instruction? – haccks Jul 17 '13 at 18:48
  • 1
    According to the [Wikipedia article](http://en.wikipedia.org/wiki/NOP): "A NOP is most commonly used for timing purposes, to force memory alignment, to prevent hazards, to occupy a branch delay slot, or as a place-holder to be replaced by active instructions later on in program development..." – Jim Mischel Jul 17 '13 at 19:27
  • 1
    Not for 8085, those considerations only apply to processors with a pipeline. You used it to disable code while debugging your assembly code. This question makes me feel old :) – Hans Passant Jul 17 '13 at 20:11
  • @HansPassant: I seem to remember using NOP on the 8080 and Z80 for timing loops and for some rather dodgy self-modifying code. – Jim Mischel Jul 17 '13 at 20:20
  • Nops are also useful when you don't know exactly where your instruction is going to flow. Adding a large amount of one-byte no-ops gives you a safe "landing area" for the control flow. – Kerrek SB Jul 17 '13 at 21:00
  • 1
    Another use is the "illegal" instruction `rep nop` on early x86-Pentiums with hyperthreading that effectively produce a yield during a spinlock's busy-wait spin round. Later processors add a dedicated `pause` instruction for that purpose. (It's the same instruction, just documented.) – Kerrek SB Jul 17 '13 at 21:02
5

You have to keep the era in mind, 8085 was designed back in 1977. Integrated circuit process technology was not nearly as advanced back then, there was a pretty hard upper limit on the number of transistors they could put on a die. It only uses 6,500 of them.

That puts a heavy limit on the kind of logic they could use to implement a processor. The bits in the opcode that selects the operands are passed directly to the register bank multiplexer. And occupy the same bit positions and meaning in other instructions that use a register. The budget to burn up additional transistors to make special exceptions for operands that don't make sense just wasn't available. It was much simpler and cheaper to leave them in place and not use up logic to deal with the exceptional case.

Not much of a problem, nobody was going to use the nonsensical instructions by accident.

It worked the other way around too btw, sometimes a processor had an obvious hole in the instruction set. The Z80 was like that. Intended for an instruction that was bugged in the first few silicon passes and not considered essential enough to fix. So they just left it out of the documentation. Or left them in place, 6502 was notoriously buggy. Had a very attractive price though :)

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
1

It is a NOP operation, used for program delays.

johnfound
  • 6,857
  • 4
  • 31
  • 60