Assembly trouble (not too complicated)

i had an assembly macro that i wrote that seems to compile at random. by that i mean that some places i put it will compile fine and work beautifully, and other places i put it wont compile at all. worst off all, they give really strange compiler errors.

i kept cutting things out to narrow down on the problem in one of the spots that it doesnt compile, and i ended up with this much non-compiling code:

Code:

__asm mov eax, val

this single, innocent line of code generates 6 compiler errors, all saying the same thing:

its C++, but it only happens to function arguments. the name mangling-should apply equally to all variables.

does this have something to do with the stack? from what i understand, you can access stack elements the same way you access normal memory if you have the address of them. i didn't think that would be a problem. and the newline thing doesnt seem to be sensical. like i said, i can copy and paste that exact line of code and have it use a non-argument variable and it works perfectly fine, so there is nothing wrong with the code itself from what i can tell.

You compiler is not parsing the line correctly so it is also not invoking the inline assembler. Since the compiler cannot compile the line it sees the end of line or new line character at the end of it and that is prob where your error is coming from. It's basically saying it cannot compile the line prior to the newline it has encountered.

i see what you are saying, but you are missing the point. it always fails whenever i am using a function argument, and only then.

this code:

Code:

__asm
{
mov eax, val
}

generates the same error as this code:

Code:

__asm mov eax, val

or even this one:

Code:

{
__asm
{
mov eax, val
}
}

and both lines of code work perfectly fine if val is not a function argument, be it local, global, or otherwise, and placing semicolons after the single line or the ending brackets does not fix the problem.

in summation:
it is only function arguments that cause this problem, and not the format of the line of code itself. the question still remains: why?

High probably extracts the high order bits from a WORD or DWORD and is probably pre-defined in your inline assembler. Look at the keywords that have been used in your inline assembler and you can answer this question.

But you have not given us enough info. All I see in your code examples is var, not high. Where did high come from?