1
votes

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?

1
Which riscv-gcc version are you using (use --version)? The current riscv-tools repository uses 4.9, which may have deprecated the "b" psuedo-op". You could of course just change that line of code to "1: j 1b". - Chris
thank you , my gcc version is 4.9.2, i change the 'b' to 'j' ,and it works. - lei
another question, i find in gcc 4.9.2, the ABI alse different from 'The RISC-V Instruction Set Manual version 2.0', for example, the manul says 'a0' represent 'x18' register, but when i use gcc 4.9.2 compile a program and dump ,i find 'a0' represent 'x10' register, do you know when the manual will update ? - lei

1 Answers

2
votes

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).