Adds hello world
This commit is contained in:
parent
e6a210e0c4
commit
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
Normal file
7
helloworld/helloriscv.c
Normal file
@ -0,0 +1,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf("Hello RISC-V");
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user