FilterFactory - Function "mix"

Back to function listing

Mixture of a and b by fraction n/d.

The definition is: a*n/d+b*(d-n)/d

Syntax

mix(a,b,n,d)

Original Machine Code (in OPER resource) of Filter Factory 3.0 and 3.0.4 for Photoshop/Win32

5B pop ebx (param_d) .
59 pop ecx (param_n) .
5A pop edx (param_b) .
5E pop esi (param_a) .
0B DB or ebx,ebx .
B8 00 00 00 00 mov eax,$00000000 (0) res = 0;
74 12 jz +$12 (@@1) if (param_d == 0) goto @@1; // return 0
8B C3 mov eax,ebx res = param_d;
2B C1 sub eax,ecx res -= param_n;
F7 EA imul edx res *= param_b;
F7 FB idiv ebx res /= param_d;
8B E8 mov ebp,eax ebp = res;
8B C1 mov eax,ecx res = param_n;
F7 EE imul esi res *= param_a;
F7 FB idiv ebx res /= param_d;
03 C5 add eax,ebp res += ebp; // res = param_n * param_a / param_d + (param_d - param_n) * param_b / param_d
@@1: @@1:
50 push eax return res;