risc-v-tlm/tests/C/func3/func3.c

44 lines
512 B
C
Raw Normal View History

2018-10-15 23:36:07 +08:00
#include <string.h>
#define TRACE (*(unsigned char *)0x40000000)
void print(char *msg) {
int i = 0;
while(msg[i] != '\0') {
TRACE = msg[i];
i++;
}
}
int func1(int a, int* b) {
return a - (*b);
}
2019-01-10 06:03:08 +08:00
int main(void) {
2018-10-15 23:36:07 +08:00
int x1, x2, x3;
int aux[5] = {0};
int aux2[5];
2019-01-10 06:03:08 +08:00
TRACE = 'a';
TRACE = 'b';
2018-10-15 23:36:07 +08:00
x1 = 6;
x2 = 7;
x3 = func1(x1, &x2);
if (x3 == (6-7)) {
2019-01-10 06:03:08 +08:00
print("\nOK\n");
2018-10-15 23:36:07 +08:00
} else {
2019-01-10 06:03:08 +08:00
print("\nERROR\n");
2018-10-15 23:36:07 +08:00
}
memcpy(aux, aux2, 5);
2019-01-10 06:03:08 +08:00
asm volatile ("ecall");
return 0;
2018-10-15 23:36:07 +08:00
}