First (trivial) test program!

A project log for risk-vee

An as-small-as-possible RISC-V implementation in Logisim.

Nicky NickellNicky Nickell 12/22/2016 at 03:572 Comments
addi r1, r1, 1
add r2, r1, r1
jalr r0, r0, 0

All it does is increment r1 and set r2 to r1*2 in a loop. Told you it was trivial.

It comes out as the following for anyone wanting to poke it into memory themselves. A RAM image of it is in the project files as well.

93 80 10 00 33 81 10 00 67 00 00 00
I usually like the bit where you have to hand assemble your first few programs. Usually. It isn't so bad when you have variable length instructions, but setting the bits in a fixed length architecture is a real pain.

Time to either write an assembler or get the gnu riscv toolchain set up.


Phil Wright wrote 12/22/2016 at 04:58 point

You could also try using ...

jal r0, -8 that it jumps backwards the two instructions, then your not dependent on starting at location zero.

  Are you sure? yes | no

Nicky Nickell wrote 12/22/2016 at 05:37 point

That was actually what I was going to do at first, but I didn't want to futz with doing the J immediate by hand. JALRing to 0 is just me being lazy.

  Are you sure? yes | no