Sign in to follow this  
fanaticlatic

Assembly confusion

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Are you first compiling to assembly from C?



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


This is only a hunch I got, so stay with me here.
Convert the following code in C with -S first.
[CODE]
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}};
[/CODE]
Then modify the output, add the following to the end.
[CODE]movq mm0, [ (_CoefficientsRGBU_ + offset) + 8 * eax ][/CODE]

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

Share this post


Link to post
Share on other sites
Hi,

Thanks for the response.

[quote name='kd7tck' timestamp='1347610580' post='4979996']
Are you first compiling to assembly from C?

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

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.

[quote name='kd7tck' timestamp='1347610580' post='4979996']
This is only a hunch I got, so stay with me here.
Convert the following code in C with -S first.
[CODE]
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}};
[/CODE]
Then modify the output, add the following to the end.
[CODE]movq mm0, [ (_CoefficientsRGBU_ + offset) + 8 * eax ][/CODE]

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

-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.

Share this post


Link to post
Share on other sites
Hi,

[quote name='fanaticlatic' timestamp='1347558389' post='4979789']
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?
[/quote]

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 :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this