Know of any good 80x86 family assembly compilers?
February 7, 2014 9:53 AM   Subscribe

What is the best free 80x86 family assembly compiler?

I have the old Jeff Duntemann book "Assembly Language Step-by-Step". It's old (1992) but the text itself suits my needs. He goes into old assembly compilers like TASM and MASM which may have been included in Windows and DOS in the x386 and x486 days. But those days are long gone and I think they have been discontinued as a freebie in modern OS and chip sets. So what's an assembly programmer wanna-be to do?

So here's the question:

What is the best 80x86 family compiler available? Free is better than pricey. Having an IDE is better than not having one.

Any opinions?

posted by Lord Fancy Pants to Computers & Internet (17 answers total) 3 users marked this as a favorite
You can use GCC as a frontend for AS, which is the only way I've ever done it.
posted by Oktober at 9:58 AM on February 7, 2014

/usr/bin/as <-- just use that one.
posted by tylerkaraszewski at 10:02 AM on February 7, 2014

You might want to use NASM, which uses a TASM/MASM style syntax, as opposed to the AT&T syntax used by default by gas (the GNU assembler). Or you could use gas with the .intel_syntax directive. I don't really know about an IDE for assembler, but most good editors will have syntax highlighting for assembler.
posted by Monday, stony Monday at 10:21 AM on February 7, 2014 [1 favorite]

There are two different commonly-used syntaxes for assembly programming, Intel and AT&T syntaxes (see "Intel and AT&T Syntax" by Kim Skak Larsen for an interview). Consider that as uses AT&T Syntax. I bet your book uses Intel syntax, so you might find nasm a better fit.
posted by grouse at 10:22 AM on February 7, 2014

(When I took a course in x86 assembly back in 2000, we just used gas with the AT&T syntax, and it worked fine)
posted by Monday, stony Monday at 10:23 AM on February 7, 2014 [1 favorite]

It has been 20 years since I've done x86 assembly as anything other than inline in C code. Since then I've only done it when I can't get the C optimizer to do the right SIMD stuff.

However, back in the days when I still did raw x86 stuff, the go-to tool was a86. It was a little weird because it used a slightly different syntax than standard x86 assembly code, but in the DOS days I did complete utilities with it.

Re an IDE: Learn how to use Vim or Emacs and a Makefile. This will serve you far better in the long-term than using an IDE.
posted by straw at 10:24 AM on February 7, 2014 [2 favorites]

I would also note that the author, Jeff Duntemann, has written a new edition of the book which is based on Linux instead of DOS, published in 2009. It uses NASM and some basic tools, which is suitable for a tutorial like that.
posted by Monday, stony Monday at 10:52 AM on February 7, 2014 [1 favorite]

(He also doesn't spend much time on real mode, and that's a good thing, really; real mode is the stuff of nightmares)
posted by Monday, stony Monday at 10:54 AM on February 7, 2014

Seems also people use the Fresh IDE which uses the flat assembler (FASM). There's WinAsm Studio, supposedly supports MASM and FASM syntax.

But it's going to be kind of weird working with a book written for 16-bit CPUs in this time of x86-64 madness. And you're likely to get wrapped around the axle on Windows calls and so forth.

For true verisimilitude, you might consider downloading DOSBox and picking up Turbo C which supports inline assembler (though probably a reduced feature set) and a nifty debugger.
posted by RobotVoodooPower at 11:28 AM on February 7, 2014

You can still get MASM. It's part of the visual studio suite. You should also be aware of the fact that MASM isn't the same as other assemblers not just in syntax (AT&T vs Intel) but also in the sort of wrapper macros and changes it will make to your code. You haven't known frustration until you've been debugging a rare kernel crash that was brought on by MASM thinking it knows better than you and turning your 'ret' into a 'ret 8' and you didn't notice the 8 the first twenty times you objdumped the code. (In my humble opinion, if you need to objdump your "pure assembly", you're not using a great assembler).
posted by lucasks at 4:51 PM on February 7, 2014

Just to be clear: I would recommend you stay as far away from MASM as possible unless you absolutely need to be writing for Windows. Also, be aware when reading your textbook that ABIs differ based on OS and 32 vs. 64 bit.
posted by lucasks at 5:05 PM on February 7, 2014

I used to use Borland's Turbo Assembler quite a bit in the early 90s. You can probably download it from one of the many "abandonware" sites on the interwebs. Oh, the memories..fixed point math and sine tables and INTs and the VGA CRTC boondoggles and realtime debuggers.

I honestly hate to derail but can I ask why you are developing for an 80x86, especially in assembler? Is this for an 8086/286 pre-protected mode? Because assembly post protected mode is a special kind of insane. I can't think of a good reason other than nostalgia or bragging rights; it's a feat of strength akin to building a computer out of vacuum tubes or tinker toys or something. (And one that I respect - they are still making demos for C64s and posting them on YouTube!)

If you are doing embedded, you have so many well-supported, proven options: PICs, AVRs, Propellers, ARMs...and if you're doing development for proper desktop computers, why wouldn't you go with something OOP (Java, C++, Python)? Part of the reason for doing things in assembler used to be speed, when every cycle mattered and things like unrolled loops and self-modifying code were commonplace (I'm looking at you, Tom Duff--yes, I know that what he did was technically C, but it has its roots in assembler) to harvest precious frames. Those problems have long been solved by Moore's law and ingenuity and things like GPUs.
posted by ostranenie at 8:03 PM on February 7, 2014 [2 favorites]


I'm not "developing" per se. I'm just monkeying around with assembly language because I wanna and I'd like to do it with something readily at hand like the computer I'm typing on rather than something really hobby-like, like an Arduino or something. Tinkering is a hobby. I've got a core i3 which is a far cry from a 286 but it's the same family several generations removed. I'm not interested in doing something spectacular with it, just the electronic equivalent of making a dissected frog's leg jump in a biology class. Followed up with several minor but successful "Frankenfrogs." No big whup. Nothing but brain food for me.

I DO, in fact, have plans on building a ham radio out of tubes. I'm that kinda tinkerer. ARRL has some GREAT plans on line from 1929.

Are you saying that a core i3 is generally inaccessible with readily available assembly compilers?
posted by Lord Fancy Pants at 9:55 PM on February 7, 2014

There are plenty of readily available assemblers for the Core i3, which support both the traditional x86 instruction set (used in the Duntemann books), and the x86_64 extension. Except for the DOS specific stuff, you should be able to run any of the old x86 programs from the Duntemann books on your processor.

What ostranenie is questioning is the relevance of assembly today, especially on a powerful and very complex processor like the one in your desktop, where, for a given program, it's actually pretty hard to write an assembly routine that will be faster than the assembly produced by a modern C compiler.

If your goal is tinkering, then that discussion doesn't really matter.

If you're intent on using the 1992 book, though, the DOSBox suggestion seems like a good one, since it reduces the chance that you encounter frustrating differences between old school DOS and your modern OS. I'd tend to go for the 2009 book though; it's the same author with the same general approach, but all in protected mode so you don't have to deal with the frustrating bits of real mode. Although I didn't become a coder, I really enjoyed the course I took in x86 assembly back in college, and we always used protected mode.
posted by Monday, stony Monday at 8:40 AM on February 8, 2014

Yep. My goal is tinkering. I just wanna know. I want to make a computer do computer things "by the numbers" since a computer program is little more than a list of instructions that get translated into a set of these low level building blocks. Faster operation in no way enters into my motivation.

So I'm wondering what assembly compiler best suits those requirements--knowledge of operation, simplicity, IDE if possible with "speed" not even entering into it. Think "hobbyist" not "developer."
posted by Lord Fancy Pants at 11:38 AM on February 8, 2014

If you're just messing around for the sake of learning you might want to look into 6502 assembler. Pro: It is less complicated. Con: It is less complicated.

If you still are into the 8086 thing, I suggest you get TASM and Turbo Linker and run them in DOSBox. Edit your assembler files with something like Notepad++ on your "real" computer and set up a batch file on your "fake" computer to assemble and run (assuming errorlevel 0, which means successful assembly) your executable. And if you assemble to COM files (no header, real mode), you can keep it as simple as possible but still have access to all the things that make assembler wonderful. Get a copy of TD386 (Turbo Debugger), too--you can step through the code, see the opcodes in hex alongside the mnemonics, watch all your registers and see your instructions come to life. And because DOSBox is a virtual machine, you can do all kinds of "illegal" things that require direct hardware and memory access.

And oh, if you're interested in tinkering, might I suggest Brainfuck? If you thought assembler was tough to write...
posted by ostranenie at 5:32 PM on February 8, 2014


Brainfuck is. . .hilarious. About as hilarious as a programming language can be. Seriously funny--like in a caveman comic strip kinda way. (Me programmer. Me program!) I think I'll pass on it though. I want to dabble in assembly language, not become a glutton for punishment.

I'll look into the TASM solution you're talking about. Good DOSBox applications too! Thanks!
posted by Lord Fancy Pants at 9:14 AM on February 9, 2014

« Older Fast moving water is best   |   Laser Jet 1000, we miss you so Newer »
This thread is closed to new comments.