lei
lei

Reputation: 35

Riscv-gcc can't recognize opcode b

When i use riscv-gcc to compile a simple assembly program, it tells me it can't recognize opcode b 1b, here is the program:

   ...
   sll x28,x28,1;
1: b 1b

b 1b is the last instruction, a loop.

The program is from riscv-sodor project. Why does the compilation fail?

Upvotes: 1

Views: 357

Answers (1)

Chris
Chris

Reputation: 3987

The problem is you're using the newer compiler gcc 4.9, which includes a new ABI and some changes to accepted psuedo-ops. The Sodor repository (as of 2015 Apr) contains assembly code that targets the deprecated gcc 4.6-port.

You can quickly change "b" to a "j".

For additional information on the gcc4.9 update:

https://riscv.org/2015/01/announcing-the-risc-v-gcc-4-9-port-and-new-abi/

And the chapter on the new ABI:

https://riscv.org/wp-content/uploads/2015/01/riscv-calling.pdf

Changes include the removal of v0/v1 (now a0/a1).

Upvotes: 2

Related Questions