proc StagingR ;(NumButter.l)
;MOV eax, [esp + 4]
;SHL eax, 1
;MOV [Staging_StageSize], eax
XOR ecx, ecx

RepLoopR:
  FLD1
  FLDZ
  MOV [Staging_xLong1], ecx
  MOV eax, ecx
  ADD eax, [esp + 4] ;[esp + 4]
  MOV [Staging_xLong2], eax
ForLoopR:
    MOV eax, ecx  ; !! before push esp!
    ADD eax, [esp + 4]
    SHL eax, 3 ; * 8
    ADD eax, RIValues2 ; -> eax = Values(xLong2 + NumButter)\Real
    MOV edx, ecx
    SHL edx, 3 ; * 8
    ADD edx, RIValues2 ; -> edx = Values(xLong2)\Real
;state:
    FLD dword [eax] ;
    FMUL ST, ST2
    FLD dword [eax + 4] ;+1!
    FMUL ST, ST2
    FSUBP
;state:
    FLD dword [eax]
    FMUL ST, ST2
    FLD dword [eax + 4] ;+!
    FMUL ST, ST4
    FADDP
;state:
    FLD dword [edx + 4]
    FSUB ST, ST1
    FSTP dword [eax + 4]
    FADD dword [edx + 4]
    FSTP dword [edx + 4]
;state:
    FLD dword [edx]
    FSUB ST, ST1
    FSTP dword [eax]
    FADD dword [edx]
    FSTP dword [edx]
    FLD ST
;state:
    FLD ST4
    FMUL ST, ST2
    FSUBP ST2, ST
    FLD ST3
    FMUL ST, ST3
    FADDP ST2, ST
;state:
    FMUL ST, ST3
    FLD ST4
    FMUL ST, ST3
    FSUBP ST3, ST
    FSUBP ST2, ST
    INC ecx
    CMP ecx, [Staging_xLong2]
    JNE ForLoopR
  FSTP ST
  FSTP ST
  MOV ecx, [Staging_xLong1]
  ADD ecx, [Staging_StageSize]
  CMP ecx, $800 ; #NumSamplesIntX + 1/ 2047+1
  JB RepLoopR
FSTP ST ;2i
FSTP ST ;2r
RET 4
endp