Assembly confusion

Started by
2 comments, last by bmarci 11 years, 7 months ago
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!"
Advertisement
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.
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!"
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 :)

This topic is closed to new replies.

Advertisement