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

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

?? nasmdoc7.htm

?? nasm手冊 大家可以看看 對要寫匯編程序的幫助很大
?? HTM
?? 第 1 頁 / 共 3 頁
字號:
<html><head><title>NASM Manual</title></head><body><h1 align=center>The Netwide Assembler: NASM</h1><p align=center><a href="nasmdoc8.html">Next Chapter</a> |<a href="nasmdoc6.html">Previous Chapter</a> |<a href="nasmdoc0.html">Contents</a> |<a href="nasmdoci.html">Index</a><h2><a name="chapter-7">Chapter 7: Writing 16-bit Code (DOS, Windows 3/3.1)</a></h2><p>This chapter attempts to cover some of the common issues encounteredwhen writing 16-bit code to run under <code><nobr>MS-DOS</nobr></code> or<code><nobr>Windows 3.x</nobr></code>. It covers how to link programs toproduce <code><nobr>.EXE</nobr></code> or <code><nobr>.COM</nobr></code>files, how to write <code><nobr>.SYS</nobr></code> device drivers, and howto interface assembly language code with 16-bit C compilers and withBorland Pascal.<h3><a name="section-7.1">7.1 Producing <code><nobr>.EXE</nobr></code> Files</a></h3><p>Any large program written under DOS needs to be built as a<code><nobr>.EXE</nobr></code> file: only <code><nobr>.EXE</nobr></code>files have the necessary internal structure required to span more than one64K segment. Windows programs, also, have to be built as<code><nobr>.EXE</nobr></code> files, since Windows does not support the<code><nobr>.COM</nobr></code> format.<p>In general, you generate <code><nobr>.EXE</nobr></code> files by usingthe <code><nobr>obj</nobr></code> output format to produce one or more<code><nobr>.OBJ</nobr></code> files, and then linking them together usinga linker. However, NASM also supports the direct generation of simple DOS<code><nobr>.EXE</nobr></code> files using the<code><nobr>bin</nobr></code> output format (by using<code><nobr>DB</nobr></code> and <code><nobr>DW</nobr></code> to constructthe <code><nobr>.EXE</nobr></code> file header), and a macro package issupplied to do this. Thanks to Yann Guidon for contributing the code forthis.<p>NASM may also support <code><nobr>.EXE</nobr></code> natively as anotheroutput format in future releases.<h4><a name="section-7.1.1">7.1.1 Using the <code><nobr>obj</nobr></code> Format To Generate <code><nobr>.EXE</nobr></code> Files</a></h4><p>This section describes the usual method of generating<code><nobr>.EXE</nobr></code> files by linking<code><nobr>.OBJ</nobr></code> files together.<p>Most 16-bit programming language packages come with a suitable linker;if you have none of these, there is a free linker called VAL, available in<code><nobr>LZH</nobr></code> archive format from<a href="ftp://x2ftp.oulu.fi/pub/msdos/programming/lang/"><code><nobr>x2ftp.oulu.fi</nobr></code></a>.An LZH archiver can be found at<a href="ftp://ftp.simtel.net/pub/simtelnet/msdos/arcers"><code><nobr>ftp.simtel.net</nobr></code></a>.There is another `free' linker (though this one doesn't come with sources)called FREELINK, available from<a href="http://www.pcorner.com/tpc/old/3-101.html"><code><nobr>www.pcorner.com</nobr></code></a>.A third, <code><nobr>djlink</nobr></code>, written by DJ Delorie, isavailable at<a href="http://www.delorie.com/djgpp/16bit/djlink/"><code><nobr>www.delorie.com</nobr></code></a>.A fourth linker, <code><nobr>ALINK</nobr></code>, written by Anthony A.J.Williams, is available at<a href="http://alink.sourceforge.net"><code><nobr>alink.sourceforge.net</nobr></code></a>.<p>When linking several <code><nobr>.OBJ</nobr></code> files into a<code><nobr>.EXE</nobr></code> file, you should ensure that exactly one ofthem has a start point defined (using the <code><nobr>..start</nobr></code>special symbol defined by the <code><nobr>obj</nobr></code> format: see<a href="nasmdoc6.html#section-6.2.6">section 6.2.6</a>). If no moduledefines a start point, the linker will not know what value to give theentry-point field in the output file header; if more than one defines astart point, the linker will not know <em>which</em> value to use.<p>An example of a NASM source file which can be assembled to a<code><nobr>.OBJ</nobr></code> file and linked on its own to a<code><nobr>.EXE</nobr></code> is given here. It demonstrates the basicprinciples of defining a stack, initialising the segment registers, anddeclaring a start point. This file is also provided in the<code><nobr>test</nobr></code> subdirectory of the NASM archives, under thename <code><nobr>objexe.asm</nobr></code>.<p><pre>segment code ..start:         mov     ax,data         mov     ds,ax         mov     ax,stack         mov     ss,ax         mov     sp,stacktop</pre><p>This initial piece of code sets up <code><nobr>DS</nobr></code> to pointto the data segment, and initialises <code><nobr>SS</nobr></code> and<code><nobr>SP</nobr></code> to point to the top of the provided stack.Notice that interrupts are implicitly disabled for one instruction after amove into <code><nobr>SS</nobr></code>, precisely for this situation, sothat there's no chance of an interrupt occurring between the loads of<code><nobr>SS</nobr></code> and <code><nobr>SP</nobr></code> and nothaving a stack to execute on.<p>Note also that the special symbol <code><nobr>..start</nobr></code> isdefined at the beginning of this code, which means that will be the entrypoint into the resulting executable file.<p><pre>        mov     dx,hello         mov     ah,9         int     0x21</pre><p>The above is the main program: load <code><nobr>DS:DX</nobr></code> witha pointer to the greeting message (<code><nobr>hello</nobr></code> isimplicitly relative to the segment <code><nobr>data</nobr></code>, whichwas loaded into <code><nobr>DS</nobr></code> in the setup code, so the fullpointer is valid), and call the DOS print-string function.<p><pre>        mov     ax,0x4c00         int     0x21</pre><p>This terminates the program using another DOS system call.<p><pre>segment data hello:  db      'hello, world', 13, 10, '$'</pre><p>The data segment contains the string we want to display.<p><pre>segment stack stack         resb 64 stacktop:</pre><p>The above code declares a stack segment containing 64 bytes ofuninitialised stack space, and points <code><nobr>stacktop</nobr></code> atthe top of it. The directive <code><nobr>segment stack stack</nobr></code>defines a segment <em>called</em> <code><nobr>stack</nobr></code>, and alsoof <em>type</em> <code><nobr>STACK</nobr></code>. The latter is notnecessary to the correct running of the program, but linkers are likely toissue warnings or errors if your program has no segment of type<code><nobr>STACK</nobr></code>.<p>The above file, when assembled into a <code><nobr>.OBJ</nobr></code>file, will link on its own to a valid <code><nobr>.EXE</nobr></code> file,which when run will print `hello, world' and then exit.<h4><a name="section-7.1.2">7.1.2 Using the <code><nobr>bin</nobr></code> Format To Generate <code><nobr>.EXE</nobr></code> Files</a></h4><p>The <code><nobr>.EXE</nobr></code> file format is simple enough thatit's possible to build a <code><nobr>.EXE</nobr></code> file by writing apure-binary program and sticking a 32-byte header on the front. This headeris simple enough that it can be generated using<code><nobr>DB</nobr></code> and <code><nobr>DW</nobr></code> commands byNASM itself, so that you can use the <code><nobr>bin</nobr></code> outputformat to directly generate <code><nobr>.EXE</nobr></code> files.<p>Included in the NASM archives, in the <code><nobr>misc</nobr></code>subdirectory, is a file <code><nobr>exebin.mac</nobr></code> of macros. Itdefines three macros: <code><nobr>EXE_begin</nobr></code>,<code><nobr>EXE_stack</nobr></code> and <code><nobr>EXE_end</nobr></code>.<p>To produce a <code><nobr>.EXE</nobr></code> file using this method, youshould start by using <code><nobr>%include</nobr></code> to load the<code><nobr>exebin.mac</nobr></code> macro package into your source file.You should then issue the <code><nobr>EXE_begin</nobr></code> macro call(which takes no arguments) to generate the file header data. Then writecode as normal for the <code><nobr>bin</nobr></code> format - you can useall three standard sections <code><nobr>.text</nobr></code>,<code><nobr>.data</nobr></code> and <code><nobr>.bss</nobr></code>. At theend of the file you should call the <code><nobr>EXE_end</nobr></code> macro(again, no arguments), which defines some symbols to mark section sizes,and these symbols are referred to in the header code generated by<code><nobr>EXE_begin</nobr></code>.<p>In this model, the code you end up writing starts at<code><nobr>0x100</nobr></code>, just like a <code><nobr>.COM</nobr></code>file - in fact, if you strip off the 32-byte header from the resulting<code><nobr>.EXE</nobr></code> file, you will have a valid<code><nobr>.COM</nobr></code> program. All the segment bases are the same,so you are limited to a 64K program, again just like a<code><nobr>.COM</nobr></code> file. Note that an<code><nobr>ORG</nobr></code> directive is issued by the<code><nobr>EXE_begin</nobr></code> macro, so you should not explicitlyissue one of your own.<p>You can't directly refer to your segment base value, unfortunately,since this would require a relocation in the header, and things would get alot more complicated. So you should get your segment base by copying it outof <code><nobr>CS</nobr></code> instead.<p>On entry to your <code><nobr>.EXE</nobr></code> file,<code><nobr>SS:SP</nobr></code> are already set up to point to the top of a2Kb stack. You can adjust the default stack size of 2Kb by calling the<code><nobr>EXE_stack</nobr></code> macro. For example, to change the stacksize of your program to 64 bytes, you would call<code><nobr>EXE_stack 64</nobr></code>.<p>A sample program which generates a <code><nobr>.EXE</nobr></code> filein this way is given in the <code><nobr>test</nobr></code> subdirectory ofthe NASM archive, as <code><nobr>binexe.asm</nobr></code>.<h3><a name="section-7.2">7.2 Producing <code><nobr>.COM</nobr></code> Files</a></h3><p>While large DOS programs must be written as<code><nobr>.EXE</nobr></code> files, small ones are often better writtenas <code><nobr>.COM</nobr></code> files. <code><nobr>.COM</nobr></code>files are pure binary, and therefore most easily produced using the<code><nobr>bin</nobr></code> output format.<h4><a name="section-7.2.1">7.2.1 Using the <code><nobr>bin</nobr></code> Format To Generate <code><nobr>.COM</nobr></code> Files</a></h4><p><code><nobr>.COM</nobr></code> files expect to be loaded at offset<code><nobr>100h</nobr></code> into their segment (though the segment maychange). Execution then begins at <code><nobr>100h</nobr></code>, i.e.right at the start of the program. So to write a<code><nobr>.COM</nobr></code> program, you would create a source filelooking like<p><pre>        org 100h section .text start:         ; put your code here section .data         ; put data items here section .bss         ; put uninitialised data here</pre><p>The <code><nobr>bin</nobr></code> format puts the<code><nobr>.text</nobr></code> section first in the file, so you candeclare data or BSS items before beginning to write code if you want to andthe code will still end up at the front of the file where it belongs.<p>The BSS (uninitialised data) section does not take up space in the<code><nobr>.COM</nobr></code> file itself: instead, addresses of BSS itemsare resolved to point at space beyond the end of the file, on the groundsthat this will be free memory when the program is run. Therefore you shouldnot rely on your BSS being initialised to all zeros when you run.<p>To assemble the above program, you should use a command line like<p><pre>nasm myprog.asm -fbin -o myprog.com</pre><p>The <code><nobr>bin</nobr></code> format would produce a file called<code><nobr>myprog</nobr></code> if no explicit output file name werespecified, so you have to override it and give the desired file name.<h4><a name="section-7.2.2">7.2.2 Using the <code><nobr>obj</nobr></code> Format To Generate <code><nobr>.COM</nobr></code> Files</a></h4><p>If you are writing a <code><nobr>.COM</nobr></code> program as more thanone module, you may wish to assemble several <code><nobr>.OBJ</nobr></code>files and link them together into a <code><nobr>.COM</nobr></code> program.You can do this, provided you have a linker capable of outputting<code><nobr>.COM</nobr></code> files directly (TLINK does this), oralternatively a converter program such as <code><nobr>EXE2BIN</nobr></code>to transform the <code><nobr>.EXE</nobr></code> file output from the linkerinto a <code><nobr>.COM</nobr></code> file.<p>If you do this, you need to take care of several things:<ul><li>The first object file containing code should start its code segmentwith a line like <code><nobr>RESB 100h</nobr></code>. This is to ensurethat the code begins at offset <code><nobr>100h</nobr></code> relative tothe beginning of the code segment, so that the linker or converter programdoes not have to adjust address references within the file when generatingthe <code><nobr>.COM</nobr></code> file. Other assemblers use an<code><nobr>ORG</nobr></code> directive for this purpose, but<code><nobr>ORG</nobr></code> in NASM is a format-specific directive to the<code><nobr>bin</nobr></code> output format, and does not mean the samething as it does in MASM-compatible assemblers.<li>You don't need to define a stack segment.<li>All your segments should be in the same group, so that every time yourcode or data references a symbol offset, all offsets are relative to thesame segment base. This is because, when a <code><nobr>.COM</nobr></code>file is loaded, all the segment registers contain the same value.</ul><h3><a name="section-7.3">7.3 Producing <code><nobr>.SYS</nobr></code> Files</a></h3><p>MS-DOS device drivers - <code><nobr>.SYS</nobr></code> files - are purebinary files, similar to <code><nobr>.COM</nobr></code> files, except thatthey start at origin zero rather than <code><nobr>100h</nobr></code>.Therefore, if you are writing a device driver using the<code><nobr>bin</nobr></code> format, you do not need the<code><nobr>ORG</nobr></code> directive, since the default origin for<code><nobr>bin</nobr></code> is zero. Similarly, if you are using<code><nobr>obj</nobr></code>, you do not need the<code><nobr>RESB 100h</nobr></code> at the start of your code segment.<p><code><nobr>.SYS</nobr></code> files start with a header structure,containing pointers to the various routines inside the driver which do thework. This structure should be defined at the start of the code segment,even though it is not actually code.<p>For more information on the format of <code><nobr>.SYS</nobr></code>files, and the data which has to go in the header structure, a list ofbooks is given in the Frequently Asked Questions list for the newsgroup<a href="news:comp.os.msdos.programmer"><code><nobr>comp.os.msdos.programmer</nobr></code></a>.<h3><a name="section-7.4">7.4 Interfacing to 16-bit C Programs</a></h3><p>This section covers the basics of writing assembly routines that call,or are called from, C programs. To do this, you would typically write anassembly module as a <code><nobr>.OBJ</nobr></code> file, and link it withyour C modules to produce a mixed-language program.<h4><a name="section-7.4.1">7.4.1 External Symbol Names</a></h4><p>C compilers have the convention that the names of all global symbols

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲综合视频网| 国产精品1区二区.| 国产成人精品免费网站| 亚洲第一电影网| 国产精品一区在线观看你懂的| 另类小说一区二区三区| 91理论电影在线观看| 久久这里都是精品| 丝袜亚洲另类欧美| 91高清视频免费看| 国产精品久久免费看| 国产一区二区福利视频| 91精品国产色综合久久ai换脸| 91精品在线一区二区| 亚洲三级电影网站| 成人三级在线视频| 久久久不卡网国产精品一区| 国产视频一区在线观看| 日韩久久一区二区| 成人av电影免费在线播放| 久久人人爽人人爽| 激情国产一区二区 | 欧美高清视频一二三区| 国产色爱av资源综合区| 欧美情侣在线播放| 99国产一区二区三精品乱码| 日韩一区二区三区三四区视频在线观看 | 欧美一区二区三区在线看| 日韩一区和二区| 亚洲成av人片一区二区| 欧美日韩一卡二卡| 亚洲成a天堂v人片| 欧美精三区欧美精三区| 午夜精品久久久久影视| 国产精品一级片在线观看| 欧美sm极限捆绑bd| 国产在线乱码一区二区三区| 欧美va在线播放| 亚洲精品视频自拍| 色综合咪咪久久| 日韩精品资源二区在线| 精品亚洲aⅴ乱码一区二区三区| 91亚洲大成网污www| 亚洲私人影院在线观看| 91国偷自产一区二区三区成为亚洲经典| 欧美日韩国产成人在线91| 亚洲国产毛片aaaaa无费看| 国产乱子轮精品视频| 色婷婷久久久久swag精品| 日韩三级视频在线看| 亚洲蜜桃精久久久久久久| 色老头久久综合| 成人高清视频在线| 亚洲桃色在线一区| 国产精品亚洲一区二区三区在线 | 亚洲激情男女视频| 欧美中文字幕一二三区视频| 26uuu精品一区二区| 国产不卡在线播放| 亚洲欧美一区二区三区国产精品| 国产一二精品视频| 亚洲品质自拍视频网站| 欧美精品v国产精品v日韩精品| 综合电影一区二区三区| 欧美日韩成人综合| 懂色av一区二区三区免费观看 | 精品国产百合女同互慰| 国产福利一区二区三区视频 | 国产一区二区剧情av在线| 国产精品乱码一区二区三区软件| 九色|91porny| 亚洲欧洲av一区二区三区久久| 精品亚洲成a人| 亚洲欧洲色图综合| 精品少妇一区二区三区 | 亚洲已满18点击进入久久| 日韩午夜精品视频| 99综合影院在线| 免费观看30秒视频久久| 日韩理论片网站| 精品国产露脸精彩对白| 欧美日韩一区 二区 三区 久久精品| 亚洲免费观看在线观看| 精品免费国产一区二区三区四区| 日本sm残虐另类| 日韩精品在线一区| 日本久久电影网| 国产精品香蕉一区二区三区| 欧美极品aⅴ影院| 欧美久久一二三四区| www.欧美日韩国产在线| 国产麻豆一精品一av一免费 | 久久综合色一综合色88| 在线观看一区二区精品视频| 粉嫩嫩av羞羞动漫久久久| 亚洲第一福利视频在线| 亚洲欧美日韩综合aⅴ视频| 国产欧美一区二区精品性色| 日韩欧美在线网站| 欧美日韩的一区二区| 欧美亚洲动漫精品| 92国产精品观看| 不卡在线观看av| 丁香五精品蜜臀久久久久99网站| 中文字幕日韩一区二区| 久久久久久久久伊人| 精品国产一区二区精华| 日韩欧美国产综合| 91精品国产色综合久久ai换脸| 国产精品亚洲午夜一区二区三区 | 精品捆绑美女sm三区| 制服丝袜亚洲精品中文字幕| 欧美丝袜丝交足nylons图片| 色94色欧美sute亚洲线路一ni| 日韩高清一级片| 日韩激情中文字幕| 免费xxxx性欧美18vr| 奇米色一区二区三区四区| 美女在线视频一区| 国模无码大尺度一区二区三区| 亚洲免费观看在线观看| 一区二区久久久久久| 亚洲成人精品一区二区| 日韩精品国产精品| 久久激情五月婷婷| 国产精品白丝jk白祙喷水网站| 亚洲国产欧美另类丝袜| 五月综合激情婷婷六月色窝| 美女被吸乳得到大胸91| 国产综合色产在线精品| 成人激情午夜影院| 色呦呦国产精品| 欧美日韩久久不卡| 欧美成人精品福利| 国产精品视频线看| 亚洲视频在线一区| 久久亚区不卡日本| 久久精品一级爱片| 亚洲欧美一区二区三区孕妇| 亚洲成人资源网| 九九久久精品视频| 91免费看片在线观看| 欧美肥大bbwbbw高潮| 久久久五月婷婷| 欧美一区二区精品| 欧美国产一区视频在线观看| 亚洲视频一区二区在线观看| 午夜精品成人在线视频| 国产一区二区91| 91久久精品一区二区三区| 日韩你懂的在线播放| 亚洲欧美日韩一区二区| 麻豆免费看一区二区三区| 成人h动漫精品一区二| 欧美日韩aaa| 国产精品午夜久久| 日韩福利电影在线观看| 99视频在线精品| 欧美成人一区二区三区在线观看| 欧美一级一区二区| 成人免费在线视频| 麻豆精品一区二区av白丝在线| 日本不卡视频一二三区| 99热在这里有精品免费| 99久久精品免费精品国产| 91精品国产综合久久久蜜臀图片 | 亚洲精品视频免费观看| 日本不卡一区二区| 色视频欧美一区二区三区| 日韩欧美色综合| 一区二区三区在线视频免费| 久久99精品国产.久久久久| 在线观看www91| 国产精品女同互慰在线看| 精品一区二区三区在线播放视频 | 日韩午夜激情电影| 亚洲综合在线免费观看| 成人污污视频在线观看| 欧美刺激脚交jootjob| 偷偷要91色婷婷| 色噜噜久久综合| 欧美人与性动xxxx| 亚洲精品乱码久久久久久久久| 亚洲一区二区三区自拍| 日韩高清一区二区| 在线视频你懂得一区| 欧美日韩免费在线视频| 中文字幕在线不卡一区| 国产一区二区毛片| 在线免费观看一区| 中文字幕一区二区不卡| 国产黄色精品视频| 久久久久久久久久看片| 久久国产剧场电影| 精品免费国产二区三区| 精品一区二区三区免费视频| 精品国产制服丝袜高跟| 蜜臀av国产精品久久久久| 日韩欧美国产1| 久久成人免费网|