‹ BackHN Continuity

Thread

Show HN: I wrote a custom assembler for CHIP-8 in C++

28 points · 8 comments · tack1234

  1. Stevenrojas888 · · focus · HN ↗
    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?
    1. tack1234 · · focus · HN ↗
      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.

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.