Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

It's 2016 and COMPILERS ARE STILL STUPID

Name: Cudder !cXCudderUE 2015-12-31 22:29

Just analysing a device driver for hardware few months old... as usual, it's as bloated as a week-old dead pig overall but then I come across pieces like this:

shl ecx, 4
mov edx, ecx
shr ecx, 2
xor eax, eax
rep stosd
mov ecx, edx
and ecx, 3
rep stosb


:facepalm:

Name: Cudder !cXCudderUE 2015-12-31 22:46

"I have no idea how to use registers":

call SomeFunc
mov edx, eax
test edx, edx
mov [esi+48], edx
jnz loc1
...
loc1:
mov edi, edx
...


Instead of just moving the return value in eax to edi where it eventually gets used in one of the stupid sequences in OP, the compiler somehow decides to thread it through edx, before realising that edx needs to be used for something else and then moves it into edi.

This would be unacceptable even at O0, but this is released code presumably compiled with O2 or better and in active use by millions or more machines worldwide. WTF.

Name: Cudder !cXCudderUE 2015-12-31 22:59

How much stupidity could a 5-instruction function have?

mov eax, ecx
lea edx, [eax+14Ch]
and dword [edx], 0FF000000h
mov byte [edx+3], 0
ret

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List