I'm just a beginner in assembly language and have probably silly question. What is difference between those two lines?
3e 8b 06 mov eax,DWORD PTR ds:[esi]
8b 06 mov eax,DWORD PTR [esi]
In my opinion it does the same, I also tried this program:
int main()
{
__asm
{
mov esi, ebx
mov eax,DWORD PTR [esi]
mov ebx,DWORD PTR ds:[esi]
}
return 0;
}
And it confirmed my guess, so asking for you guys, if there is any difference. Why would we need two instructions that does the same but have different length opcodes.
The two primary data definition statements are the DS directive and the DC directive. The DS directive allocates space for a label; the DC allocates space and assigns an initial value.
A 16-bit Data Segment register or DS register stores the starting address of the data segment. Stack Segment − It contains data and return addresses of procedures or subroutines. It is implemented as a 'stack' data structure. The Stack Segment register or SS register stores the starting address of the stack.
SS:SP (SS is Stack Segment, SP is Stack Pointer) points to the address of the top of the stack, i.e. the most recently pushed byte. DS:SI (DS is Data Segment, SI is Source Index) is often used to point to string data that is about to be copied to ES:DI.
mov ax,@data ; Initalize DS mov ds,ax … It is a directive that is used by 2 tools: assembler & loader • Assembler : Uses it to know when to stop reading from . ASM file – Any statements after END are ignored. Any statements after END are ignored.
The 3E
byte in the first instruction is a DS
segment override prefix (see "2.1.1 Instruction Prefixes" in Intel's Software Developer's Manual).
Group 2
— Segment override prefixes:
• 3EH—DS segment override prefix (use with any branch instruction is reserved)
In this case it's redundant because ds
is the default segment for most memory accesses. Also, if you have a flat 32-bit memory space you typically never explicitly specify the segment register since they're set up to point to the same memory anyway.
1) DS = DATA-segment
2) Two different opcodes because two different "adressing modes". 3) These are two different types of x86 er based so called "adressing modes". A very basic stuff in asm.
a) https://cs.nyu.edu/courses/fall10/V22.0201-002/addressing_modes.pdf b) http://www.ic.unicamp.br/~celio/mc404s2-03/addr_modes/intel_addr.html
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