日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢(xún)
選擇下列產(chǎn)品馬上在線(xiàn)溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
“C語(yǔ)言”讀書(shū)札記之[編譯執(zhí)行]

介紹

成都創(chuàng)新互聯(lián)公司是由多位在大型網(wǎng)絡(luò)公司、廣告設(shè)計(jì)公司的優(yōu)秀設(shè)計(jì)人員和策劃人員組成的一個(gè)具有豐富經(jīng)驗(yàn)的團(tuán)隊(duì),其中包括網(wǎng)站策劃、網(wǎng)頁(yè)美工、網(wǎng)站程序員、網(wǎng)頁(yè)設(shè)計(jì)師、平面廣告設(shè)計(jì)師、網(wǎng)絡(luò)營(yíng)銷(xiāo)人員及形象策劃。承接:成都網(wǎng)站建設(shè)、網(wǎng)站制作、網(wǎng)站改版、網(wǎng)頁(yè)設(shè)計(jì)制作、網(wǎng)站建設(shè)與維護(hù)、網(wǎng)絡(luò)推廣、數(shù)據(jù)庫(kù)開(kāi)發(fā),以高性?xún)r(jià)比制作企業(yè)網(wǎng)站、行業(yè)門(mén)戶(hù)平臺(tái)等全方位的服務(wù)。

現(xiàn)在C語(yǔ)言跨的領(lǐng)域非常之多,如游戲、嵌入式、智能電器等。為什么不直接用匯編或機(jī)器語(yǔ)言直接寫(xiě)呢?原因是匯編和機(jī)器語(yǔ)言受到計(jì)算機(jī)體系結(jié)構(gòu)的影響。直接用某種體系結(jié)構(gòu)的匯編或機(jī)器指令寫(xiě)出來(lái)的程序只能在這種體系結(jié)構(gòu)的計(jì)算機(jī)上運(yùn)行。

C語(yǔ)言的好處是各種體系結(jié)構(gòu)的計(jì)算機(jī)都有各自的C編譯器,可以把C程序編譯成各種不同體系結(jié)構(gòu)的機(jī)器指令,這意味著用C語(yǔ)言寫(xiě)的程序只需稍加修改甚至不用修改就可以在各種不同的計(jì)算機(jī)上編譯運(yùn)行。

hello,world

我們從簡(jiǎn)單hello,world開(kāi)始——有人說(shuō)了,又來(lái)了,這個(gè)“hello,world”,好多博友都寫(xiě)這種東西煩不煩?呵呵,那我寫(xiě)的也許跟他們說(shuō)的不一樣呢?或者理解的跟別人有不一樣的地方。

先寫(xiě)個(gè)程序我們看看。

源程序(或者源文件):是程序員通過(guò)文本編輯器創(chuàng)建并保存的文本文件。源程序?qū)嶋H就是由0和1組成的位序列,這些位8個(gè)一組,成為字節(jié),每個(gè)字節(jié)通過(guò)ASCII字符集(大部分是)對(duì)應(yīng)一個(gè)文本字符。

下面是上面程序?qū)?yīng)的16進(jìn)制數(shù)字表示

在終端輸入man ascii看看ascii表

#p#

操作步驟:

查看16進(jìn)制格式

回復(fù)到文本格式

我們看看對(duì)應(yīng)的二進(jìn)制是什么樣的?——這個(gè)也是在磁盤(pán)中的存儲(chǔ)狀態(tài)。

總結(jié):

系統(tǒng)中所有的信息——包括磁盤(pán)文件、存儲(chǔ)器中的程序,存儲(chǔ)器中存放的用戶(hù)數(shù)據(jù)以及網(wǎng)絡(luò)上傳送的數(shù)據(jù),都是由一串比特表示的。

思考:

同樣的一套字節(jié)序列可能在不同的上下文中表示一個(gè)整數(shù)、浮點(diǎn)數(shù)、字符串或者機(jī)器指令?!@取決于數(shù)據(jù)對(duì)象的上下文。

我們?cè)撟鍪裁矗?/p>

做為程序員,我們需要了解數(shù)字的機(jī)器表示方式,因?yàn)樗鼈兣c常見(jiàn)的整數(shù)和實(shí)數(shù)是不同的。

使用參考:在Linux下使用vim配合x(chóng)xd查看并編輯二進(jìn)制文件

#p#

翻譯

源程序是能夠被人讀懂的,為了能在系統(tǒng)上運(yùn)行,我們需要把C語(yǔ)句通過(guò)其他程序轉(zhuǎn)化為一系列的低級(jí)機(jī)器語(yǔ)言指令。然后這些指令按照一種稱(chēng)為“可執(zhí)行目標(biāo)程序“的格式打包好,并以二進(jìn)制磁盤(pán)文件的形式存放起來(lái)。

在Linux系統(tǒng)上,從源文件到目標(biāo)文件(可執(zhí)行目標(biāo)程序文件)的轉(zhuǎn)化是由編譯器驅(qū)動(dòng)程序完成的。如下圖:

我們用GCC工具觀察每個(gè)階段。(GCC:GNU Compiler Collection,GNU編譯器套裝)

先贈(zèng)送一張gcc命令選項(xiàng)圖

預(yù)處理階段

查看main.i的部分源碼

總結(jié):預(yù)處理器(cpp)根據(jù)以字符#開(kāi)頭的命令,修改原始C程序,結(jié)果得到了另一個(gè)C程序(還是C程序),通常以i做為文件擴(kuò)展名。

編譯階段

查看main.s的源碼

總結(jié):將C語(yǔ)言文本文件翻譯成匯編語(yǔ)言文本文件。——匯編語(yǔ)言是非常有用的,因?yàn)樗鼮椴煌呒?jí)語(yǔ)言的不同編譯器提供了通用的輸出語(yǔ)言。

匯編階段

打開(kāi)源代碼,注意此時(shí)為二進(jìn)制磁盤(pán)文件,還有注意操作步驟

此時(shí)為亂碼,需要進(jìn)行:%!xxd操作

查看指令

總結(jié):匯編器(as)將main.s翻譯成機(jī)器語(yǔ)言指令,把這些指令打包成為一種“可重定位目標(biāo)程序“的格式,并將結(jié)果保存到main.o文件中,main.o是二進(jìn)制文件,它的字節(jié)編碼是機(jī)器語(yǔ)言指令而不是字符(所以用文本編譯器看會(huì)出現(xiàn)亂碼)。

鏈接階段

按照匯編階段操作,查看部分指令碼

總結(jié):程序中調(diào)用了printf函數(shù),它是C標(biāo)準(zhǔn)庫(kù)的一個(gè)函數(shù),printf函數(shù)存在于一個(gè)名為printf.o的單獨(dú)的預(yù)編譯目標(biāo)文件中。連接器(ld)負(fù)責(zé)把printf.o的預(yù)編譯目標(biāo)文件進(jìn)行并入,結(jié)果就得到a.out文件。

NOTE:a.out是可執(zhí)行的目標(biāo)文件,而main.o是可重定位目標(biāo)程序文件?!蓤?zhí)行目標(biāo)文件加載到系統(tǒng)存儲(chǔ)器后,由系統(tǒng)負(fù)責(zé)執(zhí)行。而可重定位目標(biāo)程序文件是提供給鏈接器使用,執(zhí)行并入操作。

總結(jié)

這一篇主要是學(xué)習(xí)gcc編譯器的編譯過(guò)程,對(duì)整個(gè)過(guò)程有所熟悉。如果有好的知識(shí)點(diǎn),望大家賜教。

#p#

vim配置分享

 
 
 
 
  1. " An example for a vimrc file.
  2. "
  3. " Maintainer:   Bram Moolenaar 
  4. " Last change:  2006 Nov 16
  5. "
  6. " To use it, copy it to
  7. "     for Unix and OS/2:  ~/.vimrc
  8. "         for Amiga:  s:.vimrc
  9. "  for MS-DOS and Win32:  $VIM\_vimrc
  10. "       for OpenVMS:  sys$login:.vimrc
  11. " When started as "evim", evim.vim will already have done these settings.
  12. if v:progname =~? "evim"
  13.   finish
  14. endif
  15. " Use Vim settings, rather then Vi settings (much better!).
  16. " This must be first, because it changes other options as a side effect.
  17. set nocompatible
  18. " allow backspacing over everything in insert mode
  19. set backspace=indent,eol,start
  20. if has("vms")
  21.   set nobackup      " do not keep a backup file, use versions instead
  22. else
  23.   set nobackup      " keep [NO] backup file
  24. endif
  25. set history=250     " keep 250 lines of command line history
  26. set ruler       " show the cursor position all the time
  27. set showcmd     " display incomplete commands
  28. set incsearch      " do incremental searching
  29. set nu
  30. " For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
  31. " let &guioptions = substitute(&guioptions, "t", "", "g")
  32. " Don't use Ex mode, use Q for formatting
  33. map Q gq
  34. " In many terminal emulators the mouse works just fine, thus enable it.
  35. set mouse=a
  36. " Switch syntax highlighting on, when the terminal has colors
  37. " Also switch on highlighting the last used search pattern.
  38. if &t_Co > 2 || has("gui_running")
  39.   syntax on
  40.   set hlsearch
  41. endif
  42. " Only do this part when compiled with support for autocommands.
  43. if has("autocmd")
  44.   " Enable file type detection.
  45.   " Use the default filetype settings, so that mail gets 'tw' set to 72,
  46.   " 'cindent' is on in C files, etc.
  47.   " Also load indent files, to automatically do language-dependent indenting.
  48.   filetype plugin indent on
  49.   " Put these in an autocmd group, so that we can delete them easily.
  50.   augroup vimrcEx
  51.   au!
  52.   " For all text files set 'textwidth' to 78 characters.
  53.   autocmd FileType text setlocal textwidth=78
  54.   " When editing a file, always jump to the last known cursor position.
  55.   " Don't do it when the position is invalid or when inside an event handler
  56.   " (happens when dropping a file on gvim).
  57.   autocmd BufReadPost *
  58.     \ if line("'\"") > 0 && line("'\"") <= line("$") |
  59.     \   exe "normal! g`\"" |
  60.     \ endif
  61.   autocmd VimLeave *
  62.     \ if has("mksession") && exists("v:this_session") && v:this_session != "" |
  63.     \   exec "mksession!" v:this_session |
  64.     \ endif
  65.   augroup END
  66. else
  67.   set autoindent        " always set autoindenting on
  68. endif " has("autocmd")
  69. " Convenient command to see the difference between the current buffer and the
  70. " file it was loaded from, thus the changes you made.
  71. command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
  72.         \ | wincmd p | diffthis
  73. " Add by Journeylee to make things more easily
  74. set softtabstop=4
  75. set shiftwidth=4
  76. set tabstop=4
  77. set noexpandtab
  78. set smarttab
  79. set showmatch
  80. set foldenable
  81. set autoindent
  82. set smartindent
  83. set cindent
  84. set foldmethod=marker
  85. set background=dark
  86. set nobackup
  87. set encoding=utf-8
  88. language en_US.utf8
  89. set fileencodings=ucs-bom,utf-8,gbk,latin1
  90. set fileformats=unix,dos,mac
  91. set fileencoding=utf-8
  92. set fileformat=unix
  93. set fileformat=unix
  94. set matchtime=15
  95. " Make shift-insert work like in Xterm
  96. map  
  97. map!  
  98. " let xterm16_brightness = 'default'     " Change if needed
  99. " let xterm16_colormap = 'allblue'       " Change if needed
  100. " colo xterm16 
  101. "不使用swap文件
  102. map  :!php -l %
  103. "set runtimepath+=/home/zhoubc/opt/vim/doc
  104. "autocmd BufNewFile,Bufread *.ros,*.inc,*.php set keywordprg="help"
  105. let g:winManagerWindowLayout='TagList|FileExplorer'
  106. let g:winManagerWidth=30
  107. nmap  wm :WMToggle

分享題目:“C語(yǔ)言”讀書(shū)札記之[編譯執(zhí)行]
文章源于:http://www.5511xx.com/article/cdceosd.html