Wednesday, March 05, 2008

Sigh - library problems

One the third party libraries I occasionally use is called zlib. It offers rudimentary compression capabilities. My upgrade to VS 2008 has been nothing but one headache after another. This latest headache was caused by the optional x86 MASM assembler module for zlib that drastically increases the performance of zlib. Hand-optimized assembler generally outperforms anything else but is tricky to get right in the first place.

Apparently, the optional zlib assembler integration module requires the now ancient and dead MASM32 assembler (remnants of Visual Studio 6 that I appear to have "migrated" to a later release of VS). This time around, VS 2008 includes its own version of MASM, which I didn't want to overwrite. So, the zlib build issued these errors:

inffas32.asm(594) : error A2070: invalid instruction operands
inffas32.asm(596) : error A2070: invalid instruction operands
inffas32.asm(610) : error A2070: invalid instruction operands
inffas32.asm(667) : error A2070: invalid instruction operands

It took hunting through a blog post in a Far Eastern language (probably Japanese) to figure out how to fix the problem. Edit inffas32.asm and change:

movd mm4, [esp + 0]

To:

movd mm4, dword ptr [esp + 0]

At which point, I said "duh" to myself, tried it out, and it worked. I know assembler and thought the line looked weird but couldn't pinpoint why. I figured I'd do my own blog post on this for two reasons:

1) The websites hosting various Chinese/Japanese language blogs are always ultra slow.
2) Not every programmer can "read between the lines". I didn't have to translate the blog to English to know precisely what was being said.

People complain about outsourcing but guess who is coming up with solutions to problems first? I frequently find the most interesting bits of code tucked away within foreign websites - particularly of the Japanese variety. I have never been to an Indian blog as a Google search result.

1 comment:

  1. Thanks for the very helpful post! I don't know a thing about ASM, so this was a big help.

    As an aside, that page is in Chinese (just run it through Google Translate on "Detect Language").

    ReplyDelete