Created
July 25, 2019 06:39
-
-
Save kohnakagawa/7d8914bc34fe02090c6fd091685463b7 to your computer and use it in GitHub Desktop.
RISC-Vでprogram counte を取得するためのコード
This file contains hidden or 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
#include <stdio.h> | |
#define GET_PC ({ register long tmp asm("a0");\ | |
__asm__ __volatile__ ("auipc %0, 0\n\t": "=r"(tmp));\ | |
tmp; }) | |
int main() { | |
const int pc = GET_PC; | |
printf("%x\n", pc); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment