Jump to content

  • Log In with Google      Sign In   
  • Create Account

Assembly confusion


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 fanaticlatic   Members   -  Reputation: 473

Like
0Likes
Like

Posted 13 September 2012 - 11:46 AM

Hi all,

I am having trouble understanding why a movq instruction is putting NULL in mm0 when trying to set the source operand of the instruction using a look up table?

I already posted the question here on daniweb as it's got a specific assembly forum:
http://www.daniweb.com/software-development/assembly/threads/433670/lookup-table-confusion

If anyone can provide any help here though I would be grateful as I am totally stumped at the minute.


Thanks in advance,

MarkH.
"I have more fingers in more pies than a leper at a bakery!"

Sponsor:

#2 kd7tck   Members   -  Reputation: 719

Like
1Likes
Like

Posted 14 September 2012 - 02:16 AM

Are you first compiling to assembly from C?



The reason I ask is because
static const unsigned short CoefficientsRGBU[256][4] = {
is not assembly.


This is only a hunch I got, so stay with me here.
Convert the following code in C with -S first.
static const unsigned short CoefficientsRGBU[256][4] = {
{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0},...
{14465, 62734, 0, 0}, {14465, 62734, 0, 0}, {14465, 62734, 0, 0}, {14465, 62734, 0, 0}};
Then modify the output, add the following to the end.
movq mm0, [ (_CoefficientsRGBU_ + offset) + 8 * eax ]

If I am totally off base with this hunch then please post back with more info.

#3 fanaticlatic   Members   -  Reputation: 473

Like
0Likes
Like

Posted 17 September 2012 - 03:16 AM

Hi,

Thanks for the response.

Are you first compiling to assembly from C?

The reason I ask is because

static const unsigned short CoefficientsRGBU[256][4] = {
is not assembly.


Well it's C++ with the function wrapped in an extern "C" {} scope. The function contains inline assembley statement __asm{} all compiled/written with the VS2005 IDE. The lookup tables are defined within the extern "C" scope.

This is only a hunch I got, so stay with me here.
Convert the following code in C with -S first.

static const unsigned short CoefficientsRGBU[256][4] = {
{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0},...
{14465, 62734, 0, 0}, {14465, 62734, 0, 0}, {14465, 62734, 0, 0}, {14465, 62734, 0, 0}};
Then modify the output, add the following to the end.
movq mm0, [ (_CoefficientsRGBU_ + offset) + 8 * eax ]

If I am totally off base with this hunch then please post back with more info.


-S is a GCC compile flag I believe, so won't be much use for me with VS 2005 and the Microsoft C/C++ compiler.

There may be something in the underscored name of the lookup table as that's the way the assembly converter must be called when the converter is not inlined but the function is provided in a seperate .asm file.


I'll have another play around and if anything drops I shall post back here. Thanks again and if anyone else can shed more light on this I will be grateful.

MarkH.
"I have more fingers in more pies than a leper at a bakery!"

#4 bmarci   Members   -  Reputation: 400

Like
0Likes
Like

Posted 19 September 2012 - 06:37 AM

Hi,

I am having trouble understanding why a movq instruction is putting NULL in mm0 when trying to set the source operand of the instruction using a look up table?


Long time no coding in assembly, but as far as I know mmx instructions require a certain alignment of data.
Make sure your lookup table is aligned to 16 or maybe 8 bytes.
Just an idea :)




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS