nanderEire
asked on
What is this assembly language doing?
Hi.
This seems to take a lot of time. Is the assembly below from the creation of Buf?
This seems to take a lot of time. Is the assembly below from the creation of Buf?
void XPControl::process_xp_buffer_event()
{
uint32 CurrentTimeOut = 10; // Milliseconds willing to wait for new message in GetXPMessage
int32 retLen; // Value Returned from GetXPMessage
TF_TRANS *pTFTrans;
uint8 Buf[0x4000];
}
lea edi, DWORD PTR [ebp-16744]
mov ecx, 0x105ah
mov eax, -0x33333334
rep stosd
>> Is the assembly below from the creation of Buf?
So, no - it does something else.
So, no - it does something else.
ASKER
More specifically what does the command rep stosd do here?
>> what does the command rep stosd do here?
What I said : it stores the (32bit) value from register eax (-0x33333334) into the memory location specified by the register edi ([ebp-16744]).
What I said : it stores the (32bit) value from register eax (-0x33333334) into the memory location specified by the register edi ([ebp-16744]).
Oops, I missed the "rep" part (I must not be fully awake yet lol).
Here's my revised reply :
>> what does the command rep stosd do here?
It stores the (32bit) value from register eax (-0x33333334) into the memory location specified by the register edi ([ebp-16744]), and repeats that ecx times (0x105ah = 4186) for consecutive memory locations.
Basically, it initializes a block of 16744 = 4186*4 bytes starting at address [ebp-16744] to the value -0x33333334 (repeated 4186 times)
Here's my revised reply :
>> what does the command rep stosd do here?
It stores the (32bit) value from register eax (-0x33333334) into the memory location specified by the register edi ([ebp-16744]), and repeats that ecx times (0x105ah = 4186) for consecutive memory locations.
Basically, it initializes a block of 16744 = 4186*4 bytes starting at address [ebp-16744] to the value -0x33333334 (repeated 4186 times)
Note that -0x33333334 is the same as 0xCCCCCCCC, so this might be some kind of default memory initialization of the stack.
Is this in debug mode ?
Is this in debug mode ?
ASKER
Yes it is in Debug. So is it likely to be the initialization of the Buf[0x4000]?
>> So is it likely to be the initialization of the Buf[0x4000]?
It looks like it's the initialization of that buffer, and the other local data in the function.
If you compile/run the code in release mode, it should be faster, as that initialization won't happen.
Note also, that a statically allocated buffer of size 0x4000 is quite big ... Can't you allocate it dynamically ?
It looks like it's the initialization of that buffer, and the other local data in the function.
If you compile/run the code in release mode, it should be faster, as that initialization won't happen.
Note also, that a statically allocated buffer of size 0x4000 is quite big ... Can't you allocate it dynamically ?
ASKER
I'm trying to optimise this program and pointed out that the buffer was huge and is being created repeatedly but they indicated that it wasn't a performance hit in release mode. Is that true?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great help. Thank you
>> mov ecx, 0x105ah
>> mov eax, -0x33333334
>> rep stosd
It stores the value -0x33333334 at memory location [ebp-16744]