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 00I 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.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.
You could also try using ...
jal r0, -8
...so that it jumps backwards the two instructions, then your not dependent on starting at location zero.
Are you sure? yes | no
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