- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Could someone please point out what the problem is with the following snippet. An exception occurs in MSVC.
__m128i R0, R1;
__m128i *R0P1, *R0P2;
__m128i *R1P1, *R1P2;
char buf_chr[20] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't'
};
R0 = _mm_loadu_si128((__m128i*) (buf_chr));
R1 = _mm_loadu_si128((__m128i*) (buf_int));
R0P1 = (__m128i *) (buf_chr);
R0P2 = (__m128i *) (buf_chr);
R0 = _mm_add_epi8(R0, R1);
*R0P1 = _mm_add_epi8((__m128i) *R0P1, (__m128i) *R0P2); // ---------> Exception occurs here.
Is there a way to do the addition if I have a register used as a pointer. Can de-referencing be done by using *? This question arises because the following statements pass without incident!
R0P1++;
R0P2++;
Thanks and Regards
Deepak
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My dear friend that is not a problemsince I have used an unaligned load instruction. Please assume everything is right with respect to the buffer. Please read my question with regard to the use of a register as a pointer. What is the possibility to access the content pointed to by the register. I am also working on it and shall get back to you soon.
Thanks and Regards
Deepak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I know how to use debugger. And in debugger I see that your line
*R0P1 = _mm_add_epi8((__m128i) *R0P1, (__m128i) *R0P2);
is translated to
movdqa xmm0,xmmword ptr [eax]
[..skipped..]
paddb xmm1,xmm0
Guess where exception happens if eax is not 16B aligned?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
__m128i* R0P1;
Register1 =_mm_loadu_si128(R0P1);
You are right *R0P1 works if the buffer pointed to by R0P1 is aligned to a 16 byte boundary.
Register1 = *R0P1;
Follow up question: What if it is not an aligned address?Can we use the *operator to get the contents.
Regards
Deepak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page