Created
January 28, 2019 12:08
-
-
Save rbarzic/b8482e6e76b6fea4e05720cb6e3da5ee to your computer and use it in GitHub Desktop.
riscv custom instruction in inline assembly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From https://groups.google.com/a/groups.riscv.org/d/msg/isa-dev/fONrcF2lxhQ/sb2ZN5Q_AQAJ | |
rohan:2183$ cat tmp.c | |
int | |
sub (int a, int b) | |
{ | |
int result; | |
asm (".insn r 0x33, 0, 0, %0, %1, %2" : "=r" (result) : "r" (a), "r" (b)); | |
return result; | |
} | |
rohan:2184$ riscv32-unknown-elf-gcc -O2 -c tmp.c | |
rohan:2185$ riscv32-unknown-elf-objdump -dr tmp.o | |
tmp.o: file format elf32-littleriscv | |
Disassembly of section .text: | |
00000000 <sub>: | |
0: 00b50533 add a0,a0,a1 | |
4: 8082 ret | |
rohan:2186$ | |
Jim |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment