Warning: Some posts on this platform may contain adult material intended for mature audiences only. Viewer discretion is advised. By clicking ‘Continue’, you confirm that you are 18 years or older and consent to viewing explicit content.
This is pedantic, but assembly languages get “assembled” to machine code. This is somewhat similar to higher level languages being “compiled,” which eventually becomes assembly which gets assembled. The major reason why these are different is because a compiler changes the structure of the code. Assembly is a direct mapping to instructions. It just converts the text into machine code directly, which is why it’s easy to go from machine code to assembly but decompiling doesn’t give you identical results to the original source code.
Also, binary and hexadecimal are just different ways to view the same binary data and aren’t different things. There is only “machine code” which is a type of binary data but you can view binary with any arbitrary base, though obviously powers of 2 work better.
Assembly is a direct mapping to instructions. It just converts the text into machine code directly,
Kinda… yes and no? At least with x86 there’s still things like encoding selection going on, there’s not a 1:1 mapping between assembly syntax and opcodes.
Also assemblers, at least those meant for human consumption (mostly nasm nowadays) tend to have powerful macro systems. That’s not assembly as such, of course.
But I think your “a compiler changes the structure of the code” thing is spot-on, an assembler will not reorder instructions, it won’t do dead code elimination, but I think it’s not really out of scope of an assembler to be able to do those things – compilers weren’t doing them for the longest time, either.
I think a clearer division would be that compilers deal with two sets of semantics: That of the source language, and that of the CPU. The CPU semantics don’t say things like “result after overflow is undefined”, that’s C speaking, and compilers can use those differences to do all kind of shennanigans. With assemblers there’s no such translation between different language semantics, it’s always the CPU semantics.
I don’t think I said assembly is abstracted. It’s pretty much just a translation.
Hexidecimal isn’t binary. They’re both just ways to represent numbers. A number displayed in hexadecimal and binary are the same number even though they look different. FF(base 16) = 1111 1111(base 2) = 255(base 10). They’re all identical.
This is pedantic, but assembly languages get “assembled” to machine code. This is somewhat similar to higher level languages being “compiled,” which eventually becomes assembly which gets assembled. The major reason why these are different is because a compiler changes the structure of the code. Assembly is a direct mapping to instructions. It just converts the text into machine code directly, which is why it’s easy to go from machine code to assembly but decompiling doesn’t give you identical results to the original source code.
Also, binary and hexadecimal are just different ways to view the same binary data and aren’t different things. There is only “machine code” which is a type of binary data but you can view binary with any arbitrary base, though obviously powers of 2 work better.
Kinda… yes and no? At least with x86 there’s still things like encoding selection going on, there’s not a 1:1 mapping between assembly syntax and opcodes.
Also assemblers, at least those meant for human consumption (mostly nasm nowadays) tend to have powerful macro systems. That’s not assembly as such, of course.
But I think your “a compiler changes the structure of the code” thing is spot-on, an assembler will not reorder instructions, it won’t do dead code elimination, but I think it’s not really out of scope of an assembler to be able to do those things – compilers weren’t doing them for the longest time, either.
I think a clearer division would be that compilers deal with two sets of semantics: That of the source language, and that of the CPU. The CPU semantics don’t say things like “result after overflow is undefined”, that’s C speaking, and compilers can use those differences to do all kind of shennanigans. With assemblers there’s no such translation between different language semantics, it’s always the CPU semantics.
Removed by mod
I don’t think I said assembly is abstracted. It’s pretty much just a translation.
Hexidecimal isn’t binary. They’re both just ways to represent numbers. A number displayed in hexadecimal and binary are the same number even though they look different. FF(base 16) = 1111 1111(base 2) = 255(base 10). They’re all identical.