About evallib :
The assign() function is used to move a value in a given variable, returning this same value. May be some other functions like this one can be added :
- add(a,b) for a = a + b
- sub(a,b) for a = a - b
- mul(a,b) for a = a * b
- div(a,b) for a = a / b
and, by extension :
- inc(a) for a = a + 1
- dec(a) for a = a - 1
These will be very useful in loop(), exec2() or exec3() ...
About AVS interface
I don't know if I am the only one who tried to make a translation of AVS screens, but, if it's quite easy as long it is in the resources, it's almost impossible when strings are melted in binary (for example, all the online help !).
Please, in the next version, can we have ALL STRINGS in resource's ... string.
About resources, I read in the current wishlist something about missing version string. There is a version string. Its value is currently 2.7.9.2 🙁
Some ideas ...
6 posts
Couldn't you just use assign(a,a+b), assign(a,a-b), etc for that?
Anyway, check out Tomylobo's AVSTrans code tool for making readable code.
Anyway, check out Tomylobo's AVSTrans code tool for making readable code.
Of course, I can ! But I can also simulate arrays without megabuf() 😉
I suggested these functions for two reasons : I think it's more concise, so more readable, and functions like these are closer to machine code and may generate a more efficient code ...
I suggested these functions for two reasons : I think it's more concise, so more readable, and functions like these are closer to machine code and may generate a more efficient code ...
that's what i would write in ASM for a=b+c:
unlike integer values, floating point values have to be loaded to the fpu's registers to manipulate them
for integers that'd be true and you could write
in this case it is a bit more efficient but as all variables in AVS are floating point variables, your suggestion wouldn't make it faster
and here's what i would do for add(a,b):
ffree st(7) // empty lower register to make room for c
fld c // load c
ffree st(7) // empty lower register to make room for b
fld b // load b
fadd st,st(1)// add the 2 values
fst a // store result in a
That's nearly the same code, you see?
ffree st(7) // empty lower register to make room for b
fld b // load b
ffree st(7) // empty lower register to make room for a
fld a // load a
fadd st,st(1)// add the 2 values
fst a // store result in a
unlike integer values, floating point values have to be loaded to the fpu's registers to manipulate them
for integers that'd be true and you could write
for add(a,b) and
mov eax,b
add a,eax
for a=b+c
mov eax,c
add eax,b
mov a,eax
in this case it is a bit more efficient but as all variables in AVS are floating point variables, your suggestion wouldn't make it faster
Ooops ... I become too old 🙂
I always thought about integers only ( see inc() and dec() 😉 ).
In both cases, the binary code will be exactly the same (with a good compiler, of course).
So, forget this part of my wish ...
I always thought about integers only ( see inc() and dec() 😉 ).
In both cases, the binary code will be exactly the same (with a good compiler, of course).
So, forget this part of my wish ...
btw add these lines to your code and let AVSTrans translate it and you can use add/sub/mul/div/divr(var,value) and inc/dec(var)
some examples:
this means subr(a,b) is the same as
a=b-a
while sub(a,b) means
a=a-b
the only problem is: these add/sub/mul/div/divr here don't support commas in the first parameter and don't support brackets in the second parameter 🙁 if you need to use them , try square brackets... AVSTrans automatically converts these to round brackets after the translation.
//$AVSTrans_Replacement_Pattern=add\(([^,]+),([^\)]+)\)->assign($1,$1+$2)
//$AVSTrans_Replacement_Pattern=sub\(([^,]+),([^\)]+)\)->assign($1,$1-$2)
//$AVSTrans_Replacement_Pattern=subr\(([^,]+),([^\)]+)\)->assign($1,$2-$1)
//$AVSTrans_Replacement_Pattern=mul\(([^,]+),([^\)]+)\)->assign($1,$1*$2)
//$AVSTrans_Replacement_Pattern=div\(([^,]+),([^\)]+)\)->assign($1,$1/$2)
//$AVSTrans_Replacement_Pattern=divr\(([^,]+),([^\)]+)\)->assign($1,$2/$1)
//$AVSTrans_Replacement_Pattern=inc\(([^\)]+)\)->assign($1,$1+1)
//$AVSTrans_Replacement_Pattern=dec\(([^\)]+)\)->assign($1,$1-1)
some examples:
subr/divr are backwards subtraction/division
add(x,0.3); => assign(x,x+0.3);
subr(iy,[1-i]*5); => assign(iy,(1-i)*5-iy);
this means subr(a,b) is the same as
a=b-a
while sub(a,b) means
a=a-b