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?
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.
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)
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.
However, like other instructions, memory-to-memory operations are not possible using ADD/SUB instructions.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With