Using modern compiler optimizations it suggests that doing something like this:
Code:
int32_t val1 = 1234;
int32_t val2 = -val1;
Translates to:
Code:
mov [ebp+var_4], 4D2h
mov eax, [ebp+var_4]
neg eax
mov [ebp+var_4], eax
which is what mcp suggested in his first suggestion. If you write the code out as:
Code:
int32_t val1 = 1234;
val1 *= -1;
It also optimizes to the first suggestion.