亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? nasmdoc8.htm

?? nasm手冊 大家可以看看 對要寫匯編程序的幫助很大
?? HTM
?? 第 1 頁 / 共 2 頁
字號:
<html><head><title>NASM Manual</title></head><body><h1 align=center>The Netwide Assembler: NASM</h1><p align=center><a href="nasmdoc9.html">Next Chapter</a> |<a href="nasmdoc7.html">Previous Chapter</a> |<a href="nasmdoc0.html">Contents</a> |<a href="nasmdoci.html">Index</a><h2><a name="chapter-8">Chapter 8: Writing 32-bit Code (Unix, Win32, DJGPP)</a></h2><p>This chapter attempts to cover some of the common issues involved whenwriting 32-bit code, to run under Win32 or Unix, or to be linked with Ccode generated by a Unix-style C compiler such as DJGPP. It covers how towrite assembly code to interface with 32-bit C routines, and how to writeposition-independent code for shared libraries.<p>Almost all 32-bit code, and in particular all code running under<code><nobr>Win32</nobr></code>, <code><nobr>DJGPP</nobr></code> or any ofthe PC Unix variants, runs in <em>flat</em> memory model. This means thatthe segment registers and paging have already been set up to give you thesame 32-bit 4Gb address space no matter what segment you work relative to,and that you should ignore all segment registers completely. When writingflat-model application code, you never need to use a segment override ormodify any segment register, and the code-section addresses you pass to<code><nobr>CALL</nobr></code> and <code><nobr>JMP</nobr></code> live inthe same address space as the data-section addresses you access yourvariables by and the stack-section addresses you access local variables andprocedure parameters by. Every address is 32 bits long and contains only anoffset part.<h3><a name="section-8.1">8.1 Interfacing to 32-bit C Programs</a></h3><p>A lot of the discussion in <a href="nasmdoc7.html#section-7.4">section7.4</a>, about interfacing to 16-bit C programs, still applies when workingin 32 bits. The absence of memory models or segmentation worries simplifiesthings a lot.<h4><a name="section-8.1.1">8.1.1 External Symbol Names</a></h4><p>Most 32-bit C compilers share the convention used by 16-bit compilers,that the names of all global symbols (functions or data) they define areformed by prefixing an underscore to the name as it appears in the Cprogram. However, not all of them do: the <code><nobr>ELF</nobr></code>specification states that C symbols do <em>not</em> have a leadingunderscore on their assembly-language names.<p>The older Linux <code><nobr>a.out</nobr></code> C compiler, all<code><nobr>Win32</nobr></code> compilers, <code><nobr>DJGPP</nobr></code>,and <code><nobr>NetBSD</nobr></code> and <code><nobr>FreeBSD</nobr></code>,all use the leading underscore; for these compilers, the macros<code><nobr>cextern</nobr></code> and <code><nobr>cglobal</nobr></code>, asgiven in <a href="nasmdoc7.html#section-7.4.1">section 7.4.1</a>, willstill work. For <code><nobr>ELF</nobr></code>, though, the leadingunderscore should not be used.<p>See also <a href="nasmdoc2.html#section-2.1.21">section 2.1.21</a>.<h4><a name="section-8.1.2">8.1.2 Function Definitions and Function Calls</a></h4><p>The C calling conventionThe C calling convention in 32-bit programs isas follows. In the following description, the words <em>caller</em> and<em>callee</em> are used to denote the function doing the calling and thefunction which gets called.<ul><li>The caller pushes the function's parameters on the stack, one afteranother, in reverse order (right to left, so that the first argumentspecified to the function is pushed last).<li>The caller then executes a near <code><nobr>CALL</nobr></code>instruction to pass control to the callee.<li>The callee receives control, and typically (although this is notactually necessary, in functions which do not need to access theirparameters) starts by saving the value of <code><nobr>ESP</nobr></code> in<code><nobr>EBP</nobr></code> so as to be able to use<code><nobr>EBP</nobr></code> as a base pointer to find its parameters onthe stack. However, the caller was probably doing this too, so part of thecalling convention states that <code><nobr>EBP</nobr></code> must bepreserved by any C function. Hence the callee, if it is going to set up<code><nobr>EBP</nobr></code> as a frame pointer, must push the previousvalue first.<li>The callee may then access its parameters relative to<code><nobr>EBP</nobr></code>. The doubleword at<code><nobr>[EBP]</nobr></code> holds the previous value of<code><nobr>EBP</nobr></code> as it was pushed; the next doubleword, at<code><nobr>[EBP+4]</nobr></code>, holds the return address, pushedimplicitly by <code><nobr>CALL</nobr></code>. The parameters start afterthat, at <code><nobr>[EBP+8]</nobr></code>. The leftmost parameter of thefunction, since it was pushed last, is accessible at this offset from<code><nobr>EBP</nobr></code>; the others follow, at successively greateroffsets. Thus, in a function such as <code><nobr>printf</nobr></code> whichtakes a variable number of parameters, the pushing of the parameters inreverse order means that the function knows where to find its firstparameter, which tells it the number and type of the remaining ones.<li>The callee may also wish to decrease <code><nobr>ESP</nobr></code>further, so as to allocate space on the stack for local variables, whichwill then be accessible at negative offsets from<code><nobr>EBP</nobr></code>.<li>The callee, if it wishes to return a value to the caller, should leavethe value in <code><nobr>AL</nobr></code>, <code><nobr>AX</nobr></code> or<code><nobr>EAX</nobr></code> depending on the size of the value.Floating-point results are typically returned in<code><nobr>ST0</nobr></code>.<li>Once the callee has finished processing, it restores<code><nobr>ESP</nobr></code> from <code><nobr>EBP</nobr></code> if it hadallocated local stack space, then pops the previous value of<code><nobr>EBP</nobr></code>, and returns via<code><nobr>RET</nobr></code> (equivalently,<code><nobr>RETN</nobr></code>).<li>When the caller regains control from the callee, the functionparameters are still on the stack, so it typically adds an immediateconstant to <code><nobr>ESP</nobr></code> to remove them (instead ofexecuting a number of slow <code><nobr>POP</nobr></code> instructions).Thus, if a function is accidentally called with the wrong number ofparameters due to a prototype mismatch, the stack will still be returned toa sensible state since the caller, which <em>knows</em> how many parametersit pushed, does the removing.</ul><p>There is an alternative calling convention used by Win32 programs forWindows API calls, and also for functions called <em>by</em> the WindowsAPI such as window procedures: they follow what Microsoft calls the<code><nobr>__stdcall</nobr></code> convention. This is slightly closer tothe Pascal convention, in that the callee clears the stack by passing aparameter to the <code><nobr>RET</nobr></code> instruction. However, theparameters are still pushed in right-to-left order.<p>Thus, you would define a function in C style in the following way:<p><pre>global  _myfunc _myfunc:         push    ebp         mov     ebp,esp         sub     esp,0x40        ; 64 bytes of local stack space         mov     ebx,[ebp+8]     ; first parameter to function         ; some more code         leave                   ; mov esp,ebp / pop ebp         ret</pre><p>At the other end of the process, to call a C function from your assemblycode, you would do something like this:<p><pre>extern  _printf         ; and then, further down...         push    dword [myint]   ; one of my integer variables         push    dword mystring  ; pointer into my data segment         call    _printf         add     esp,byte 8      ; `byte' saves space         ; then those data items... segment _DATA myint       dd   1234 mystring    db   'This number -&gt; %d &lt;- should be 1234',10,0</pre><p>This piece of code is the assembly equivalent of the C code<p><pre>    int myint = 1234;     printf("This number -&gt; %d &lt;- should be 1234\n", myint);</pre><h4><a name="section-8.1.3">8.1.3 Accessing Data Items</a></h4><p>To get at the contents of C variables, or to declare variables which Ccan access, you need only declare the names as<code><nobr>GLOBAL</nobr></code> or <code><nobr>EXTERN</nobr></code>.(Again, the names require leading underscores, as stated in<a href="#section-8.1.1">section 8.1.1</a>.) Thus, a C variable declared as<code><nobr>int i</nobr></code> can be accessed from assembler as<p><pre>          extern _i           mov eax,[_i]</pre><p>And to declare your own integer variable which C programs can access as<code><nobr>extern int j</nobr></code>, you do this (making sure you areassembling in the <code><nobr>_DATA</nobr></code> segment, if necessary):<p><pre>          global _j _j        dd 0</pre><p>To access a C array, you need to know the size of the components of thearray. For example, <code><nobr>int</nobr></code> variables are four byteslong, so if a C program declares an array as<code><nobr>int a[10]</nobr></code>, you can access<code><nobr>a[3]</nobr></code> by coding<code><nobr>mov ax,[_a+12]</nobr></code>. (The byte offset 12 is obtainedby multiplying the desired array index, 3, by the size of the arrayelement, 4.) The sizes of the C base types in 32-bit compilers are: 1 for<code><nobr>char</nobr></code>, 2 for <code><nobr>short</nobr></code>, 4for <code><nobr>int</nobr></code>, <code><nobr>long</nobr></code> and<code><nobr>float</nobr></code>, and 8 for<code><nobr>double</nobr></code>. Pointers, being 32-bit addresses, arealso 4 bytes long.<p>To access a C data structure, you need to know the offset from the baseof the structure to the field you are interested in. You can either do thisby converting the C structure definition into a NASM structure definition(using <code><nobr>STRUC</nobr></code>), or by calculating the one offsetand using just that.<p>To do either of these, you should read your C compiler's manual to findout how it organises data structures. NASM gives no special alignment tostructure members in its own <code><nobr>STRUC</nobr></code> macro, so youhave to specify alignment yourself if the C compiler generates it.Typically, you might find that a structure like<p><pre>struct {     char c;     int i; } foo;</pre><p>might be eight bytes long rather than five, since the<code><nobr>int</nobr></code> field would be aligned to a four-byteboundary. However, this sort of feature is sometimes a configurable optionin the C compiler, either using command-line options or<code><nobr>#pragma</nobr></code> lines, so you have to find out how yourown compiler does it.<h4><a name="section-8.1.4">8.1.4 <code><nobr>c32.mac</nobr></code>: Helper Macros for the 32-bit C Interface</a></h4><p>Included in the NASM archives, in the <code><nobr>misc</nobr></code>directory, is a file <code><nobr>c32.mac</nobr></code> of macros. Itdefines three macros: <code><nobr>proc</nobr></code>,<code><nobr>arg</nobr></code> and <code><nobr>endproc</nobr></code>. Theseare intended to be used for C-style procedure definitions, and theyautomate a lot of the work involved in keeping track of the callingconvention.<p>An example of an assembly function using the macro set is given here:<p><pre>proc    _proc32 %$i     arg %$j     arg         mov     eax,[ebp + %$i]         mov     ebx,[ebp + %$j]         add     eax,[ebx] endproc</pre><p>This defines <code><nobr>_proc32</nobr></code> to be a procedure takingtwo arguments, the first (<code><nobr>i</nobr></code>) an integer and thesecond (<code><nobr>j</nobr></code>) a pointer to an integer. It returns<code><nobr>i + *j</nobr></code>.<p>Note that the <code><nobr>arg</nobr></code> macro has an<code><nobr>EQU</nobr></code> as the first line of its expansion, and sincethe label before the macro call gets prepended to the first line of theexpanded macro, the <code><nobr>EQU</nobr></code> works, defining<code><nobr>%$i</nobr></code> to be an offset from<code><nobr>BP</nobr></code>. A context-local variable is used, local tothe context pushed by the <code><nobr>proc</nobr></code> macro and poppedby the <code><nobr>endproc</nobr></code> macro, so that the same argumentname can be used in later procedures. Of course, you don't <em>have</em> todo that.<p><code><nobr>arg</nobr></code> can take an optional parameter, giving thesize of the argument. If no size is given, 4 is assumed, since it is likelythat many function parameters will be of type <code><nobr>int</nobr></code>or pointers.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产喂奶挤奶一区二区三区| 成人午夜精品一区二区三区| 中文字幕佐山爱一区二区免费| 久久精品日产第一区二区三区高清版 | 欧美一区二区三区日韩| 777久久久精品| 日韩一区二区三区视频在线| 日韩欧美成人一区二区| 久久亚洲精品小早川怜子| 91精品国产高清一区二区三区蜜臀| 亚洲欧洲另类国产综合| 亚洲成人av福利| 欧美成人乱码一区二区三区| 日韩欧美你懂的| 久久精品视频在线免费观看| 18成人在线观看| 日日摸夜夜添夜夜添精品视频| 老司机免费视频一区二区| 福利一区二区在线| 91成人免费在线视频| 日韩一区二区三区视频在线观看| 欧美精品一区二区三区四区| 国产精品网站导航| 亚洲国产精品嫩草影院| 国内不卡的二区三区中文字幕 | 99精品久久免费看蜜臀剧情介绍| 色综合亚洲欧洲| 欧美r级在线观看| 国产精品初高中害羞小美女文| 午夜精品久久久久久久99水蜜桃| 国产真实精品久久二三区| 色欲综合视频天天天| 日韩精品自拍偷拍| 亚洲欧美日韩中文字幕一区二区三区 | 日本不卡一二三区黄网| 国产精品18久久久久久久久久久久 | 亚洲福利一区二区三区| 国产一区二区三区精品欧美日韩一区二区三区 | 国产一区二区三区在线观看精品 | 国产三区在线成人av| 一区二区三区欧美视频| 精品亚洲aⅴ乱码一区二区三区| 99久久精品99国产精品| 日韩一区二区三区电影| 一区二区三区电影在线播| 国产精品99久久久久久宅男| 制服丝袜中文字幕亚洲| 中文字幕日韩精品一区| 久久国产三级精品| 欧洲视频一区二区| 国产精品萝li| 国产精品自在在线| 日韩一区二区电影在线| 亚洲妇女屁股眼交7| 9人人澡人人爽人人精品| 精品欧美一区二区在线观看 | 久久久久亚洲综合| 日本不卡视频在线观看| 在线一区二区三区四区五区| 久久久不卡网国产精品一区| 蜜乳av一区二区三区| 欧美剧情片在线观看| 伊人婷婷欧美激情| 95精品视频在线| 亚洲欧美综合色| 成人av先锋影音| 国产欧美va欧美不卡在线| 久久精品久久综合| 欧美zozo另类异族| 久久国产麻豆精品| 久久综合九色综合欧美98| 久久99九九99精品| 久久久久国产精品人| 国产一区久久久| 久久久久亚洲综合| 大胆亚洲人体视频| 国产精品久久久久久久久免费丝袜| 国产成人鲁色资源国产91色综| 久久影院午夜论| 成人在线视频一区二区| 亚洲国产精华液网站w| 国产一区二区美女| 中文字幕成人网| 99久久99久久综合| 亚洲国产精品天堂| 日韩一区二区三区观看| 国产美女久久久久| 亚洲色图视频免费播放| 一本到不卡精品视频在线观看 | 精品国内二区三区| 国产大陆精品国产| 一区二区三区波多野结衣在线观看 | 91麻豆精品91久久久久久清纯| 日韩黄色片在线观看| 欧美肥胖老妇做爰| 国产不卡视频在线观看| 亚洲欧美日韩一区二区三区在线观看| 色综合久久88色综合天天| 日韩精品欧美精品| 久久久久久久久久久久久久久99| 成人在线视频一区二区| 五月婷婷综合在线| 久久久www成人免费毛片麻豆| 色综合欧美在线| 麻豆成人久久精品二区三区红 | 亚洲电影你懂得| 精品国产伦一区二区三区观看方式 | 国产视频一区在线观看| 精品视频在线看| 国产精品一二三区在线| 亚洲一区二区三区视频在线播放 | 中文字幕一区二区日韩精品绯色| 欧美影院一区二区三区| 国产一区二区导航在线播放| 日韩毛片精品高清免费| 337p日本欧洲亚洲大胆精品| 色噜噜狠狠色综合中国| 国产美女精品在线| 日韩国产精品91| 一区二区欧美视频| 国产日韩欧美电影| 精品国产一区二区三区久久影院| 91亚洲男人天堂| 丁香婷婷综合网| 另类人妖一区二区av| 亚洲成人在线免费| 亚洲精品高清在线观看| 国产亚洲一二三区| 在线观看成人免费视频| 亚洲欧洲精品成人久久奇米网| 91视频在线观看免费| 国产一区二区0| 老鸭窝一区二区久久精品| 亚洲电影在线播放| 亚洲欧美日韩中文播放| 中文av一区二区| 久久久国产综合精品女国产盗摄| 欧美一级片在线看| 6080yy午夜一二三区久久| 欧美三级中文字幕在线观看| 91色视频在线| 97aⅴ精品视频一二三区| av在线一区二区| 成人免费高清在线| 成人黄动漫网站免费app| 国产成人夜色高潮福利影视| 国产一区二区三区av电影 | 中文字幕制服丝袜成人av | 亚洲电影在线免费观看| 欧美午夜影院一区| 欧美日韩一级片网站| 精品久久99ma| 天天色天天操综合| 日韩不卡免费视频| 男男视频亚洲欧美| 久久丁香综合五月国产三级网站| 免费在线观看一区| 国产乱理伦片在线观看夜一区| 国产一区二区视频在线| 成人午夜在线播放| 99久久99久久精品国产片果冻| 91免费看片在线观看| 色拍拍在线精品视频8848| 欧美伊人久久大香线蕉综合69 | 欧美一卡二卡三卡| 久久久久国产精品厨房| 亚洲图片欧美激情| 亚洲高清不卡在线观看| 久久99精品久久久久久国产越南| 国产高清一区日本| caoporen国产精品视频| 在线观看欧美日本| 日韩一区二区三区视频在线观看 | 一区二区三区日韩精品视频| 一区二区三区在线免费播放 | 亚洲欧美在线观看| 亚洲国产日日夜夜| 国产一区二区三区四区在线观看| 99亚偷拍自图区亚洲| 欧美乱妇15p| 久久久蜜臀国产一区二区| 亚洲黄一区二区三区| 另类小说综合欧美亚洲| 91丨九色丨蝌蚪丨老版| 91精品国产综合久久久久久久久久 | 欧美影片第一页| 亚洲尤物视频在线| 免费av网站大全久久| 97精品视频在线观看自产线路二| 7777精品伊人久久久大香线蕉超级流畅| 欧美精品一区二区三区蜜桃 | 国内精品久久久久影院色| 色综合久久久久网| 日韩精品专区在线影院重磅| 中文字幕亚洲精品在线观看| 日本成人中文字幕| 在线观看日韩毛片| 国产精品久久夜| 国产美女av一区二区三区| 在线播放国产精品二区一二区四区|