Iridium

So You Want to Build a Language VM - Part 10 - Assembler 3: Assemble Harder

Teaches our assembler to recognize more instruction forms

Improving the Assembler

Our assembler right now can recognize one opcode, load. We need to teach it to recognize all the rest. There’s a couple ways we can do that:

  1. We can write a parser for each opcode

  2. We can write a parser that recognizes the letters a-z and then check if they are a valid Opcode.

Let’s go with option #2, since it will require much less copy-paste. It also gives us an excuse to implement From<CompleteStr<_>> for our opcodes! == The From<&str> Trait In instruction.rs, below the block where we implemented From<u8>, put this:

This Week in Iridium - #2

Summary of what happened with Iridium in the second week.

VM Changes Fixed a numbering bug reported by dancing-koala where the opcodes went from 4 → 6 Fixed some inconsistencies in the part 8 tutorial where I had left Op as Opcode Website Changes I’m now posting all the tutorials on Medium for those who like to read them there. You can find them at: https://medium.com/iridium-vm. Experimenting with ads to help offset hosting costs (sorry, I’ll try to put them in non-annoying places)

This Week in Iridium - #1

Summary of what happened with Iridium this week.

Week #1 Hello! Given the interest in this project, I decided to do an update every week. Website Changes Replaced Disqus with Discourse. Posts now show a shorter summary that isn’t the first part of the post all jumbled up Added links to Twitter and GitLab (lower left corner) Added a project page for Iridium to give easier access to all the tutorials

So You Want to Build a Language VM - Part 06 - The REPL

Starts building a REPL for the Iridium VM

A REPL

REPL stands for Read, Evaluate, and Print Loop. It is also referred to as the interactive interpreter for a language. For example, if you open up Terminal or iTerm, we can look at Python’s REPL:

So You Want to Build a Language VM - Part 07 - REPL and Code Execution

Adds basic hex code evaluation to the REPL

A More Advanced REPL

Our current REPL doesn’t do a ton, so let’s fix that. In this post, we’ll be adding some commands to look at the program bytecode and the registers and their contents, as well as actually execute code entered in as hexadecimal.

So You Want to Build a Language VM - Part 05 - Equality Checks

Covers equality opcodes

Equality

Hey, you’ve made it this far! Congrats! I wish I could say we’re near the end to give you some hope, but, well…​sorry. =)

Today, we’re going to add some equality and comparison instructions! These will let us test us if the values in two registers are equal, not equal, greater than, or less than. These are easy to implement, so it shouldn’t take us too long. == Opcodes The new Opcodes we’ll be creating are:

So You Want to Build a Language VM - Part 04 - Jumps

Covers the jump opcodes

Jump Around!

When we last left our intrepid tutorial followers, we had a simple VM that could add, subtract, multiply and divide. This is all fine and dandy, but we need more functionality than just that. In this segment, we’ll be adding some jump-related instructions.