68 points · by okaleniuk · 5y ago · 53 comments
That is not to say that you can't have macros in an assembly language. While you can't unambiguously recover any macros (or label names, for that matter) used when generating assembly language from the binary output, you can still unambiguously recover some sort of assembly which can be used to generate an identical binary output, excepting any junk your particular platform does that prevents reproducible builds such as embedding timestamps.
This isn’t true for many CPU assembly languages, though. For example, the x86 instruction `add eax, ecx` can be assembled to either `01 c8` or `03 c1`.
> you can still unambiguously recover some sort of assembly which can be used to generate an identical binary output
If your binary contains `01 c8`, information is lost when that’s disassembled to `add eax, ecx` and there’s no guarantee that a newly assembled binary won’t contain `03 c1` in its place.
Also, while C might not be an assembly language... it combines the power and performance of assembly language with the flexibility and ease-of-use of assembly language.
Person using definition B: No it isn't!
---
Actual situation: Different people using the same word to refer to different things.
Edit: I suggest that as a necessary condition for something to be assembly,
disassemble(assemble(x)) = x,
modulo comments and label names.
disassemble(assemble("nop")) == "add r0, 0"
I think that's how v850 or tricore do it. Than there is ARM, for which the v8.6 ISA manual casually contains the term "This instruction is an alias of" 115 times. (I checked the rev. F PDF, you can get the rev. G PDF at https://developer.arm.com/documentation/ddi0487/ga/ by clicking "Download").I think a huge problem is how it is easy to mix up assembly that gets "processed" to /machine/ instructions with another kind of assembly that gets "processed" to VM ops. Which then get compiled again (usually JIT) before being executed.
ILAsm is a nice example for that: It's some kind of assembly language, and you could probably go right down to x86 instructions (at least with little change). But you'll never do that. Simply because it is a stack language; and while you can produce e.g. x86 opcodes that "do the right thing", the whole stack traffic will kill performance. Instead, the VM will push the opcode stream through a (I guess JIT?) compiler: Small functions will be inlined, others will get a prologe and epiloge, parameters and return values are arranged according to the ABI's calling conventions. And then there will be all the usual register allocation stuff. [edit] And a lot of other magic. [/edit] Still, the original input is pretty much an assembly language.
That's not-quite-correct, since the Smalltalk-80 implementation manual sitting on my shelf explicitly details the bytecode that compiles to. It's not "as far from low-level programming" as can be, it compiles directly to a bytecode!
But, inadvertently, such influential projects gradually warp the definition of the word 'assembly' or 'assembler' away from what it traditionally was: the most close to the metal and minimal abstraction from hardware.
Perhaps that's OK? But it does cause some arguments
But it seems like it could be a better definition, as it gets closer to the essential meaning.
After all these gates it turns out that while RISC had some nice ideas, the flexibility of microcoded CPUs won the war anyway, and nowadays stuff like FPGAs makes it even more flexible than traditional microcode languages.
That said, probably most of the time when people say "assembly language" their definition is not as strict as mine.
Most mainframes, like those from Xerox PARC, don't have any kind of Assembly, the first step of booting was to load the corresponding microcode execution engine.
(And most instructions correspond to 1 or a few uops in a straightforward way).
That is, you still need a compiler, with optimization, register/stack allocation, etc... before you start outputting machine code that is run by the hardware. However all the tricky parts of ADA, the task model in particular, are implemented in hardware.
So it doesn't make ADA an assembly language.
Maybe FORTH and LISP could be considered assembly in some circumstances. I don't know enough about these and their machine implementation to be sure but it looks like there can be a 1:1 relationship between these languages and machine code.