Adds hello world
このコミットが含まれているのは:
コミット
b0e6f0813d
@ -1,25 +0,0 @@
|
||||
#include <stdio.h>
|
||||
|
||||
uint64_t getcycles();
|
||||
static void do_something()
|
||||
{
|
||||
for (int i = 0; i < 1000; ++i) {
|
||||
__asm__("NOP");
|
||||
}
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Instruction cache misses are relatively expensive, so for more
|
||||
// consistent benchmarks that depend less on the relative speed of
|
||||
// the QSPI flash, you might want to fill the instruction cache first.
|
||||
// Note that it can hold 16 KiB of instructions on the HiFive1.
|
||||
do_something();
|
||||
getcycles();
|
||||
uint64_t oldcount = getcycles();
|
||||
do_something();
|
||||
uint64_t newcount = getcycles();
|
||||
|
||||
printf("That took %d cycles.\n", (unsigned int)(newcount-oldcount));
|
||||
return 0;
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
.text
|
||||
|
||||
.globl getcycles
|
||||
.align 2
|
||||
getcycles:
|
||||
csrr a1, mcycleh
|
||||
csrr a0, mcycle
|
||||
csrr a2, mcycleh
|
||||
bne a1, a2, getcycles
|
||||
ret
|
@ -1,6 +1,6 @@
|
||||
TARGET := cyclecount.elf
|
||||
LOCAL_SRC_C := cyclecount.c
|
||||
LOCAL_SRC_S := getcycles.S
|
||||
TARGET := helloriscv.elf
|
||||
LOCAL_SRC_C := helloriscv.c
|
||||
LOCAL_SRC_S :=
|
||||
LOCAL_OPT_C := -Os -fno-builtin-printf -Wall -Wextra -pedantic
|
||||
|
||||
include ../conf/toolchain.mk
|
7
helloworld/helloriscv.c
ノーマルファイル
7
helloworld/helloriscv.c
ノーマルファイル
@ -0,0 +1,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf("Hello RISC-V");
|
||||
return 0;
|
||||
}
|
読み込み中…
新しいイシューから参照
ユーザーをブロックする