FilterFactory - Function "sin"

Back to function listing

Sine function of x, where x is an integer between 0 and 1024, inclusive, and the value returned is an integer between -512 and 512, inclusive (Windows) or -1024 and 1024, inclusive (Mac OS)

Click here for a diagram of sin, cos, tan

Syntax

sin(x)

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

58 pop eax (param_x)
2D 00 01 00 00 sub eax,$00000100 (256)
8B D8 mov ebx,eax
C1 FB 1F sar ebx,$1f (31)
33 C3 xor eax,ebx
2B C3 sub eax,ebx
25 FF 03 00 00 and eax,$000003ff (1023)
0F BF 84 47 78 05 00 00 movsx eax,[edi+eax*2+$00000578] (COS_LOOKUP)
C1 F8 05 sar eax,$05 (5)
50 push eax

C++ code

int factory_sin(int parm) {
	return factory_cos(parm - 256);
}