Must assemblers understand EVERY mnemonic?

chrstrbrts

Senior member
Aug 12, 2014
522
3
81
Hi everyone,

OK, so because I'm an OCD madman, I'm reading every page of the Intel 64 and IA-32 Architectures Software Developer’s Manual Combined Volumes 1, 2A, 2B, 2C, 2D, 3A, 3B, 3C, and 3D.

I'm on page 1,000 (only 3,618 pages to go!), and I'm in the middle of the 2nd volume, specifically the part where every instruction is detailed.

I've noticed that modern Intel platforms have a TON of instructions.

Do modern x86-64 assemblers have to understand every single one?

Many instructions are extremely esoteric and narrow in focus.

For example, many of the SIMD instructions do things like take the vectors in some YMM register and move them around or add some scalar to them.

Obviously, the basic instructions e.g. mov, add, etc. need to be assembled.

But I'm beginning to think that it might be prohibitively complicated to write an assembler that can assemble every single one.
 
Last edited:

Merad

Platinum Member
May 31, 2010
2,586
19
81
Bear in mind that very few people are writing new compilers or assemblers from scratch these days. As you can see on Wikipedia, instructions are grouped by feature set and/or processor family. When a new processor comes out, you add any new instructions along with a new option to enable them. An assembler certainly doesn't have to understand everything. GNU Assembler, for example, had its last stable release in 2013 so I'm sure it's missing some of the newest instructions.

If you want to write an assembler I recommend starting with a RISC instruction set. In grad school we used the DLX (a simplifed MIPS), and a basic assembler for it was about a month long project.
 

chrstrbrts

Senior member
Aug 12, 2014
522
3
81
When a new processor comes out, you add any new instructions along with a new option to enable them. An assembler certainly doesn't have to understand everything. GNU Assembler, for example, had its last stable release in 2013 so I'm sure it's missing some of the newest instructions.

So, if a brand new processor is just released, you've acquired one, and you'd like to program it to perform some of its new functions, you can't rely on an assembler.

In such a situation, you'd be forced to obtain some kind of tech manual that lists the opcodes for the new operations and use a hex editor to code the 0's and 1's yourself.

Is that right?

And if no tech manual exists?......then you're SOL?
 

Merad

Platinum Member
May 31, 2010
2,586
19
81
Basically, yeah. With enough smart people, time and resources you could probably reverse engineer the CPU, but I wouldn't want to try it. IIRC this did happen during the cold war when Soviets got their hands on western computers and vice versa (granted, CPUs were much simpler back then).

Realistically though someone releasing a new CPU wants people to use it, so they're going to release documentation at the least, if not assemblers or a C compiler as well. Honestly a basic assembler isn't very difficult to program (especially with modern languages and libraries to help with string operations and lexing/parsing). A basic non-optimizing C compiler isn't much more difficult. This is why C remains so popular - basically every CPU ever release has had a C compiler written for it, and a C compiler gives you access to tons of libraries, programs, and the ability to port higher level languages to your platform.