* paddw vs paddb
@ 2004-12-23 10:59 Ankit Jain
2004-12-24 9:01 ` Maciej Hrebien
0 siblings, 1 reply; 6+ messages in thread
From: Ankit Jain @ 2004-12-23 10:59 UTC (permalink / raw)
To: assembly
1 #include<stdio.h>
2 #include<inttypes.h>
3 int main()
4 {
5 uint8_t
a[8]={1,2,3,4,5,6,7,8},b[8]={1,2,3,4,5,6,7,8},i;
6 asm("movq (%1), %%mm0 \n"
7 "paddb (%0), %%mm0 \n"
8 "movq %%mm0, (%0) \n"
9 :
10 :"r"(b),"r"(a)
11 :"%mm0"
12 );
13 for(i=0;i<8;i++)
14 printf("%d ",b[i]);
15 return 0;
16 }
17
Both the programs give the same output
WHY IS IT SO? i am using paddb and paddw. it dosent
make any diff?
1 #include<stdio.h>
2 #include<inttypes.h>
3 int main()
4 {
5 uint8_t
a[8]={1,2,3,4,5,6,7,8},b[8]={1,2,3,4,5,6,7,8},i;
6 asm("movq (%1), %%mm0 \n"
7 "paddd (%0), %%mm0 \n"
8 "movq %%mm0, (%0) \n"
9 :
10 :"r"(b),"r"(a)
11 :"%mm0"
12 );
13 for(i=0;i<8;i++)
14 printf("%d ",b[i]);
15 return 0;
16 }
17
~
ankit jain
________________________________________________________________________
Yahoo! Messenger - Communicate instantly..."Ping"
your friends today! Download Messenger Now
http://uk.messenger.yahoo.com/download/index.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: paddw vs paddb
2004-12-23 10:59 paddw vs paddb Ankit Jain
@ 2004-12-24 9:01 ` Maciej Hrebien
2004-12-25 7:21 ` Ankit Jain
0 siblings, 1 reply; 6+ messages in thread
From: Maciej Hrebien @ 2004-12-24 9:01 UTC (permalink / raw)
To: linux-assembly
Ankit Jain wrote:
>
> 1 #include<stdio.h>
> 2 #include<inttypes.h>
> 3 int main()
> 4 {
> 5 uint8_t
> a[8]={1,2,3,4,5,6,7,8},b[8]={1,2,3,4,5,6,7,8},i;
> 6 asm("movq (%1), %%mm0 \n"
> 7 "paddb (%0), %%mm0 \n"
> 8 "movq %%mm0, (%0) \n"
> 9 :
> 10 :"r"(b),"r"(a)
> 11 :"%mm0"
> 12 );
> 13 for(i=0;i<8;i++)
> 14 printf("%d ",b[i]);
> 15 return 0;
> 16 }
> 17
> Both the programs give the same output
>
> WHY IS IT SO? i am using paddb and paddw. it dosent
> make any diff?
Insert to a or b value for which a[i]+b[i]>255 where i is odd
and you will see the difference, ie. a[7]=255.
--
Maciej Hrebien
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: paddw vs paddb
2004-12-24 9:01 ` Maciej Hrebien
@ 2004-12-25 7:21 ` Ankit Jain
2004-12-25 10:40 ` Maciej Hrebien
0 siblings, 1 reply; 6+ messages in thread
From: Ankit Jain @ 2004-12-25 7:21 UTC (permalink / raw)
To: m_hrebien; +Cc: assembly
thanks
but if u can solve one more problem
'a' is uint8_t type and i want to extract only 4 int
and store it as a word in mmx register
i am not able to understand that because movq is
extracting 8 bytes at a time.
actually the problem is overflow. saturation is not
tht helpfull
thanks
ankit jain
--- Maciej Hrebien <m_hrebien@wp.pl> wrote:
> Ankit Jain wrote:
> >
> > 1 #include<stdio.h>
> > 2 #include<inttypes.h>
> > 3 int main()
> > 4 {
> > 5 uint8_t
> > a[8]={1,2,3,4,5,6,7,8},b[8]={1,2,3,4,5,6,7,8},i;
> > 6 asm("movq (%1), %%mm0 \n"
> > 7 "paddb (%0), %%mm0 \n"
> > 8 "movq %%mm0, (%0) \n"
> > 9 :
> > 10 :"r"(b),"r"(a)
> > 11 :"%mm0"
> > 12 );
> > 13 for(i=0;i<8;i++)
> > 14 printf("%d ",b[i]);
> > 15 return 0;
> > 16 }
> > 17
> > Both the programs give the same output
> >
> > WHY IS IT SO? i am using paddb and paddw. it
> dosent
> > make any diff?
>
> Insert to a or b value for which a[i]+b[i]>255 where
> i is odd
> and you will see the difference, ie. a[7]=255.
>
> --
> Maciej Hrebien
>
> -
> To unsubscribe from this list: send the line
> "unsubscribe linux-assembly" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at
> http://vger.kernel.org/majordomo-info.html
>
________________________________________________________________________
Yahoo! Messenger - Communicate instantly..."Ping"
your friends today! Download Messenger Now
http://uk.messenger.yahoo.com/download/index.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: paddw vs paddb
2004-12-25 7:21 ` Ankit Jain
@ 2004-12-25 10:40 ` Maciej Hrebien
2004-12-29 12:12 ` Ankit Jain
0 siblings, 1 reply; 6+ messages in thread
From: Maciej Hrebien @ 2004-12-25 10:40 UTC (permalink / raw)
To: linux-assembly
Ankit Jain wrote:
>
> thanks
>
> but if u can solve one more problem
>
> 'a' is uint8_t type and i want to extract only 4 int
> and store it as a word in mmx register
>
> i am not able to understand that because movq is
> extracting 8 bytes at a time.
>
> actually the problem is overflow. saturation is not
> tht helpfull
I don't know if i understand your question right but for
32-bit transfers (4 bytes) you have MOVD instruction.
--
Maciej Hrebien
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: paddw vs paddb
2004-12-25 10:40 ` Maciej Hrebien
@ 2004-12-29 12:12 ` Ankit Jain
2004-12-29 22:40 ` Maciej Hrebien
0 siblings, 1 reply; 6+ messages in thread
From: Ankit Jain @ 2004-12-29 12:12 UTC (permalink / raw)
To: m_hrebien; +Cc: assembly
hi
i know about movd but i want to move 16bit atr a time
thanks
--- Maciej Hrebien <m_hrebien@wp.pl> wrote:
> Ankit Jain wrote:
> >
> > thanks
> >
> > but if u can solve one more problem
> >
> > 'a' is uint8_t type and i want to extract only 4
> int
> > and store it as a word in mmx register
> >
> > i am not able to understand that because movq is
> > extracting 8 bytes at a time.
> >
> > actually the problem is overflow. saturation is
> not
> > tht helpfull
>
> I don't know if i understand your question right but
> for
> 32-bit transfers (4 bytes) you have MOVD
> instruction.
>
> --
> Maciej Hrebien
>
> -
> To unsubscribe from this list: send the line
> "unsubscribe linux-assembly" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at
> http://vger.kernel.org/majordomo-info.html
>
________________________________________________________________________
Yahoo! Messenger - Communicate instantly..."Ping"
your friends today! Download Messenger Now
http://uk.messenger.yahoo.com/download/index.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: paddw vs paddb
2004-12-29 12:12 ` Ankit Jain
@ 2004-12-29 22:40 ` Maciej Hrebien
0 siblings, 0 replies; 6+ messages in thread
From: Maciej Hrebien @ 2004-12-29 22:40 UTC (permalink / raw)
To: linux-assembly
Ankit Jain wrote:
>
> hi
>
> i know about movd but i want to move 16bit atr a time
You can't move a word to a mmx register directly. You have to
simulate it ie. with a temp ored with the destination register:
pxor %mm7,%mm7
xor %eax,%eax
movw your_word,%ax
movd %eax,%mm7
por %mm7,%mm0
which moves your_word to the lowest part of mm0 and you have
to be sure that low word of mm0 is zeroed before the operation.
Or you can:
movd %mm0,%eax
movw your_word,%ax
movd %eax,%mm0
etc. but i don't recomend this kind of coding. Keep your words
together and use movq.
--
Maciej Hrebien
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2004-12-29 22:40 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-12-23 10:59 paddw vs paddb Ankit Jain
2004-12-24 9:01 ` Maciej Hrebien
2004-12-25 7:21 ` Ankit Jain
2004-12-25 10:40 ` Maciej Hrebien
2004-12-29 12:12 ` Ankit Jain
2004-12-29 22:40 ` Maciej Hrebien
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).