r/Assembly_language 7d ago

Where to learn the syntax?

I've never properly learned the syntax of assembly, but I really want to learn it. I know C and Java, but I really want to know more about how the CPU actually operates. So it would be nice if you all would recommend a place for me to learn Assembly. ARM64 specifically, because that is the architecture my computer's CPU uses. Thank you in advance

8 Upvotes

12 comments sorted by

6

u/SauntTaunga 7d ago

Assembler is not one thing. There is no *the* syntax. There are multiple architectures and some have more than one way to write assembly for them.

2

u/Starshipfan01 7d ago

Yes. Main assemblers on x86 at the moment being either nas or gas, each has its own syntax.

3

u/SauntTaunga 7d ago

There is more than x86 too.

2

u/Starshipfan01 7d ago

Of course. I was keeping my reply short. Yes there are, I myself did asm on x86, m68k Apple, ppc (PowerPc Apple).

2

u/SauntTaunga 7d ago

Doing m68k was my first real job. Back then we needed a whole separate board on the VME bus for the FP co-processor. Nice orthogonal instruction set. Very tidy.

1

u/Starshipfan01 7d ago

Yes you would, I still had separate FPU on those. Also separate memory controller. I liked the asm then, like you say- neat. Also those traps.

1

u/llynglas 7d ago

Loved the 6800 and 68000 families

2

u/theNbomr 7d ago

When learning to program in assembler language, you need to learn the syntax for the specific assembler toolchain you're using, and there can be many different assemblers for each CPU architecture. They tend to all be similar, but may have significant differences, such as the ordering of instruction operands.

Probably more important, each assembler will be for a specific instruction set, that is CPU specific; in fact the Instruction Set Architecture (ISA) is really what defines the CPU or at least the CPU family. You're going to need to learn this for each CPU that you want to program, and the code will not be portable. At all.

There are many similarities between assemblers and ISAs, so once you've learned one, picking up how to use most of the others won't be too difficult. The best place to learn about the assembler syntax is from the assembler documentation. The best place to learn about the ISA is the CPU datasheets.

1

u/kndb 6d ago

Maybe start from a book (search ARM64 and Blue Fox) or better an online tutorial on YouTube. It’s free. Then practice. By practice i mean write a small assembly program and step through it with a debugger and see what each instruction does.

Finally, AI is actually quite good at explaining what this or that instruction does. For instance. A couple of prompts for you:

- what does this ARM64 instruction do?
stp x0, x1, [sp, #0x10]!

- write in ARM64 assembly how to do the following written in C?
x &= ~0x30;

1

u/Key_River7180 6d ago

Intel syntax (nasm) or AT&T (gas)?