256 bytes

Even though an 8-bit computer is called an 8-bit computer because it works with 8-bit numbers, it's not strictly necessary to make all numbers 8-bit. For example, it's certainly reasonable to use a larger number for memory addresses, otherwise you'd be limited to only 256 bytes of memory. However, I'm not a reasonable man, so 256 bytes is all you get.

Addressing memory

There are two things you need to be able to do with memory: read it, and write it. That means I'll need two new instructions. After a lengthy and intense brainstorm session full of posting notes, categorizing suggestions, and scoring candidates, I finally decided on their names: read and write. read is for reading memory, and write is for writing memory; in case that wasn't clear.

You can't do operations directly on a value in memory; that's why you need to read it first. Once it's in a register, you can do whatever you want to it, provided what you want is to add it to another number, because that's the only arithmetic instruction I've implemented so far. After that, you can write it back to memory. For now, read and write always use register R0, but I'll probably make that more flexible in the future.

Variables

Keeping track of memory addresses while you are programming is most inconvenient; it's much easier to use variables. Instead of introducing some special syntax for variables, I can reuse labels, because they translate to memory addresses.

Pointers

Right now, you have to hard-code your memory addresses. Sure, you can use labels for that, but the assembler still translates them to static numbers. What if you want to change the address at run-time? You'll need a pointer. I introduced the DP-register as a designated pointer. You can set it, you can increment it, and you can use it to read and write memory.

Instruction set

I can't decide whether the current instruction set is comically bad or tragically bad. It's missing a lot of basic operations, there's no reason it has to default to R0 for everything, and an extra register or two would be nice. If you struggle to write anything interesting with it, it's not your fault. If you didn't struggle to write anything interesting with it, then you probably didn't try writing anything. You should; it's fun! No wait, I just ruined the chance to convince you of that. Maybe try it anyway?

Instruction Description
set_r0 value Assigns the specified value to the R0 register.
set_r1 value Assigns the specified value to the R1 register.
swap Swaps the values of the R0 register and the R1 register.
add Adds the values of the R0 register and the R1 register and stores the result in R0.
jump address Sets the instruction pointer to the specified address.
read address Reads the value stored in memory at the specified address and assigns it to register R0.
write address Writes the value stored in register R0 to memory at the specified address.
set_dp value Assigns the specified value to the DP register.
inc_dp Increments the value in the DP register by one.
read_dp Reads the value stored in memory at the address specified by the DP register and assigns it to register R0.
write_dp Writes the value stored in register R0 to memory at the address specified by the DP register.