Current version

v1.10.4 (stable)

Navigation

Main page
Archived news
Downloads
Documentation
   Capture
   Compiling
   Processing
   Crashes
Features
Filters
Plugin SDK
Knowledge base
Donate
Contact info
Forum
 
Other projects
   Altirra

Search

Archives

01 Dec - 31 Dec 2013
01 Oct - 31 Oct 2013
01 Aug - 31 Aug 2013
01 May - 31 May 2013
01 Mar - 31 Mar 2013
01 Feb - 29 Feb 2013
01 Dec - 31 Dec 2012
01 Nov - 30 Nov 2012
01 Oct - 31 Oct 2012
01 Sep - 30 Sep 2012
01 Aug - 31 Aug 2012
01 June - 30 June 2012
01 May - 31 May 2012
01 Apr - 30 Apr 2012
01 Dec - 31 Dec 2011
01 Nov - 30 Nov 2011
01 Oct - 31 Oct 2011
01 Sep - 30 Sep 2011
01 Aug - 31 Aug 2011
01 Jul - 31 Jul 2011
01 June - 30 June 2011
01 May - 31 May 2011
01 Apr - 30 Apr 2011
01 Mar - 31 Mar 2011
01 Feb - 29 Feb 2011
01 Jan - 31 Jan 2011
01 Dec - 31 Dec 2010
01 Nov - 30 Nov 2010
01 Oct - 31 Oct 2010
01 Sep - 30 Sep 2010
01 Aug - 31 Aug 2010
01 Jul - 31 Jul 2010
01 June - 30 June 2010
01 May - 31 May 2010
01 Apr - 30 Apr 2010
01 Mar - 31 Mar 2010
01 Feb - 29 Feb 2010
01 Jan - 31 Jan 2010
01 Dec - 31 Dec 2009
01 Nov - 30 Nov 2009
01 Oct - 31 Oct 2009
01 Sep - 30 Sep 2009
01 Aug - 31 Aug 2009
01 Jul - 31 Jul 2009
01 June - 30 June 2009
01 May - 31 May 2009
01 Apr - 30 Apr 2009
01 Mar - 31 Mar 2009
01 Feb - 29 Feb 2009
01 Jan - 31 Jan 2009
01 Dec - 31 Dec 2008
01 Nov - 30 Nov 2008
01 Oct - 31 Oct 2008
01 Sep - 30 Sep 2008
01 Aug - 31 Aug 2008
01 Jul - 31 Jul 2008
01 June - 30 June 2008
01 May - 31 May 2008
01 Apr - 30 Apr 2008
01 Mar - 31 Mar 2008
01 Feb - 29 Feb 2008
01 Jan - 31 Jan 2008
01 Dec - 31 Dec 2007
01 Nov - 30 Nov 2007
01 Oct - 31 Oct 2007
01 Sep - 30 Sep 2007
01 Aug - 31 Aug 2007
01 Jul - 31 Jul 2007
01 June - 30 June 2007
01 May - 31 May 2007
01 Apr - 30 Apr 2007
01 Mar - 31 Mar 2007
01 Feb - 29 Feb 2007
01 Jan - 31 Jan 2007
01 Dec - 31 Dec 2006
01 Nov - 30 Nov 2006
01 Oct - 31 Oct 2006
01 Sep - 30 Sep 2006
01 Aug - 31 Aug 2006
01 Jul - 31 Jul 2006
01 June - 30 June 2006
01 May - 31 May 2006
01 Apr - 30 Apr 2006
01 Mar - 31 Mar 2006
01 Feb - 29 Feb 2006
01 Jan - 31 Jan 2006
01 Dec - 31 Dec 2005
01 Nov - 30 Nov 2005
01 Oct - 31 Oct 2005
01 Sep - 30 Sep 2005
01 Aug - 31 Aug 2005
01 Jul - 31 Jul 2005
01 June - 30 June 2005
01 May - 31 May 2005
01 Apr - 30 Apr 2005
01 Mar - 31 Mar 2005
01 Feb - 29 Feb 2005
01 Jan - 31 Jan 2005
01 Dec - 31 Dec 2004
01 Nov - 30 Nov 2004
01 Oct - 31 Oct 2004
01 Sep - 30 Sep 2004
01 Aug - 31 Aug 2004

Stuff

Powered by Pivot  
XML: RSS feed 
XML: Atom feed 

§ Screw it, let's try a different assembler

After thinking a bit about the SSE4.1 problem, I decided that the best route for taking advantage of SSE4.1 would be through external assembly, and that the best way to do that was to ditch MASM. There are various workarounds to try to kludge MASM into assembling alternate opcodes, but after being unable to quickly find a workable SSE4.1 macro set and after a failed attempt to make one myself (as well as rediscovering the mess that is MASM's macro facilities), I decided to go for plan B. I'd been wanting to do this for a while for a few reasons. One reason is the half hearted way in which Microsoft has been maintaining MASM, including:

The other reason is MASM's availability, since it's only normally available in Professional Edition or higher. Oh, but you can sometimes get a download for non-commercial use, when they remember to update it, and you can grab it out of the Windows SDK, but you have to make sure not to mix up the bin paths since the SDK compiler isn't always compatible with the VC++ headers. Ugh. MASM is the only thing that prevents the 32-bit version of VirtualDub from being built with VC++ Express, a restriction which I've wanted to lift even though I don't use Express myself for that purpose.

So I spent some time last night porting all of my assembly language to YASM.

The reason I chose YASM is that it has support for x64 Windows, and more importantly, for VC-compatible line number debugging information. I had looked at NASM before, but dropped the idea due to the lack of debug info support. YASM, on the other hand, does, and it looks like a lot of other work has been put into making it VC friendly, such as adding support for emitting errors in VC compatible form. YASM shares NASM syntax, and while it's far closer to Intel syntax than GAS syntax is, it's unfortunately gratuitously different enough to make the conversion non-trivial. I was able the do a lot of the conversion with an ugly Visual Studio macro (why oh why do I have to use Visual Basic?!?), but I still had to fix up a lot of assembly by hand. Among the changes I had to do:

It took me about four hours to convert all 700K of assembly language, after which I actually did end up with a working build of VirtualDub. I even got it hooked in cleanly via a custom build rule. So far, so good. However, as you might have guessed, that means I now have an enormous test coverage problem, because that 700K of asm covers about fifty different features in VirtualDub and only a small fraction of them have test cases. Worse yet, there are about five different CPU levels involved (scalar, MMX, SSE, ISSE, SSE2). Writing all of the test cases necessary to get complete coverage would probably take a very long time, so for now what I'm probably going to do is just do a DUMPBIN /DISASM on both the MASM and YASM based builds and see if I can do verification by automated diff.

Haven't actually gotten to writing any SSE4.1 code yet, but I'm getting there....

Comments

Comments posted:


ID software had a similar problem (needed sse3 conformance before one was available on their compilers). They solved it with some very nice use of regular VC macros:
http://www.koders.com/cpp/fidDF1DB7A4FCE..

OfekSH - 23 04 08 - 04:13


You know, while reading this I just imagined the Adobe coders when Apple told them they'll be switching PowerPC -> Intel. That's not just some naming conventions/syntax diff.

A collective cry of /wrists! must have rang out through Adobe's offices on that day.

keije - 23 04 08 - 19:02


@keije:

On the other hand, Adobe was likely able to re-use the x86(-64) code they had already written for Windows. Of course, the really platform-specific stuff had to be rewritten (painful for many large projects), but on the whole, it shouldn't have been too bad if they wrote everything well. (Big "if", right?)

dj - 23 04 08 - 19:50


It is a big if :) but not for the reason you've mentioned. ASM is very platform specific, especially when windows is concerned. That's why for example x264 while having extensive asm optimization which according to devs gives 10-15% improvement, is almost never available in windows builds. ASM code is written under linux and windows is sufficiently different that you have to recheck the whole thing (and apparently it's not a matter simple substitution). So if Adobe had a linux port they would've used asm from there (OS X is very close in what it wants), but with windows only solution they had their work cut out for them (not from scratch, but a royal pain nonetheless).

keije - 23 04 08 - 23:36


So, now we need YASM to build VirtualDub? Damn...
I cringe when I see oword in the code.
What always annoyed me in x86 assembler is move al, byte ptr [address]. As if specifying AL as the destination isn't enough for assembler to realize that it should use byte form. Motorola had neat code like move.b d0, -110(a4).

Igor Levicki (link) - 27 04 08 - 14:57


I don't think moving assembly between x86-based platforms is that bad -- the most likely problem you have is the register saving convention, and that's easy to abstract. I've moved assembly language between Watcom C/386 and VC++ without much difficulty. Now, if you do what I do and temporarily store ESP in fs:[0] to reuse it as a general purpose register, porting may be a bit more difficult....

mov al, byte ptr [address] is ugly, but it's not terrible when you consider that the prefix is necessary for the push byte ptr [address] and movzx eax, byte ptr [address] cases. I do miss 68K assembler... well, except for the stupid thing where the arguments to a compare are unintuitively backwards compared to the required conditional branch instruction.

Phaeron - 27 04 08 - 16:37


Is there a version of Virtual Dub for Power Macs? I am working cross-platform (Mac - Windows) on Powerpoint presentations and I need to convert .mov and other video clips to .mpg or .mpeg

skybar - 30 04 08 - 22:17


Not a month after this was written, MS finally released VS2008 SP1 beta, which finally adds MASM to VC2008 Express:
http://blogs.msdn.com/vcblog/archive/200..

Yuhong Bao - 16 04 09 - 13:13

Comment form


Please keep comments on-topic for this entry. If you have unrelated comments about VirtualDub, the forum is a better place to post them.
Name:  
Remember personal info?

Email (Optional):
Your email address is only revealed to the blog owner and is not shown to the public.
URL (Optional):
Comment: /

An authentication dialog may appear when you click Post Comment. Simply type in "post" as the user and "now" as the password. I have had to do this to stop automated comment spam.



Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.