// convert List of words into a string for output to a file
private static string ThisOutput(List<String> list)
using (StringWriter stream_out = new StringWriter())
int i = 0;
while (i < list.Count)
line = list[i];
stream_out.Write(line + "\r\n");
Is my currently failing solution... Any pointers would be appreciated, thank you!
The "Illegal character" error occurs when the CPUEmulator reads a character that is not '0' or '1' when it is expecting a binary ASCII number.
The UTF-8 byte order mark is a common cause of this problem, but I've also seen students' assemblers that accidentally include a null character '\0' at the beginning or end of the lines, which will also cause this problem.
Because you must write ASCII, I would not trust "Encoding.Default". I don't know C#, but a quick search shows "Encoding.ASCII" is available.
If you can't find a solution, post a ZIP or RAR archive containing the failing .hack file.
Thanks for the feedback! I've switched to explicit ASCII encoding, which is working, but the problem was actually being caused by the way I was initializing the empty string for address codes.
It's a bit funny, I changed it from "\0" to "" and suddenly my output contained empty lines for address codes. I fixed it by initializing the variable with a blank space, " ", but then before I return the encoded word I pass the string through my StripWhitespace() function. Et viola! It's not exactly pretty, but it works for now.
Now I can use the Assembler compare feature as it was intended, thank you again!