Archive: Some ideas ...


29th April 2004 22:23 UTC

Some ideas ...
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 :(


29th April 2004 22:48 UTC

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.


30th April 2004 11:05 UTC

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 ...


30th April 2004 12:15 UTC

that's what i would write in ASM for a=b+c:


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


and here's what i would do for add(a,b):

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

That's nearly the same code, you see?
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

mov eax,b
add a,eax

for add(a,b) and

mov eax,c
add eax,b
mov a,eax

for a=b+c
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

30th April 2004 13:36 UTC

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 ...


1st May 2004 09:46 UTC

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)


//$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)

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.

some examples:

add(x,0.3); => assign(x,x+0.3);
subr(iy,[1-i]*5); => assign(iy,(1-i)*5-iy);

subr/divr are backwards subtraction/division
this means subr(a,b) is the same as
a=b-a
while sub(a,b) means
a=a-b