mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
Update on assembly simple/spike
This commit is contained in:
parent
10921accdb
commit
14e53099f8
@ -10,7 +10,7 @@ $(TARGET): $(TARGET).c Makefile
|
||||
-static -nostdlib -nostartfiles -lm -lgcc -T../common/test.ld \
|
||||
-I../common \
|
||||
-O0 $(TARGET).c \
|
||||
../common/crt.S ../common/syscalls.c
|
||||
../common/crt.S ../common/syscalls.c comp1.s
|
||||
|
||||
clean:
|
||||
rm -f $(TARGET) $(TARGET).objdump
|
||||
|
10
examples/C/simple/comp1.s
Normal file
10
examples/C/simple/comp1.s
Normal file
@ -0,0 +1,10 @@
|
||||
.global _comp1
|
||||
_comp1:
|
||||
|
||||
li a0, 42
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
|
7
examples/C/simple/comp1.s~
Normal file
7
examples/C/simple/comp1.s~
Normal file
@ -0,0 +1,7 @@
|
||||
_comp1:
|
||||
|
||||
li a0, 1
|
||||
ret
|
||||
|
||||
|
||||
|
6
examples/C/simple/sim.s~
Normal file
6
examples/C/simple/sim.s~
Normal file
@ -0,0 +1,6 @@
|
||||
_comp1:
|
||||
|
||||
li a0, 1
|
||||
|
||||
|
||||
|
Binary file not shown.
@ -5,31 +5,36 @@
|
||||
//#include <stdio.h>
|
||||
#include "util.h"
|
||||
extern int printf(const char* fmt, ...);
|
||||
extern int _comp1(void);
|
||||
|
||||
/*
|
||||
long sum(long N) {
|
||||
/* long result, i;
|
||||
long result, i;
|
||||
result = 0;
|
||||
for (i=1; i<=N; i++) {
|
||||
result = result + i;
|
||||
}
|
||||
return result; */
|
||||
return result;
|
||||
|
||||
int a;
|
||||
// asm volatile ("li s0, 10;");
|
||||
asm volatile ("li s0, 10;");
|
||||
|
||||
asm volatile(
|
||||
"li %0, 10"
|
||||
// "csrrs %0, 0xF14, zero" //CSSRS rd, mhartid, 0
|
||||
: "=r"(a) //output
|
||||
: //input
|
||||
: //clobbered
|
||||
"li %0, 3;"
|
||||
// "csrrs %0, 0xF14, zero" //CSSRS rd, mhartid, 0
|
||||
: "=r"(a) //output
|
||||
: //input
|
||||
: //clobbered
|
||||
);
|
||||
return a;
|
||||
}
|
||||
*/
|
||||
|
||||
int main(void) {
|
||||
int s[1], expected[1];
|
||||
s[0] = sum(4);
|
||||
// s[0] = sum(4);
|
||||
s[0] = _comp1();
|
||||
printf("s = %d\n", s[0]);
|
||||
expected[0] = 10;
|
||||
expected[0] = 42;
|
||||
return verify(1, s, expected); // 0 means success
|
||||
}
|
||||
}
|
||||
|
11009
examples/C/simple/simple.dis
Normal file
11009
examples/C/simple/simple.dis
Normal file
File diff suppressed because it is too large
Load Diff
35
examples/C/simple/simple_orig.c
Normal file
35
examples/C/simple/simple_orig.c
Normal file
@ -0,0 +1,35 @@
|
||||
// simple.C
|
||||
// David_Harris@hmc.edu 24 December 2021
|
||||
// Simple illustration of compiling C code
|
||||
|
||||
//#include <stdio.h>
|
||||
#include "util.h"
|
||||
extern int printf(const char* fmt, ...);
|
||||
|
||||
long sum(long N) {
|
||||
/* long result, i;
|
||||
result = 0;
|
||||
for (i=1; i<=N; i++) {
|
||||
result = result + i;
|
||||
}
|
||||
return result; */
|
||||
|
||||
int a;
|
||||
// asm volatile ("li s0, 10;");
|
||||
asm volatile(
|
||||
"li %0, 10"
|
||||
// "csrrs %0, 0xF14, zero" //CSSRS rd, mhartid, 0
|
||||
: "=r"(a) //output
|
||||
: //input
|
||||
: //clobbered
|
||||
);
|
||||
return a;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
int s[1], expected[1];
|
||||
s[0] = sum(4);
|
||||
printf("s = %d\n", s[0]);
|
||||
expected[0] = 10;
|
||||
return verify(1, s, expected); // 0 means success
|
||||
}
|
Loading…
Reference in New Issue
Block a user