Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't MOV have both operands as memory locations? [closed]

I read that MOV instruction cannot have memory locations for both its operands.

Like : MOV [0012H], [0016H] is not allowed.

Why so?

And can other instructions have memory locations for both its operands?

like image 773
batman Avatar asked Jan 24 '13 20:01

batman


People also ask

Why is it not allowed to have two operands from memory in an instruction?

Because that wasnt a design goal, they didnt want to burn the cost for it, not practical, etc. Because a ModR/M byte can only encode one memory operand.

What are the limitations of mov?

The MOV instruction has a few limitations: an immediate value cannot be moved into a segment register directly (i.e. mov ds,10) segment registers cannot be copied directly (i.e. mov es,ds) a memory location cannot be copied into another memory location (i.e. mov aNumber,aDigit)

Which transfer is not allowed in mov instruction?

The MOV instruction cannot move from memory to memory or from segment register to segment register are not allowed. Memory-to-memory moves can be performed, however, by the string move instruction MOVS. XCHG (Exchange) swaps the contents of two operands.

Is it possible to use two memory operands in the ADD and SUB instructions?

However, like other instructions, memory-to-memory operations are not possible using ADD/SUB instructions.


1 Answers

It's was a design decision when they created the CPU. More addressing modes you have and more instructions, larger (in terms of number of bits required to represent instruction) the instructions get. And larger instruction take longer to fetch from memory.

In other words, x86's instruction set is not orthogonal. It is not necessarily bad, at least not now, that only very limited amount of assembly code is written.

Some other CPUs (for example MC680xx designed in same era) can do that.

like image 122
dbrank0 Avatar answered Sep 17 '22 08:09

dbrank0