|
[求助]请帮帮我啊!汇编问题!不晓得如何生成目标文件??
看看这篇文章吧。 IDE的选择与配置 作者:AoGo 于2003-9-12上传 -------------------------------------------------------------------------------- IDE,全称集成开发环境,对于MASM的IDE,我想每个人最低的要求都至少要求在写程序时不需要在命令行中手工输入命令来编译再链接,这样很不方便,如果代码有错,就需要用编辑器(一般是计事本)修改然后再重复的编译、链接,把大量的时间花在这种操作上,不爽! 为此,RedASM出现了,它具备了写MASM程序的所有基本功能,只要设置好,在RedASM中写程序简直和用VC差不多,API函数原型的提示、常数自动的弹出、结构的成员变量显示(暂不支持声明为结构类型的变量)、过程变量名自己列出、支持快速跳转、关键字的自动补齐、集成对话框编辑器/菜单编辑器、工具栏编辑器、调试器等等等等,让我等汇编狂人惊喜不已,但是(住住听到这两字时总是让人心里发紧^_^),RedASM对中文的支持相当不好,并且一直没有解决,情况就是打开、编辑有中文的源文件时会停止响应或死机,除非整个程序都不用中文那就没问题,最新版本的RedASM能通过设置中文字体来支持双字节的编辑,但这种方法只适用于2000以上的操作系统,对于我们这些用着破机器装个98都觉得慢、对英文头痛的人来说,RedASM成了我等人心头之鸡肋---功能强大却用着烦心,可是它的确非常实用,心里这个可惜啊,犹如滔滔江水....(打住)! 所以,如果你操作系统在98以上(不包括ME),推荐你选择RedASM,最新版本的RedASM速度更快,实用的功能让MASM程序的编写真的非常方便,你可以到作者主页上去下载(http://radasm.sonshinesoftware.com/ ),记住RedASM更新相当快,要时常去看看是否更新了,这也是对作者的一种支持。 不过因为我RedASM只用过几次,它的功能与特点我不清楚,详细自己去玩吧,而MASM的设置也相当方便,只要设置好MASM32的路径就行。 RedASM的几个缺点: 1.是没有模板,虽然可以自己写一个,但是内建模析是一个IDE所具备基本条件,不知道RedASM的作者为什么不写几个。 2.高亮显示的API函数与常数库不全,遇到没有加入的函数,我们还是得去看参考手册。(建立写MASM总开着参考手册,方便查询)。 3.资源编辑功能不是很实用,RedASM把对话框编辑、菜单编辑等等分开了,碰到需要加入其它资源,还是得自己去修改,这点不方便。 另外向大家重点推荐另一个也是我一直使用的IDE,不,不能说是IDE,只能说是编辑器,那就是EditPlus,程序的下载地址:,点击下载EditPlue点击查看程序界面截图,只要自己设置好,EditPlus就可以相当方便的用来进行MASM的编程,如何配置大家就不要操心了,我已经为大家写好了相关的配置文件,并做了一个安装程序,请大家下载本站的MASM for EditPlus,安装好后就行了,目前MASM for EditPlus已经升级到Serial 0004,因为MASM for EditPlus是我自己配置的,我就它详细向大家说说MASM for EditPlus的优点。 1.MASM for EditPlus的关键字非常全,因为我是按照最新版本的MASMv8.0来制作语法文件表的,所有MASMv8.0支持的函数都能高亮显示,如果某个在API手册中存在的API在EditPlus中输入后没有高亮显示就证明此函数MASM不支持,同理,常数与结构也是一样,另外所有的关键字都支持自动完成,这样可以尽量的避免大小写这种讨厌的错误. 2.MASM for EditPlus的模板相当多,这样省得大家在学习时得去自己写重复的代码. 3.批处理相当完善,还支持VC的编译,批处理有相当的智能,当编译的文件是EXE/DLL等程序时,如果源文件目录下不存在资源文件,批处理会通过复制的方法把相应的res改名复制到目标目录,编译后就能行到一个包含资源文件的程序,这样方便点4号工具栏启动VC资源编辑器来进行编辑. 3.当编译的模式是DLL/VxD时,如果源文件目录下不存在DEF文件,则批处理也会自动用重定向文件来创建它,这样你就不用手工去自己建立了,当然要输出函数的话还是得自己添加。 4.当建立LIB时,INC文件会自动的创建,虽然有时会把一些API函数也加进去,但是这样不影响它的使用,因为MASM编译时是找到原型就跳过的,所以建立自己建立的LIB在使用时尽量包含在最后。 5.因为MASM for EditPlus集成了MASM5.0、MASMv8.0、VC资源编辑器,98DDK的头文件,所以,你只需要安装好MASM for EditPlus后就不需要进行其它设置了,并且只要你安装了SoftICE,还可以使用MASM for EditPlus进行源码调试。 6.如果你喜欢手工进行编译,可以这样,在启动时打通MASM for EditPlus的BIN目录,如在Autoexec.bat中添加一句set PATH=%PATH%;D:\MASM32\BIN,注意D:\MASM32\BIN要是你自己的安装目录下的BIN,以后在命令行方式下只要输入mlink 文件路径就可以进行一步到位的编译,例如编译C:\1.asm,则输mlink c:\1.asm,则能自动的编译出1.EXE文件来。唯一的要求就在源代码最前面几行中加入一行注释,里面用双引号包含说明编译的模式,如;MODE="DOS",则编译程序会自动编译为DOS汇编程序,相关的关键关有DOS/CON/DLG/EXE/DLL/MDI/VXD/LIB. 小技巧: =============== 1.RedASM有一个很方便的功能,叫ASCII码表,这在想知道某些字符的值的相当有用,其实EditPlus中这个功能更加方便,你只要把光标移动到相应字符前面,在EditPlus的状态栏中会自动显示其ASCII值,虽然无法显示特殊的字符,但是已经相当方便好用。 2.当一个文件中自定义的过程、函数过多时,可以点搜索-]函数列表来查看已有的过程,双击后能马上跳到目录行.对于大文件相当文件。 3.当要查找字符时,如想查找一些变量是否重声明,可以双击选择这个单词,再点查找时选择的文本会自动出现在查找编辑框中。 4.当要查找某个API函数相应的LIB时或查看某个常数的值时,你可以这样做:点搜索-]在文件中查找,输入API的名字,然后文件类型使用*.inc,文件夹选择MASM for EditPlus的INCLUDE文件,然后点查找,不到1秒钟,就能查找到它所对应的INC文件。也很方便,并且设置好后,以后查找时只需双击想查询的API再点在文件中查找,所有的设置都不需要输入,直接点查找就行,用得好的话,这比在API手册中查找还要方便。 5.如果编译时使用EditPlus的输出窗口,当发生错误后,你只需双击列表中错误提示的那一行,则能自动跳运源文件中相关行,这一点和VC的编辑器一样。这个功能也相当方便。具体在参数设置中,在用户工具需要使用输出窗口的工具下复选"捕捉输出"就行了。 6.如果你用MASM已经在写程序了,并且想写一个软件,建议使用工程功能,这样可以把一系列的文件设置在一个工程中,在下面的打开的文件名列表左边有一个文件夹的图标,点一下能在弹出的菜单中相当文件设置工程文件。 7.把API的帮助文件添加到5号工具栏,以后只需选择要查询的关键字,点5号工具栏就可以显示它的信息,非常方便。如果您还未安装API参考手册,请到我的站点下载。 EditPlus做为一个文本编辑器是非常实用的,对于编程来说,有一些非常有用的功能不容易被您发现,我均放到了工具栏上,相应的快捷键我帮您定义好了,这些快捷键是我习惯的,如下: ============================================================== 把选择的文本复制追加到剪切板 Ctrl+Shift+C 选择文本全部转换成大写 Ctrl+U 选择文本全部转换成小写 Ctrl+L 选择当前的字词 Ctrl+W 选择当前行 Ctrl+R 或 单击行号 开始进行列块选择 Alt+Mouse 注释选择的文本 Ctrl+; 复制当前行 Ctrl+J 增加当前行的缩进 Ctrl+I 缩进或缩进选择行 Tab 显示当前源代码中的所有函数列表 F4 在当前光标所在行设置一个标记 F5 清除当前文档中的所有标记 F6 快速跳转到当前行上一个标记 F7 快速跳转到当前行下一个标记 F8 跳到指定行 Ctrl+G 显示或隐藏列标记 Ctrl+` 开始记录或停止键盘宏记录 Ctrl+Q 键盘宏回放 Alt+ 0,1,2,3... 运行用户工具 Ctrl+ 0,1,2,3... 其中最实用的是文档标记,当一个文件很长时,如果您突然想声明一个全局变量,当然您可能会用宏在代码中定义,但更有可能的是您会拖动光标到最前面的.data或.data?段添加好变量,再拖动光标到刚才的地方,如果代码很多,非常麻烦,这个时候,请一定要使用标记功能,碰到这种情况,您只需先在当前行按下F5做一个标记,然后再到前面声明好变量,再按一个F8,就能马上返回刚才的位置,非常方便。 接着是函数列表,当一个文件很大,里面有N个过程/函数时,F4就太方便了,您可能在某个过程中修改时突然想到另外某个过程也要修改,此时您只需按下F4,所有的过程就全部出来了,选择马上跳转到这个过程,结合标记功能,在文件中来回跳转根本不会再麻烦。 另外一个非常实用的功能是增加缩进,当源代码的某一块要全部往前减少一个制表符时,你只需选择这些行,再按Ctrl+I就OK了(全部往后添加一个制表符就是Tab键,当然要选择),对代码美化非常实用。 还有宏(不是MASM的宏),比如说对话框过程,每个对话框返回过程最初都是一样的,您可以把过程记录为一个宏,以后需要添加对话框模板的地方按Alt+n就行了。一样方便。 另外有一个功能就是颜色选择工具,猜想您以前定义色彩搞不好是使用宏RGB或自己进行移位,现在不必这么麻烦了,颜色选择功能已放到了工具栏上,不过记得选择了相应色彩后一定要把前面两位与后面两位调换,如选择后为:#45FF10h,这时应该改为10FF45h,如果前面是A-F,还应添加0.如#89FFEEh,应改为0EEFF89h. 另外还有一些编辑器非常好,如UE,如果你想使用UE做编辑器,可以直接挂上MASM for EditPlus的批处理,参数的提供设置一下后就能进行MASM for EditPlus一样的编译操作。 另外,大家不要老是在意IDE的选择,其实做为一个编辑器来说,关键是要自己用着顺手,很多朋友都不喜欢RedASM的封装性,老觉得它就像VC一样搞得很复杂,还有些朋友不喜欢用EditPlus,这些都有个人的原因,所以,大家在选择IDE时,选择好后觉得好用最好就一直用下去,像RedASM,将来它一定会解决双字节的问题的,如果现在你去使用它,将来就会更加顺手.当然,MASM for EditPlus也会不断的进行更新,不过因为编辑器不是我编写的,我的做法可能有点白痴。最好的方法就是自己写一个编辑器,这个以后再说。 |
|
初学者提问:请问为何会出现Access Violation
在用link程序的时候必须加/SECTION选项将代码段设置成可读可写可执行的属性才行。 |
|
求助关于GetOpenFileName的详细用法
OPENFILENAME结构的定义: OPENFILENAMEA STRUCT LStructSize DWORD ? ;结构的长度,用户填写 HwndOwner DWORD ? ;所属窗口,可以为NULL HInstance DWORD ? ; LpstrFilter DWORD ? ;文件筛选字符串 LpstrCustomFilter DWORD ? NMaxCustFilter DWORD ? NFilterIndex DWORD ? LpstrFile DWORD ? ;全路径的文件名缓冲区 NmaxFile DWORD ? ;文件名缓冲区长度 LpstrFileTitle DWORD ? ;不包含路径的文件名缓冲区 NMaxFileTitle DWORD ? ;文件名缓冲区长度 LpstrInitialDir DWORD ? ;初始目录 LpstrTitle DWORD ? ;对话框标题 Flags DWORD ? ;标志 NFileOffset WORD ? ;文件名在字符串中的起始位置 NFileExtension WORD ? ;扩展名在字符串中的起始位置 LpstrDefExt DWORD ? ;默认扩展名 LCustData DWORD ? LpfnHook DWORD ? LpTemplateName DWORD ? OPENFILENAMEA ENDS OPENFILENAME equ <OPENFILENAMEA> 结构中一些重要的字段含义如下。 ● lpstrFilter――指定文件名筛选字符串,该字段决定了对话框中“文件类型”下拉式列表框中的内容,字符串可以由多组内容组成,每组包括一个说明字符串和一个筛选字符串,字符串的最后用两个0结束。如下面的字符串将在列表框中显示两项内容,选择不同项目的时候分别列出“*.txt”文件或者所有文件“*.*”: 'Text Files(*.txt)',0,'*.txt',0,'All Files(*.*)',0,'*.*',0,0 筛选字符串中也可以同时指定多个扩展名,中间用分号隔开,如'*.txt;*.doc'。 ● lpstrFile――指向一个包含文件名的缓冲区。如果这个缓冲区中已经包含了一个文件名,那么对话框初始化的时候将显示这个文件名。当用户选择了一个文件的时候,函数在这里返回新的文件名。 ● nMaxFile――指定lpstrFile参数指向的缓冲区的长度。 ● lpstrFileTitle――指向一个缓冲区,用来接收用户选择的不含路径的文件名。这个字段可以为NULL。 ● nMaxFileTitle――指明lpstrFileTitle参数指向的缓冲区的长度。 ● lpstrInitialDir――对话框的初始化目录,这个字段可以为NULL。 ● lpstrTitle――指向自定义的对话框标题,如果这个字段是NULL,那么“打开”对话框和“保存”对话框的默认标题是“打开”和“另存为”。 ● nFileOffset―返回文件名字符串中文件名的起始位置,如当用户选择了文件“c:\dir1\file.ext”时,这里将返回8。 ● nFileExtension――返回文件名字符串中扩展名的起始位置,同样是上面的字符串,这里返回13。如果文件名的最后一个字符是“.”,这里返回0,表示文件没有扩展名,这个字段和nFileOffset字段为分析文件名提供了方便。 ● lpstrDefExt――指定默认扩展名,如果用户输入了一个没有扩展名的文件名,那么函数会自动加上这个默认扩展名。 ● Flags字段――该标志字段决定了对话框的不同行为,它可以是一些取值的组合。下面是一些比较重要的标志: ■ OFN_ALLOWMULTISELECT――允许同时选择多个文件名。 ■ OFN_CREATEPROMPT――如果用户输入了一个不存在的文件名,对话框向用户提问“是否建立文件”。 ■ OFN_FILEMUSTEXIST――用户只能选择一个已经存在的文件名,使用这个标志的时候必须同时使用 OFN_PATHMUSTEXIST标志。 ■ OFN_HIDEREADONLY――对话框中不显示“以只读方式打开”复选框。 ■ OFN_OVERWRITEPROMPT――在“保存”文件对话框中使用的时候,当选择一个已存在的文件时,对话框会提问“是否覆盖文件”。 ■ OFN_PATHMUSTEXIST――用户输入文件名时,路径必须存在。 ■ OFN_READONLY――对话框中的“以只读方式打开”复选框初始化的时候处于选中状态。 调用显示“打开”或“保存”文件对话框函数时,函数会停留直到对话框关闭为止,当用户单击了对话框中的“确定”按钮时,函数返回TRUE,用户单击“取消”按钮退出时,函数返回FALSE,程序可以由此判断是否需要继续进行打开或保存文件的操作。具体的代码可以参考例子中的_SaveAs和_OpenFile子程序。 ;ASM例子: .386 .model flat, stdcall Option CaseMap:None include Windows.inc include Kernel32.inc include User32.inc include ComDlg32.inc includelib Kernel32.lib includelib User32.lib includelib ComDlg32.lib .data ofn OPENFILENAMEA <> lpstrFilter db 'All Files(*.*)',0,'*.*',0,0 lpstrFile db 255 dup(0) lpszOkMsgTitle db 'OpenFileNameOk',0 lpszErrMsgText db 'OpenFileNameErr',0 lpszErrMsgTitle db 'OpenFileNameErr',0 .code start: ;注意!如果你将ofn结构定义在“函数的局部变量”中,必须使用RtlZeroMemory函数将ofn结构内存清0,否则调用GetOpenFileName函数将不会成功。 mov ofn.lStructSize,sizeof ofn mov eax,offset lpstrFilter ;初始化ofn结构 mov ofn.lpstrFilter,eax mov eax,offset lpstrFile mov ofn.lpstrFile,eax mov ofn.nMaxFile,sizeof lpstrFile mov ofn.Flags,OFN_FILEMUSTEXIST or OFN_PATHMUSTEXIST invoke GetOpenFileName,addr ofn ;开始获取FileName .if eax ;如果获取文件名成功 invoke MessageBox,NULL,addr lpstrFile,addr lpszOkMsgTitle,MB_OK .else invoke MessageBox,NULL,addr lpszErrMsgText,addr lpszErrMsgTitle,MB_OK .endif invoke ExitProcess,NULL end start |
操作理由
RANk
{{ user_info.golds == '' ? 0 : user_info.golds }}
雪币
{{ experience }}
课程经验
{{ score }}
学习收益
{{study_duration_fmt}}
学习时长
基本信息
荣誉称号:
{{ honorary_title }}
能力排名:
No.{{ rank_num }}
等 级:
LV{{ rank_lv-100 }}
活跃值:
在线值:
浏览人数:{{ visits }}
最近活跃:{{ last_active_time }}
注册时间:{{ user_info.create_date_jsonfmt }}
勋章
兑换勋章
证书
证书查询 >
能力值