ホーム 道しるべ 憩いの広場 濃緑空間 濃緑研の日記

座標変換に挑戦
ホーム ] 上へ ] Float to Fixed ] Normalize ] Fixed to Float ] Adjust Point ] [ 座標変換に挑戦 ]

 

bulletとりあえず、コードだけ。思ったほど速くない、PentiumIIで走らせた方が速い、何故?

だいたい演算用レジスタがeaxebx,ecx,edxの4個では(しかも固定小数点の場合eaxとedxはペアのアキュームレータとなるし、ebx,ecxは配列データへのポインタの役割も持たせないといけないし。

もしかして、esi、edi以外にも使えるレジスタがあったりして(もう少し調べてみます)。


mtrxi2(long a[4], long b[4][4], long c[4])
{
//        c[0] = a[0]*b[0][0] + a[1]*b[0][1] + a[2]*b[0][2] + a[3]*b[0][3];
//        c[1] = a[0]*b[1][0] + a[1]*b[1][1] + a[2]*b[1][2] + a[3]*b[1][3];
//        c[2] = a[0]*b[2][0] + a[1]*b[2][1] + a[2]*b[2][2] + a[3]*b[2][3];
//        c[3] = a[0]*b[3][0] + a[1]*b[3][1] + a[2]*b[3][2] + a[3]*b[3][3];
    _asm {
        mov         edi,a             // edi = 配列a[0]のアドレス
        mov         ebx,b             // ebx = 配列b[0][0]のアドレス
        mov         esi,c             // ecx = 配列c[0]のアドレス
        mov         eax,[edi]
        imul    DWORD PTR [ebx]
        mov         ecx,edx
        mov         eax,[edi+4]
        imul    DWORD PTR [ebx+4]
        add         ecx,edx
        mov         eax,[edi+8]
        imul    DWORD PTR [ebx+8]
        add         ecx,edx
        mov         eax,[edi+12]
        imul    DWORD PTR [ebx+12]
        add         ecx,edx
        mov         [esi],ecx

        mov         eax,[edi]
        imul    DWORD PTR [ebx+16]
        mov         ecx,edx
        mov         eax,[edi+4]
        imul    DWORD PTR [ebx+20]
        add         ecx,edx
        mov         eax,[edi+8]
        imul    DWORD PTR [ebx+24]
        add         ecx,edx
        mov         eax,[edi+12]
        imul    DWORD PTR [ebx+28]
        add         ecx,edx
        mov         [esi+4],ecx        

        mov         eax,[edi]
        imul    DWORD PTR [ebx+32]
        mov         ecx,edx
        mov         eax,[edi+4]
        imul    DWORD PTR [ebx+36]
        add         ecx,edx
        mov         eax,[edi+8]
        imul    DWORD PTR [ebx+40]
        add         ecx,edx
        mov         eax,[edi+12]
        imul    DWORD PTR [ebx+44]
        add         ecx,edx
        mov         [esi+8],ecx

        mov         eax,[edi]
        imul    DWORD PTR [ebx+48]
        mov         ecx,edx
        mov         eax,[edi+4]
        imul    DWORD PTR [ebx+52]
        add         ecx,edx
        mov         eax,[edi+8]
        imul    DWORD PTR [ebx+56]
        add         ecx,edx
        mov         eax,[edi+12]
        imul    DWORD PTR [ebx+60]
        add         ecx,edx
        mov         [esi+12],ecx
    }
}