To compute the norm of a three-dimensional vector in PB (all variables are Single):
To do it using the floating point processor:
But this assembly code is literally no faster than PB. Is there a faster way?
Code:
v = Sqr(x*x + y*y + z*z)
Code:
Macro Norm3(v,x,y,z) ! fld x 'push X onto stack ! fld st(0) 'push it again ! fmul 'stack top = product ! fld y 'push Y onto stack ! fld st(0) 'push it again ! fmul 'stack top = product ! fld z 'push Z onto stack ! fld st(0) 'push it again ! fmul 'stack top = product ! fadd 'stack top = sum of last two ! fadd 'sum of that with last ! fsqrt 'stack top = sqr of that ! fstp v 'copy stack top to result and pop stack End Macro
Comment