Which syntax and architecture of assembly is most useful to know?

assembly, x86

Solution

First, there are two types of syntax: Intel and AT&T. What's the difference?

The main differences are superficial: reversed operands, for example.

Why are there still two in use? When would I need to use one versus the other?

Intel uses a syntax that is a major departure from the syntax that virtually all other processor ISA documents use.

GNU `as` uses AT&T syntax for all platforms, and supports Intel syntax for x86 and x86_64.

Other assemblers (like NASM, MASM, etc.) use Intel syntax exclusively.

So, how can I know whether the assembly I'm learning from a certain web page will work for my machine?

It's documented in the processor manuals from Intel and AMD. Sandpile is also a good resource.

So, the big question is, with all these variables, how can I know what type I should learn? What's most common?

The most widely-supported would be Pentium-pro class, so-called 'i686', and K8-class (referred to as 'x86_64' or 'amd64' or 'EM64T'). The variations from there are whether MMX or SSE or its variations are supported. Look up the CPUID instruction - it will provide you with support information for the processor you're running on.

How is it possible for people to "know assembly" when there are all of these variations?

I don't think anyone "knows" x86. Everyone who needs to has a copy of the processor manuals.

Problem

I've always wanted to learn assembly, but there seems to be a jungle of assembly-related information out there that is difficult to interpret. I haven't just been able to google "learn assembly" and get going. First, there are two types of syntax: Intel and AT&T. What's the difference? Why are there still two in use? When would I need to use one versus the other? Second, there's a multitude of chips out there. Intel vs AMD, 32-bit versus 64-bit, x86 vs other architectures... even x86 is really a whole family of chips. So, how can I know whether the assembly I'm learning from a certain web page will work for my machine? There exist even more variations (operating system even plays a role in determining how code will run. So, the big question is, with all these variables, how can I know what type I should learn? What's most common? How is it possible for people to "know assembly" when there are all of these variations?

Original source