Why are there two consecutive transitions to EAX when building the optimization?

I looked at the ASM code of the release build with optimizations enabled, and here is one of the built-in functions that I came across:

0061F854 mov eax,[$00630bec]
0061F859 mov eax,[$00630e3c]
0061F85E mov edx,$00000001
0061F863 mov eax,[eax+edx*4]
0061F866 cmp byte ptr [eax],$01
0061F869 jnz $0061fa83

The code is quite easy to understand, it creates an offset (1) in the table, compares the value of the byte with it by 1 and makes a jump if NZ. I know that the pointer to my table is stored in $ 00630e3c, but I have no idea where $ 00630bec comes from.

Why two transitions to eax one by one? Is the first one overwritten by the second? Could this be a cache optimization or am I missing something incredibly obvious / obscure?

The Delphi code for the above ASM is as follows:

if( TGameSignals.IsSet( EmitParticleSignal ) = True ) then [...]

IsSet () is a built-in function of the class and calls the built-in function IsSet () for TSignalManager:

class function TGameSignals.IsSet(Signal: PBucketSignal): Boolean;
begin
  Result := FSignalManagerInstance.IsSet( Signal );
end;

The final IsSet of the signal manager is as follows:

function TSignalManagerInstance.IsSet( Signal: PBucketSignal ): Boolean;
begin
  Result := Signal.Pending;
end;
+6
1

, $00630bec TGameSignals. ,

ShowMessage(IntToHex(NativeInt(TGameSignals), 8))

, ,

0061F854 mov eax,[$00630bec] //Move reference to class TGameSignals in EAX
0061F859 mov eax,[eax + $250] //Move Reference to FSignalManagerInstance at offset $250 in class TGameSignals in EAX

[eax + $250] [$00630e3c], , MOV .

codegen, ...

, delphi,

if TGameSignals.IsSet( EmitParticleSignal ) then

, IF

var vBool : Boolean
[...]
vBool := Boolean(10);
if vBool and (vBool <> True) then

, , TRUE.

EDIT: Ped7g, .

0061F854 mov eax,[$00630bec] 

0061F854 mov eax,$00630bec

, , ... MOV "self" TGameSignals.IsSet. , , :

mov eax,[$00630bec]
call TGameSignals.IsSet

*TGameSignals.IsSet
mov eax,[$00630e3c]
[...]

mov , "Self" TGameSignals.IsSet, - "self" . , , .

, TGameSignals.IsSet Self , , MOV.

+9

All Articles