Recently in the study of "in-depth understanding of computer systems," The code is in the Linux environment in the C language, because the use of the GCC compilation environment, for the convenience of my study, special in the Windows environment download MINGM, and with sublime editor, play a great function, Ability to implement simple C program compilation, run, and decompile to view assembly code.
1. Installing MinGW
MinGW is installed automatically during the installation of Dev C + +, and installation MinGW can be downloaded separately.
2. Configure Environment variables
There are many commands in the MinGW bin file, in order for these executable commands to be used directly in the console, the environment variables need to be configured, depending on the MinGW file path
(I: C:\Program Files (x86) \DEV-CPP\MINGW64), configure environment variables.
" name= ' path ' and username= ' <system> ' "Set variablevalue="%path%; C:\Program Files (x86) \dev-cpp\mingw64w\bin "WMIC environment create name="library_path ", username= "<system>", variablevalue= "C:\Program Files (x86) \dev-cpp\mingw64\lib"WMIC environment create Name=" C_includede_path ", username=" <system> ", variablevalue=" C:\Program Files (x86) \dev-cpp\mingw64\ Include "
Copy the above code, paste into the new text document, Save as "**.bat", right-run as administrator, configure environment variables to complete.
3. Construct C language compiling system
Select tool–> build system–> New build System
Then enter the following code:
{"Working_dir":"$file _path","cmd":"gcc-wall \ "$file _name\"-o \ "$file _base_name\"","File_regex":"^(.. [^:]*]:([0-9]+):? ([0-9]+)?:? (.*)$","selector":"source.c","variants":[{"name":"Run","Shell_cmd":"gcc-wall \ "$file \"-o \ "$file _base_name\" && start cmd/c \ "${file_path}/${file_base_name} & Pause\" "}]}
Press Ctrl+s save, will automatically open the User directory (Sublime Text 3\packages\user), we modified the file name is C.sublime-build, saved in this directory.
This will open the. c file in the default type C, and press Ctrl+shift+b to compile and run the C program.
4. Construction of C + + language compiling system
Step above, just insert the code in the GCC that is g++, source.c to source.c++, save the file name C.sublime-build changed to C++.sublime-build on it;
{"encoding":"Utf-8","Working_dir":"$file _path","Shell_cmd":"g++-wall-std=c++11 \ "$file _name\"-o \ "$file _base_name\"","File_regex":"^(.. [^:]*]:([0-9]+):? ([0-9]+)?:? (.*)$","selector":"source.c++","variants":[{"name":"Run","Shell_cmd":"g++-wall-std=c++11 \ "$file \" o \ "$file _base_name\" && start cmd/c \ "${file_path}/${file_base_name} & P Ause\ ""}]
}5. Compiling and deserializing commands
For a C program, use the command gcc-s main.c to generate the corresponding assembly code main. S, you can open the view directly with a text editor.
For the generated object file, you can disassemble it with the Objdump command.
Objdump-t obj output target file symbol table ()
Objdump-h obj outputs all segments of the target file ()
Objdump-j. text/.data-s obj outputs information for the specified segment
Objdump-s obj C language and assembly language display simultaneously
objdump-d obj disassembly of sections that should also have instruction machine code
Sublime configuring C and C + + compilation Run environment