I’ve programmed in IBM 360 and VAX Assembly before but I have been working in a Microsoft Windows environment on an Intel x86/x64 hardware platform for quite a while. That little reminder in the back of my head has kept popping up saying it was time to learn Intel Assembler but the auto-click to “close the annoying popups” has until recently triumphed. I finally decided to go for it. Since I want to target Microsoft Windows on an Intel platform I figured I’d go for the MASM Assembler.
I learn pretty well through reading books so I opened up Amazon to search around for something that would help. Much to my chagrin authors either don’t target Windows, don’t target a flat memory model (come on! it’s been a while since we were all working on 8086 processors guys), don’t target MASM or haven’t written a book on Assembly in the current century.
The best resources I’ve found so far are Internet resources. Following are some good ones I’ve found so far:
- The MASM Forum – http://www.masm32.com/board/index.php
- The MASM32 SDK – http://www.masm32.com/
- Iczelion’s Win32 Assembly Homepage – http://win32assembly.online.fr/tutorials.html
- Setting up your MASM32 Development Environment – http://devpinoy.org/blogs/cvega/archive/2009/01/24/setting-up-your-masm32-development-environment.aspx
- Processor Architecture – http://msdn.microsoft.com/en-us/library/ff553442(v=VS.85).aspx
You’d think that the MASM development environment would be integrated somehow into the Visual Studio environment but I guess it’s so rare for somebody to write anything in Assembly they don’t feel like putting in the time to develop and maintain that part of Visual Studio. You can get an add-in for Visual Studio 2010 that does highlighting for Assembler called ‘AsmHighlighter’ but you’ll just be in a text editor not a development environment.
A very old-school (it makes you think of DOS editors) x86 development environment is installed as part of running the ‘Install.exe’ found on the ‘MASM32 SDK’ link above. Before running the ‘Install.exe’ note all the warnings about AntiVirus scanners. Norton Anti-Virus no longer complains, not sure about other scanners.
The x64 Assembler ML64.EXE is part of the Windows Driver Kit but note that it’s the Assembler, not a development environment. I guess that’s why we have the very expensive text editor named ‘Visual Studio’ and the venerable notepad.
So, anyway, once you get into using Macro Assemblers you find that the “Macro” part of the Assembler means that it seems like you’re programming in a combination high-level/low-level programming language. Some of the very repetitive sequences of instructions like setting up and tearing down call stacks (‘invoke’ keyword) and flow control statements (.IF, .ELSEIF, .WHILE, etc) are provided. The rest of it though is a good ole Win32 programming (when is the last time you used RegisterClassEx & CreateWindowEx?) and lots and lots of push/pop/mov commands.
My original motivation for learning Intel Assembly was to be better able to diagnose program dumps and I know learning the programming methodology needed to write Windows programs in MASM is a necessary start in that directory but looking at the disassembled program code:
is a whole lot different than looking at:
So my next thought was that there has to be a good disassembler out there for Intel x86 Assembly. After searching for a while and finding a number of virus delivery systems masquerading as disassemblers I found a very good tool named IDA at http://www.hex-rays.com/. There is a freeware version of the tool called ‘IDA Freeware’ at http://www.hex-rays.com/products/ida/support/download_freeware.shtml. The freeware version has limitations of course so I figured I’ll just go ahead and buy the professional version. After catching my breath at the price of $1,059.00 I just added that software to my “I hope I have a rich uncle and he buys me this” list. So for now I’m sticking with the freeware version
Using ‘IDA Freeware’ for the same binary I get:
I have a long long way to go on getting comfortable with Intel Assembly but at least I’ve made that first step.
Pingback: InterKnowlogy Blogs » Blog Archive » Configuring Visual Studio 2010 for Assembly Development