从今天开始,进入到《计算机原理》实验课环节。
环境准备,参考下文:
下载地址 密码:564r
请先下载《实验环境下载及安装说明》文档,根据说明文档来下载及安装对应的文件。
下载地址1文件列表:
实验环境下载及安装说明.pdf(请优先下载阅读)。
for vmware 10.zip:为vmware workstations 10配套的虚拟机环境。
for vmware 12.zip:为vmware workstations 12配套的虚拟机环境。
gcc_handbook.pdf:gcc指导手册。
PS.若已经使用的就是类UNIX操作系统,例如:Ubuntu 或者 Mac 可以跳过这里的安装过程。当然也可以使用 wmware 安装 Ubuntu 虚拟机也是可以的,都可以在网上找到很多安装教程,自己实践一下,遇到问题总是好的。
运行过程:
Microsoft Windows XP [版本 5.1.2600]
(C) 版权所有 1985-2001 Microsoft Corp.
C:\>gcc --help
Usage: gcc [options] file...
Options:
-pass-exit-codes Exit with highest error code from a phase
--help Display this information
--target-help Display target specific command line options
(Use '-v --help' to display command line options of sub-processes)
-dumpspecs Display all of the built in spec strings
-dumpversion Display the version of the compiler
-dumpmachine Display the compiler's target processor
-print-search-dirs Display the directories in the compiler's search path
-print-libgcc-file-name Display the name of the compiler's companion library
-print-file-name=<lib> Display the full path to library <lib>
-print-prog-name=<prog> Display the full path to compiler component <prog>
-print-multi-directory Display the root directory for versions of libgcc
-print-multi-lib Display the mapping between command line options and
multiple library search directories
-print-multi-os-directory Display the relative path to OS libraries
-Wa,<options> Pass comma-separated <options> on to the assembler
-Wp,<options> Pass comma-separated <options> on to the preprocessor
-Wl,<options> Pass comma-separated <options> on to the linker
-Xassembler <arg> Pass <arg> on to the assembler
-Xpreprocessor <arg> Pass <arg> on to the preprocessor
-Xlinker <arg> Pass <arg> on to the linker
-save-temps Do not delete intermediate files
-pipe Use pipes rather than intermediate files
-time Time the execution of each subprocess
-specs=<file> Override built-in specs with the contents of <file>
-std=<standard> Assume that the input sources are for <standard>
-B <directory> Add <directory> to the compiler's search paths
-b <machine> Run gcc for target <machine>, if installed
-V <version> Run gcc version number <version>, if installed
-v Display the programs invoked by the compiler
-### Like -v but options quoted and commands not executed
-E Preprocess only; do not compile, assemble or link
-S Compile only; do not assemble or link
-c Compile and assemble, but do not link
-o <file> Place the output into <file>
-x <language> Specify the language of the following input files
Permissible languages include: c c++ assembler none
'none' means revert to the default behavior of
guessing the language based on the file's extension
Options starting with -g, -f, -m, -O, -W, or --param are automatically
passed on to the various sub-processes invoked by gcc. In order to pass
other options on to these processes the -W<letter> options must be used.
For bug reporting instructions, please see:
<URL:http://www.mingw.org/bugs.shtml>.
C:\>cd helloworld
C:\helloworld>gcc -E hello.c -o hello.i
C:\helloworld>gcc -S hello.i
C:\helloworld>gcc -c hello.s
C:\helloworld>dir
驱动器 C 中的卷没有标签。
卷的序列号是 34AB-7561
C:\helloworld 的目录
2021-04-29 00:48 <DIR> .
2021-04-29 00:48 <DIR> ..
2016-01-29 11:59 6,173 hello-mips.exe
2016-01-29 11:58 878 hello-mips.s
2016-01-29 12:00 9,243 hello-mips.txt
2015-11-10 08:34 85 hello.c
2015-12-02 20:11 15,883 hello.exe
2021-04-29 00:44 16,855 hello.i
2021-04-29 00:48 574 hello.o
2021-04-29 00:47 486 hello.s
2015-12-11 11:07 39,589 hello.txt
9 个文件 89,766 字节
2 个目录 37,631,598,592 可用字节
C:\helloworld>gcc hello.o -o hello.exe
C:\helloworld>hello
Hello world!
运行截图: