0

I'm trying to convert an old project I worked on back in the year 2000 using MSVC6 to Visual Studio 2019. Its code for a "Rich Media" player.

The following code compiled fine under MSVC6

// CODEGENX86.H //

#define PLACEHOLDER_32 0xf0f00f0f

// CODEGENX86.C //

_asm jz PLACEHOLDER_32 

But now in VS2019 I get ...

"error C2415: improper operand type". 

I didn't write this code and I was never good at assembly. I'm hoping someone can explain to me why it worked under MSVC6 (seems to me it should NOT have worked there) and how I can get it to work under VS2019. As far as I can tell, the person who wrote this code was trying to put 4 bytes after jz which gets overwritten before the line executes.

  • You need to look at the surrounding code and figure out what this was trying to do. Is there some code involved that would change the offset (target address) of the jump? – 1201ProgramAlarm Mar 27 '20 at 03:04
  • 1
    Try `_asm jz $+0x0f0f0f0f`. My guess is that it just needs to avoid being a `jz short ...` with a one byte relative offset. I'm wondering about this code will work with Windows, if it is using Windows, since normally code can't be executed from the data segment, and the code segment is normally read-only. – rcgldr Mar 27 '20 at 05:23
  • The reason it doesn't assemble as written is: [How to write an absolute target for a near direct relative call/jmp in MASM](https://stackoverflow.com/q/50058523) - you apparently can't because of `.obj` relocation limitations. – Peter Cordes Mar 27 '20 at 07:53
  • Thanks rcgldr, it links now. It doesn't run the way if did under Windows 95 through XP so there is still an issue, but maybe I can at least debug it. And yes, this was code that worked on Windows 95 through Windows XP machines! I kludged together something that worked under Windows 7, but I wanted the correct answer! Thanks. Also thanks Mr. Cordes for your input. – Dwayne Daniels Mar 28 '20 at 01:53

0 Answers0