News for hackers. Stuff that matters.
Re:Show HN: I wrote a custom assembler for CHIP-8 in C++ by Stevenrojas888 on Saturday September 19, 2026 @09:09AM (#49766307)
Awesome milestone! As someone diving into C and C++ right now, what was the steepest part of the learning curve for you when structuring the assembler compared to writing the emulator in C?
Re:Show HN: I wrote a custom assembler for CHIP-8 in C++ by tack1234 on Tuesday September 22, 2026 @06:41AM (#49799117)
Thanks! Well at first I did not have much structure, I just went full procedural and did what I needed to do at each step. It was an ugly, long chain of loops and switches. Then I read up about assemblers a little bit, figured out what should go into the lexing/parsing/emitting stages and split it into classes.

The steepest part.. probably trying to do things efficiently, using string views instead of strings where relevant, references and also ranges + iterators in C++. The from_char function and how it reports errors (e.g. when the iterator it returns is the end of the provided range, there were no errors) etc.