|
Subject:
|
inline assembly on VS2005 c++ PROBLEM
|
|
Posted By:
|
Huskey
|
Post Date:
|
1/24/2007 9:58:40 AM
|
Hi!
I am just beginning my adventure with inline assembler and I encountered a problem. I tried to find some solution through google, but after a long time with no success I decided to write here. My problem is as follows: I am writing an application to blur images with box-blur; I have to load a bitmap and do some operation with it. I thought I would use SSE2 as it would speed-up my progam. I have two structs __declspec(align(0x4)) struct ARGB{ //__m128 m; char r; char g; char b; char a; };
__declspec(align(0x10)) struct pixel4{ //__m128; ARGB p[4]; }; and I store the data in an array: input = (pixel4*) _aligned_malloc(sizeof(pixel4)*length, 0x10); Now I would like to load the first 128 bits ( in C++ input[0] ) into an xmm register:
MOV esi, input; MOVAPS xmm0, XMMWORD PTR [esi];
but it won't work. I get an access violation error at line MOVAPS... .
I did watch the esi register in debug mode. Its value is 44 (0x0000002c) and I get this error msg:
Unhandled exception at 0x0043deec in testBMP.exe: 0xC0000005: Access violation reading location 0xffffffff.
Shouldn't it be access violation at 0x0000002c ? (Maybe I'm wrong, but I'm no expert - just a beginner, so excuse me :) )
Another thing I noticed is that the esi register contains the value 0x0000002c which is NOT dividable by 16 :/ it's also weird to me, because I used _aligned_malloc with 0x10 (16) to allocate 'input'; so after MOV esi, input esi should store the address to input which should be divisible by 16 (should have a zero at the end of its address in hex) and it it not :(
I also tried the following code:
MOV esi, [input]; MOVAPS xmm0, XMMWORD PTR [esi]
and I tried MOVUPS the same way as well - it still wouldn't work. What did compile was: MOV esi, [input]; MOVAPS xmm0, esi; but I don't think it gives the result I want to get...
If anyone could help I would be grateful!
Kind Regards,
|
|