Search code examples
assemblymachine-code

What compiler would I use to write machine language?


Just out of interested I would like to write a small program in machine code.

I am currently learning about registers, ALU, buses and memory and I'm slightly fascinated that instructions can be written in binary instead an assembly language.

Would a compiler would need to be used?

Preferably one that runs on OSX.


Solution

  • You would not use a compiler to write raw machine code. You would use a hex editor. Unfortunately, I don't use OSX, so I can't provide you a specific link to one.

    If you write machine code, you will need to learn how to write the binary headers required by your OS as well. I would recommend doing so and testing with an assembler in raw output format first; once you understand the binary layout it is a purely mechanical task to hand-assemble this to machine code.