flat assembler
Message board for the users of flat assembler.
Index
> Main > fasm & vb Goto page Previous 1, 2 |
Author |
|
jmcclane1 17 Aug 2021, 18:07
But that way you can't call a function from c# or vb
I don't know what you mean? |
|||
17 Aug 2021, 18:07 |
|
jmcclane1 18 Aug 2021, 01:17
Why doesn't the 64 bit version work? The result is 0...but 32 bit work's ok!
Now I tried to multiply 4x4 matrices? Can help in advance thanks! Code: ;64 ;<DllImport(AsmLib, EntryPoint:="MatrixMultiply", CharSet:=CharSet.Auto, CallingConvention:=CallingConvention.StdCall)> ;Public Shared Sub MatrixMultiply(ByRef MD As Matrix, ByVal MA As Matrix, ByVal MB As Matrix) ;End Sub proc MatrixMultiply MatrixD, MatrixA, MatrixB mov rax,[MatrixD] ; Matrix Dest mov rdx,[MatrixB] ; Matrix B mov rcx,[MatrixA] ; Matrix A movups xmm4,[rdx+00] ; [b3 b2 b1 b0] wzyx movups xmm5,[rdx+16] ; [b7 b6 b5 b4] wzyx movups xmm6,[rdx+32] ; [bB bA b9 b8] wzyx movups xmm7,[rdx+48] ; [bF bE bD bC] wzyx i = 0 repeat 4 movups xmm0,[rcx+i*16] ; [a3 a2 a1 a0] wzyx movaps xmm1,xmm0 movaps xmm2,xmm0 movaps xmm3,xmm0 shufps xmm0,xmm0,0x00 ; [a0 a0 a0 a0] shufps xmm1,xmm1,0x55 ; [a1 a1 a1 a1] shufps xmm2,xmm2,0xAA ; [a2 a2 a2 a2] shufps xmm3,xmm3,0xFF ; [a3 a3 a3 a3] mulps xmm0,xmm4 ; [a0*b3 a0*b2 a0*b1 a0*b0] mulps xmm1,xmm5 ; [a1*b7 a1*b6 a1*b5 a1*b4] mulps xmm2,xmm6 ; [a2*bB a2*bA a2*b9 a2*b8] mulps xmm3,xmm7 ; [a3*bF a3*bE a3*bD a3*bC] addps xmm2,xmm0 addps xmm3,xmm1 addps xmm3,xmm2 movups [rax+i*16],xmm3 ; [d3 d2 d1 d0] wzyx i = i + 1 end repeat ret endp Code: ;32 proc MatrixMultiply MatrixD, MatrixA, MatrixB mov eax,[MatrixD] ; Matrix Dest mov edx,[MatrixB] ; Matrix B mov ecx,[MatrixA] ; Matrix A movups xmm4,[edx+00] ; [b3 b2 b1 b0] wzyx movups xmm5,[edx+16] ; [b7 b6 b5 b4] wzyx movups xmm6,[edx+32] ; [bB bA b9 b8] wzyx movups xmm7,[edx+48] ; [bF bE bD bC] wzyx i = 0 repeat 4 movups xmm0,[ecx+i*16] ; [a3 a2 a1 a0] wzyx movaps xmm1,xmm0 movaps xmm2,xmm0 movaps xmm3,xmm0 shufps xmm0,xmm0,0x00 ; [a0 a0 a0 a0] shufps xmm1,xmm1,0x55 ; [a1 a1 a1 a1] shufps xmm2,xmm2,0xAA ; [a2 a2 a2 a2] shufps xmm3,xmm3,0xFF ; [a3 a3 a3 a3] mulps xmm0,xmm4 ; [a0*b3 a0*b2 a0*b1 a0*b0] mulps xmm1,xmm5 ; [a1*b7 a1*b6 a1*b5 a1*b4] mulps xmm2,xmm6 ; [a2*bB a2*bA a2*b9 a2*b8] mulps xmm3,xmm7 ; [a3*bF a3*bE a3*bD a3*bC] addps xmm2,xmm0 addps xmm3,xmm1 addps xmm3,xmm2 movups [eax+i*16],xmm3 ; [d3 d2 d1 d0] wzyx i = i + 1 end repeat ret endp Last edited by jmcclane1 on 18 Aug 2021, 02:27; edited 1 time in total |
|||
18 Aug 2021, 01:17 |
|
revolution 18 Aug 2021, 01:32
Exactly the same problem as before. The first parameters are not on the stack in 64-bit mode, they are in registers.
This code below is wrong, you need to use the registers. Code: mov rax,[MatrixD] ; Matrix Dest mov rdx,[MatrixB] ; Matrix B mov rcx,[MatrixA] ; Matrix A |
|||
18 Aug 2021, 01:32 |
|
Goto page Previous 1, 2 < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.