3 ms·
There's a bit of a miscommunication going on. What I meant was, when you write an assembly instruction, that maps to one machine instruction. I.e., because of
by amw-zero 10y ago
There's a bit of a miscommunication going on. What I meant was, when you write an assembly instruction, that maps to one machine instruction.
I.e., because of things like addressing modes, different invocations of an ADD instruction can map to different machine instructions. But one ADD invocation will always map to one machine instruction.
The parent comment sounded to me like one assembly instruction could map to several machine instructions, like one line of C is equivalent to several lines of assembly. Just wanted to clarify that that isn't the case.
- Narishma 10y agoI read it as one assembly instruction can map to one of several machine instructions.
- userbinator 10y agoThat is also true --- for example, "mov reg, reg" is a special case of "mov reg, r/m" or "mov r/m, reg" with the r/m specifying a register, so basically two separate sequences of bytes which perform the same operation. This has been exploited by copy-protection and steganography, going back to the A86 shareware assembler which was the first use of this technique that I can remember, to more recent developments: https://www.cs.columbia.edu/~angelos/Papers/hydan.pdf https://www.cs.columbia.edu/~angelos/Papers/hydan.pdf http://stackoverflow.com/questions/17973103/why-does-the-solaris-assembler-generate-different-machine-code-than-the-gnu-asse http://stackoverflow.com/questions/17973103/why-does-the-sol... (Almost wish that last link was cut off one letter earlier...)
- wolfgke 10y ago> There's a bit of a miscommunication going on. What I meant was, when you write an assembly instruction, that maps to one machine instruction. That's not true on x86-16, x86-32 and x86-64. For example 060o, 310o and 062o, 301o (...o means "octal"; for the reason why I give this example in octal instead of hexadecimal cf. https://news.ycombinator.com/item?id=13051770 https://news.ycombinator.com/item?id=13051770) both stand for "xor al, cl" (the assembler you use will one of the two encodings) - for those people who really prefer hexadecimal here: It corresponds to 30h, C8h and 32h, C1h The fact that there are different ways to encode some instructions was used by the A86 assembler (https://en.wikipedia.org/w/index.php?title=A86_(software)&oldid=738208372 https://en.wikipedia.org/w/index.php?title=A86_(software)&ol...) to watermark machine code that was generated by it; in particular to detect whether it was generated by a registered or unregistered version of A86: "The assembler automatically embeds a "fingerprint" into the generated code through a particular choice of functionally equivalent instruction encodings. This makes it possible to tell if code was assembled with A86, and also to distinguish between registered and unregistered versions of the assembler, although access to the source code is required."
- amw-zero 10y agoRe-read my previous comment. An assembly instruction can map to one of a set of machine instructions, but only one. Said another way, when you write: MOV eax, 5 This will map to _either_: 110111 _or_ 110110, but _not_ both in sequence.