Click here to Skip to main content
15,912,400 members

Comments by Charles Keepax (Top 4 by date)

Charles Keepax 7-Oct-10 4:27am View    
Your variables r0-r4 are effectively arrays of 4 16-bit numbers; a 16-bit number can only be 0 to 65536 or -32768 to 32767 since you are using signed variables. 6,000,000 is too large to store in a 16-bit number, thus you will need to extract it into a 32-bit number. The following code (assuming int is 32-bit on your system) does this with the first number however it is almost certainly a poor way to use the MMX extensions, but the best way to use them would depend rather heavily on context.

unsigned short B[4]={2000,2000,2000,2000};
unsigned short C[4]={3000,3000,3000,3000};
unsigned short D[4]={0,0,0,0};
unsigned short E[4]={0,0,0,0};
__m64*b =(__m64*)B;
__m64*c =(__m64*)C;
__m64*d =(__m64*)D;
__m64*e =(__m64*)E;

*d =_mm_mullo_pi16(*b,*c);
*e =_mm_mulhi_pi16(*b,*c);

int temp = E[0];
temp = (temp<<16) | D[0];
Charles Keepax 5-Oct-10 9:19am View    
That would be about right, you need to stick them together to get your answer. So 36224 in hex is 0x8D80 and 91 in hex is 0x5B. Shift the hi result by 16 bits then AND them together and you will get 0x5B8D80, which is hex for 6000000.
Charles Keepax 29-May-10 18:47pm View    
Distance from the camera would also play a fairly large factor in that as well.
Charles Keepax 27-May-10 2:49am View    
Glad that helps, should be the only problem and it should work perfectly after you fix it.