diff --git a/sylib/libsysy_riscv.a b/sylib/libsysy_riscv.a new file mode 100644 index 0000000..58c7fbd Binary files /dev/null and b/sylib/libsysy_riscv.a differ diff --git a/sylib/sylib.c b/sylib/sylib.c index 20ddb7d..dc3d92c 100644 --- a/sylib/sylib.c +++ b/sylib/sylib.c @@ -1,42 +1,83 @@ -// SysY 运行库实现: -// - 按实验/评测规范提供 I/O 等函数实现 -// - 与编译器生成的目标代码链接,支撑运行时行为 - #include +#include +#include #include"sylib.h" /* Input & output functions */ int getint(){int t; scanf("%d",&t); return t; } int getch(){char c; scanf("%c",&c); return (int)c; } +float getfloat(){ + float n; + scanf("%a", &n); + return n; +} + int getarray(int a[]){ + int n; + scanf("%d",&n); + for(int i=0;i /* Input & output functions */ int getint(),getch(),getarray(int a[]); -void putint(int a),putch(int a),putarray(int n,int a[]); float getfloat(); -void putfloat(float a); int getfarray(float a[]); -void putfarray(int n,float a[]); -/* Timing functions */ -void starttime(); -void stoptime(); + +void putint(int a),putch(int a),putarray(int n,int a[]); +void putfloat(float a); +void putfarray(int n, float a[]); + +void putf(char a[], ...); + +/* Timing function implementation */ +struct timeval _sysy_start,_sysy_end; +#define starttime() _sysy_starttime(__LINE__) +#define stoptime() _sysy_stoptime(__LINE__) +#define _SYSY_N 1024 +int _sysy_l1[_SYSY_N],_sysy_l2[_SYSY_N]; +int _sysy_h[_SYSY_N], _sysy_m[_SYSY_N],_sysy_s[_SYSY_N],_sysy_us[_SYSY_N]; +int _sysy_idx; +__attribute((constructor)) void before_main(); +__attribute((destructor)) void after_main(); +void _sysy_starttime(int lineno); +void _sysy_stoptime(int lineno); + #endif