FilterFactory - Function "scl"

Scale a from input range (il to ih) to output range (ol to oh)

Back to function listing

Syntax

scl(a,il,ih,ol,oh)

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

8B 6C 24 08 mov ebp,[esp+$08] (param_ih) .
8B 4C 24 0C mov ecx,[esp+$0c] (param_il) .
2B E9 sub ebp,ecx param_ih -= param_il;
8B C5 mov eax,ebp eax = param_ih;
74 15 jz +$15 (@@1) if (param_ih == 0) goto @@1; // return 0
8B 04 24 mov eax,[esp] (param_oh) eax = param_oh;
8B 74 24 04 mov esi,[esp+$04] (param_ol) .
2B C6 sub eax,esi eax -= param_ol;
8B 54 24 10 mov edx,[esp+$10] (param_a) .
2B D1 sub edx,ecx .
F7 EA imul edx eax *= param_a - param_il;
F7 FD idiv ebp eax /= param_ih;
03 C6 add eax,esi eax += param_ol; // eax = (param_oh - param_ol) * (param_a - param_il) / param_ih + param_ol
@@1: @@1:
83 C4 14 add esp,$14 (= 5x pop) .
50 push eax return eax;