is that normal ?Trond wrote:If you want to write really obfuscated code you can use this:Code: Select all
a-a-a
if i do the same with a C compiler (a -= a - a) a doesn't change.
it's like a -= 0
Dri

is that normal ?Trond wrote:If you want to write really obfuscated code you can use this:Code: Select all
a-a-a
Its normal, because the PBCompiler replace "a-" with "a=a-" -> "a=a-a-a" and this is like "a=-a"Dr. Dri wrote:is that normal ?Trond wrote:If you want to write really obfuscated code you can use this:Code: Select all
a-a-a
if i do the same with a C compiler (a -= a - a) a doesn't change.
it's like a -= 0
Dri
Code: Select all
a -= a-a
Code: Select all
a = a - (a-a)
Code: Select all
a = a - a + a = a
Code: Select all
a-a-a
Code: Select all
a = a-a-a = 0-a = -a
Code: Select all
a -= a-a (C)
Code: Select all
a-a-a (PB)
Code: Select all
a-(a-a)
That's not true!variable - expression:
The value of the expression is subtracted from variable
Code: Select all
a = 10
debug a-1-1
Everyone seems a bit confused. I can assure that everything is normal and working fine. (Well, actually the manual is a small bit inconsistent with itself.)Froggerprogger wrote:Hey, you're right!
The helpfile is inconsistent to the implementation there.
It says (in translation from German):That's not true!variable - expression:
The value of the expression is subtracted from variablegives 8, not 10, though the value of the 'expression' is 1-1 = 0Code: Select all
a = 10 debug a-1-1
It would be nice to update the docs there, but not change the behaviour.
I find it intuitive and would expect, that the expression a-1-1 gives 8 here, as well I would expect a -= 1-1 to result in 10.
Code: Select all
a-a
Code: Select all
a-a-a
Code: Select all
a-1-1
Code: Select all
variable - expression
you point the problem... if "-" is the first operator, then it's also an assignment operator. this is the same behavior with others operators (- * / % & |...)Trond wrote:Let's say a is 5. That gives us this expression: 5-5-5. Obviously, the result should be -5. Since there is no assignment operator, the result is put into the first of the variables on the left side. A therefore equals -5 after execution.Code: Select all
a-a-a
Dr. Dri wrote:asm output code (/commented)
working "inlined" asm codeCode: Select all
; a = -a MOV ebx,dword [v_a] NEG ebx MOV dword [v_a],ebx
I think "NEG a" is faster than using ebx but maybe i'm wrong... It may be optimized as "a + 1" becomes "INC a".Code: Select all
a = 1 !NEG [v_a] Debug a
Dri
Heeeyy...Fred wrote:True, it can be easily optimized, i put it on the todo list
Code: Select all
a*-1
Code: Select all
a/-1
Dr. Dri wrote:asm output code (/commented)
working "inlined" asm codeCode: Select all
; a = -a MOV ebx,dword [v_a] NEG ebx MOV dword [v_a],ebx
I think "NEG a" is faster than using ebx but maybe i'm wrong... It may be optimized as "a + 1" becomes "INC a".Code: Select all
a = 1 !NEG [v_a] Debug a
Dri
Still not done in PB4.0Fred wrote:True, it can be easily optimized, i put it on the todo list