There is C++ code:
int16_t ** g_Meshes;
int32_t m_MeshPtrCount;
int16_t * g_MeshBase;
uint32_t *mesh_indices;
for (int i = 0; i < m_MeshPtrCount; i++)
{
g_Meshes[i] = &g_MeshBase[mesh_indices[i] / 2];
}
And corresponding Assembler code from IDA:
cseg01:0001E958 For_Mesh_Ptr_Count: ; CODE XREF: Load_Objects+B9j
cseg01:0001E958 mov ebx, Mesh_Indices
cseg01:0001E95E mov eax, [edi+ebx]
cseg01:0001E961 mov edx, eax
cseg01:0001E963 sar edx, 1Fh
cseg01:0001E966 sub eax, edx
cseg01:0001E968 sar eax, 1
cseg01:0001E96A lea edx, ds:0[eax*2]
cseg01:0001E971 mov eax, g_MeshBase
cseg01:0001E976 add eax, edx
cseg01:0001E978 mov [edi+ebx], eax
cseg01:0001E97B inc ecx
cseg01:0001E97C mov ebx, [esp+28h+var_20] ; var_20 = m_MeshPtrCount
cseg01:0001E980 add edi, 4
cseg01:0001E983 cmp ecx, ebx
cseg01:0001E985 jl short For_Mesh_Ptr_Count
Please explain someone for what need this operations:
cseg01:0001E963 sar edx, 1Fh
cseg01:0001E966 sub eax, edx
sar edx, 1Fh
is equivalent toedx >> 31
except it always preserves the sign bit.sub eax, edx
is simplyeax -= edx
. It's hard to provide more info than that since we dont know the variable-register mapping here.