Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
2
2022fall-Compiler_CMinus
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
6
Merge Requests
6
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李晓奇
2022fall-Compiler_CMinus
Commits
d158e39e
You need to sign in or sign up before continuing.
Commit
d158e39e
authored
Feb 03, 2023
by
甘文迪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix float
parent
c736471e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
7 deletions
+25
-7
Documentations/5-bonus/README.md
Documentations/5-bonus/README.md
+10
-7
src/io/io.h
src/io/io.h
+7
-0
tests/5-bonus/testcases/10-float.cminus
tests/5-bonus/testcases/10-float.cminus
+8
-0
No files found.
Documentations/5-bonus/README.md
View file @
d158e39e
...
...
@@ -48,7 +48,7 @@
1.
当函数参数个数大于 8 个时,如何传递参数?
2.
浮点常量、全局变量是如何存储的?
> 可以写一段 C 语言代码,
在龙芯上用 `gcc -S
` 生成汇编代码,观察汇编代码,思考如何实现。
> 可以写一段 C 语言代码,
将该文件命名为 `test.c`,在龙芯上用 `gcc -include io.h -S test.c
` 生成汇编代码,观察汇编代码,思考如何实现。
### 完成代码
...
...
@@ -95,15 +95,18 @@ cmake ..
make
```
编译后会产生
`cminusfc`
可执行文件,使用
`cminusfc -S test.cminus`
编译
`test.cminus`
源文件,生成
`test.s`
汇编文件。
编译后会产生
`cminusfc`
可执行文件,使用
`cminusfc -S test.cminus`
编译
`test.cminus`
源文件,生成
`test.s`
汇编文件。
> 可以
开启 `-mem2reg` 选项来简化 IR
> 可以
选择开启 `cminusfc` 的 `-mem2reg` 选项优化中间代码
学生可以本地运行生成汇编代码,然后传输到龙芯服务器,代码如下:
学生可以先本地运行生成汇编代码,然后将
`test.s`
`io.c`
`io.h`
传输到龙芯服务器,再在龙芯服务器上运行:
> 假设 test.c 在仓库根目录下,用户的用户名为 username
```
bash
scp src/io/io.c username@202.38.75.246
scp test.s username@202.38.75.246
build/cminusfc
-S
test.cminus
scp src/io/io.c src/io/io.h test.s username@202.38.75.246:~/
ssh username@202.38.75.246
# 以下命令在 ssh 会话中执行
...
...
@@ -116,7 +119,7 @@ echo $?
在龙芯服务器,loongnix系统上将源代码编译为汇编代码命令如下,
```
```
bash
gcc test.s io.c
-Wa
,--gdwarf2
-o
test
# 也可以利用静态链接库进行编译
gdb
test
```
...
...
src/io/io.h
0 → 100644
View file @
d158e39e
int
input
();
void
output
(
int
a
);
void
outputFloat
(
float
a
);
void
neg_idx_except
();
tests/5-bonus/testcases/10-float.cminus
View file @
d158e39e
...
...
@@ -10,3 +10,11 @@ int main(void) {
outputFloat(a * b + c);
return 0;
}
/*
用 gcc 编译此文件生成汇编代码时,命令为 gcc -include io.h -S 10-float.c
其中 io.h 位于 src/io/io.h,
也可以在本文件开头加上 void outputFloat(float x);
*/
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment