0

I am trying to add a custom instruction which has 4 operands. It does multiply and accumulate (a*b+c) to the first 3 source registers and then store the result in the destination register. It multiplies the first 2 source registers and then add the value to the 3rd register and the stores it in the destination register.

I used inline assembly to call the custom instruction. When I converted the C-code to assembly the instruction was called successfully. But when I am trying to compile the C-code I am getting this error.

riscv64-unknown-elf-gcc mac4op.c

/home/chaitanya/riscv_custom/lib/gcc/riscv64-unknown-elf/14.2.0/../../../../riscv64-unknown-elf/bin/ld: /tmp/cc5VUpL0.o: in function main': mac4op.c:(.text+0x30): undefined reference to a3'

collect2: error: ld returned 1 exit status

Do anyone know the reason for this?

I added the custom instruction into the tool chain and I also converted into the assembly language successfully. But I am facing the above error when I am compiling the code.

2
  • Compile your C file without linking then disassemble it (objdump -dr to get relocations). It kinda looks like your compiler decided a3 was an external symbol and not a register. Commented Feb 10 at 14:03
  • *Assembler rather. The compiler merely transfers inline assembly as is; assembler converts it into machine code. So ensure your modified assembler treats these new instructions the way it should. Ensure that object files produced by the assembler contain what you need it to, before going up to the compiler and down to the linker. Commented Feb 10 at 14:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.