iman wrote:Schol-R-LEA wrote:If you don't mind me asking, why are you studying the instruction binaries? ... if you could please say more about your goals
I'm curious to see how far I can go to implement a custom assembler for my own OS.
This is the way I learn something. Start to write something simple and building up the rest step by step. If I could get the way an assembler codes some simple instructions, then I would be motivated to continue. Apparently starting off from the MOV, gives quite a good knowledge for coding the other instructions.
I had recently gotten in touch with implementation of an assembler, as such, communication with the Intel's manual, in this respect, is still tough and needs more time to understand.
That is why I made the decision to ask for some easier-to-grasp explanations.
Fair enough, both regarding motives and your reason in asking for help.
You may want to take a bit of time to look at other instruction set architectures before diving into the assembler proper, however, as the comparison between x86 (and x86-64, which is mostly a superset of x86 but does change some things) and, say, ARM, or MIPS, or RISC-V - or maybe even an older, simpler ISA such as 6502 (or conversely, a contemporary one such as Motorola 68000, which came out a few months after the 8086 did) - may give you more of a context for what the different terms mean, and how the instructions' fields are arranged, if you can compare it to how other designs work.
I'd also mention that the x86 is a particularly difficult ISA to understand and implement a toolchain for; it came at an awkward period in the history of microprocessors, falling between the very simple accumulator machines such as the 6502 and the M6800, and the even more complex but more regular and consistent designs such as the M68000 (which, despite the name, was not a related design to the 6800) or the Z8000 - and certainly before the re-alignment and retrenching of the design space that came with the
RISC architectures in the mid-1980s. Also, the 8086 (and subsequent 8088 used on the original PC) was designed as an extension of the 8080, so the x86 ISA already had some historical baggage even before it came out.
You may find it easier to get a brief overview of a different architecture - or better still, a few different ones - so you have a bit more context to put the weirdness of the x86 into. I'd suggest MIPS, as it is a solid, if somewhat simple and abstract, RISC ISA which was partly developed for teaching computer architecture courses and thus particularly easy to understand. RISC-V might be a good choice too, being a later development of the same overall design but with a lot of extra work done in order to make it more extensible. ARM is a good choice too, and live hardware for it may be easier to come by as most of the popular single-board computers - such as the Raspberry Pi, Asus Tinkerboard, Libre Renegade, Pine Rock64, and several ODROID models - use some implementation of the ARM for their CPUs, and a suitable one can be had (including the necessary accessories, not counting a monitor or television) for under $50 US.
Or you can go old school with some retro hardware like a Commodore 64 or Apple II, if you can find one, or neo-retro with something like the
the Maximite or the Commander X16. The advantage of those is that the 6502 most of them use(d) is dead simple compared to any of the others, and the systems themselves (or the emulator for the upcoming system, in the case of the Commander) are simple single-tasking systems and generally have a built-in debugger for manually coding in machine language.
Still, if your main interest is in PCs, you probably won't want to linger on the other CPU designs too long. A little may go a long way.