How does the CPU know how many bytes it should read for the next instruction, considering instructions have different lengths?

The simple way is to just read one byte, decode it and then determine if it’s a complete instruction. If not read another byte, decode it if necessary and then determine if a complete instruction has been read. If not continue reading/decoding bytes until the complete instruction is read. This means that if the instruction … Read more

Linux Mach-O Disassembler

AFAIK, the native Darwin binary tools are part of the cctools package. They don’t have the same command line syntax or output as the GNU binutils. Later binutils (i.e., 2.22) supports the Mach-O format however. You can get these prebuilt, with the ‘g‘ prefix to the tool names, as mentioned here. Alternatively, you can compile … Read more