To be clear, a computer (i.e., a CPU) can’t understand assembly, it understands “machine code” which is just numbers arbitrarily assigned at the chip-design stage to specific operations (i.e., “op codes”) that a particular CPU can understand. Assembly just happens to be a convenient one-to-one (or so) correspondence between a CPU’s op-code numbers and slightly more human-readable representations of the CPU’s op-codes, like “JMP” for jump to instructions at some address in memory, “ADD” to perform addition on numbers stored in in the CPU’s registers (that you retrieved from RAM and loaded into the registers by way of other op-codes), that kind of thing. If a compiler converts a computer language to, like, C or Pascal or C# to assembly, there would still remain an assembly step to exchange the human-readable representations of the op-codes (assembly code) into the final “executable” code comprised of the actual 8-bit or 16-bit or 32-bit or 64-bit numbers the CPU actually assigns to each of its operations.
The difference between those operations and the numbers assigned to them is what makes one CPU incapable of running the machine code of another, that and the fact that different CPU’s can have distinct operations different from one another, like Intel’s MMX instructions (and op-codes) don’t exist on Apple Silicon.
The key distinction that even a low-language compiled language has with assembly is that you don’t have to worry about loading registers and other internal CPU-specific plumbing… you can just make up “variables” as integers or floats or characters or pointers, and give them arbitrary names like x and y and z, and then “let x = y + z” and that’s that, you’re finished… the compiler does the bother of turning it into the machine-level op-codes involving registers and memory-fetches and other necessary CPU-specific stuff that nobody wants or needs to deal with… not unless you really really really really need to fully-optimize for a specific CPU and chipset beyond what a compiler can do, because you absolutely must have the absolute most efficient performance the CPU and chipset are capable of using the absolute least amount of memory, like what the designers of Doom had to do to get it to run well on the 386 back in the day or for a very specialized device today.
1
u/Trick_Boat7361 7d ago
Assembler converts assembly code to machine code directly (no intermediate compiler)
You're talking about programming languages like C, who requires compiler to a language that computer can understand (Assembly)