## Yet another compiler anomaly

Just found in some old code:

fabs
fild    [esp+50h+var_34]
fabs
fxch    st(1) ; first instruction
fxch    st(1) ; second instruction
fcomp   [esp+50h+var_3C]
fnstsw  ax
test    ah, 41h
jz      short loc_100040B7


The firsst FXCH instruction swaps ST(0) and ST(1), the second do the same, so both do nothing. This is a program uses MFC42.dll, so it could be MSVC 6.0, 5.0 or maybe even MSVC 4.2 from 1990s.

This pair do nothing, so it probably wasn't catched by MSVC compiler tests. Or maybe I wrong?

There are another compiler anomalies in my book, or just open PDF and then Ctrl-F "anomaly".

The reason I cite them is that sometimes practicing reverse engineers are stumbled by them while they should just ignore such quirks.

Interested in articles like this? Subscribe to my blog and/or twitter: @yurichev and/or facebook.