Direct addressing without segment in x86?

181 views Asked by At

The encoding of memory operands with the SIB-byte allows a ›none register‹ for index as well as base. So this should be a valid instruction:

03 04 25 10 32 54 76add eax, dword [ 0x76543210 ]

The address should be calculated like this: 1·0+0+0x76543210 and is not based on any segment register.
In a flat memory this should not change anything, but is this different from add eax, dword ds:0x76543210, if ds is not zero?

1

There are 1 answers

0
fuz On BEST ANSWER

In 16 and 32 bit operation modes, a SIB byte indicating no base and no index (ie. 04 +r 25) simply encodes a 32 bit address, just as the modr/m byte 05 +r does. This does not affect segmentation, ds is used to add a segment base address in both cases.

In long mode (64 bit mode), the modr/m byte 05 +r indicates a rip (resp. eip) relative address whereas 04 +r 25 indicates an absolute address. For example:

8b 05 XX XX XX XX       is mov eax, [rip+XXXXXXXX]
8b 04 25 XX XX XX XX    is mov eax, [XXXXXXXX]