Why can’t an immediate value be moved into a segment registry directly (i.e. mov ds 10) ?
Also, why cannot segment registers be copied directly (i.e mov es, ds) ?
.code
mov AX,@data
mov DS,AX
Why can’t this be done directly by:
mov DS, @data
Any explanation why it was designed this way?
The main problem here is Instruction en-/decoding
X86 has opcodes with variable lengths. They can range from a single byte (like nop) to a couple of bytes, like 12 bytes for something like movl $0xdeadbeef, 0x12345678(%ebx,%edx,1)
Intel decided to not include instructions which provide no real advantage. mov segmentregister, is one of them. Most probably because segmentregisters do not have to be changed very often.
So, this saves space in the instruction encoding and so it saves a couple of transistors on the chip (compared to transistors dumps today, maybe not THAT much).
Other ISAs like ARM or MIPS which have a fixed encoding size for their instructions usually allow the same operations for all registers. In the case of ARM even the PC is a normal register and can be read an written too.