So I'm writing my first 6502 chip emu and I have yet to write the assembler. But my question is: Should the assembler produce a machine code file in plain-text format or a binary file?
So I'm writing my first 6502 chip emu and I have yet to write the assembler. But my question is: Should the assembler produce a machine code file in plain-text format or a binary file?
Binary. Text mode is mainly used to translate a newline (\n) to a platform-specific newline sequence, such as \r\n. As I understand it, Windows also stops reading from a text file when it hits a particular byte, which it won't do in binary mode; but don't quote me on that one.
Basically, if you want the file contain exactly the bytes you write to it, use binary mode. Text mode can, if the system differentiates between the two, mangle output.
How complex is your assembler?
At the simple end of things, it would emit pure binary data located to a particular address. Once loaded onto the machine, it was good to go.
A complex relocatable assembler would output instructions and relocation information. Such programs allow you to build libraries of modules, and multi-module programs without too much effort. But you also need an additional "link" program to resolve all the relocation information down to a pure binary form.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I still have a little bit to do with the core. I've never written an assembler so this one may be moderately simple but I'm looking forward to it.