masm32新手指南
作者:purple endurer,廣西河池(2002.6.4)
工欲善其事,必先利其器。以下是masm32的一些基本用法。masm32v8下載請到aogo站(3104k)
本文主要說明三點:
1、基本使用方法
如何在masm32中建立、匯編、鏈接源程序文件和運行生成的可執(zhí)行文件。
2、如何開啟masm32的在線幫助功能
3、漢化qeditor菜單
一、基本使用方法
以在c:\pwin951\temp文件夾下建立test.asm和生成test.exe為例.
安裝好masm32后,打開“資源管理器”或“我的電腦”,進入masm32所在文件夾(假設(shè)為c:\masm32),雙擊qeditor.exe
的圖標(biāo),這就進入了masm32的集成開發(fā)環(huán)境。
⒈[可選] 輸入資源文件。按⒈的方法存盤,注意如果是在集成環(huán)境中編譯此資源文件,文件名必須是rsrc.rc(大小寫均可)。
⒉[可選] 編譯資源文件。使用菜單欄上的菜單project -> compile resource file。這時系統(tǒng)會打開一個dos窗口運
行相關(guān)的批處理文件,并報告結(jié)果。
若不編譯成功,信息為(具體錯誤信息因錯誤而異):
microsoft (r) windows (r) resource compiler, version 5.00.1823.1 - build 1823
copyright (c) microsoft corp. 1985-1998. all rights reserved.
using codepage 936 as default
creating rsrc.res
rc: rcpp -cp 936 -f c:\\pwin951\\temp\\rca83947 -g c:\\pwin951\\temp\\rda83947 -drc_in voked -d_win32 -pc\\:/ -e -i. -i .
rsrc.rc.
rsrc.rc (1): error rc2135 : file not found: mainicon.ico.
writing menu:600, lang:0x409, size 128
microsoft (r) windows resource to object converter version 5.00.1736.1
copyright (c) microsoft corp. 1992-1997. all rights reserved.
cvtres : fatal error cvt1101: cannot open rsrc.res for reading
press any key to continue . . .
其中給出了出錯語句的行號,錯誤類型代碼及錯誤信息。
按任一鍵結(jié)束,再關(guān)閉此dos窗口,并按錯誤信息修改資源文件,存盤后,重新編譯。直到顯示如下成功信息:
microsoft (r) windows (r) resource compiler, version 5.00.1823.1 - build 1823
copyright (c) microsoft corp. 1985-1998. all rights reserved.
using codepage 936 as default
creating rsrc.res
rc: rcpp -cp 936 -f c:\pwin951\temp\rca81843 -g c:\pwin951\temp\rda81843 -drc_in
voked -d_win32 -pc\:/ -e -i. -i .
rsrc.rc.
writing menu:600, lang:0x409, size 128
microsoft (r) windows resource to object converter version 5.00.1736.1
copyright (c) microsoft corp. 1992-1997. all rights reserved.
press any key to continue . . .
說明生成了rsrc.res和rsrc.obj文件,按任一鍵結(jié)束,再關(guān)閉此dos窗口。
⒊輸入源程序,然后使用菜單欄上的菜單file -> save 或 快捷工具欄中的代表存盤功能的磁盤狀圖標(biāo),第一次需要輸
入文件名,注意要指定擴展名 .asm[本例中為c:\pwin951\temp\test.asm]。
⒋匯編源程序。使用菜單欄上的菜單project -> assemblier asm file。這時系統(tǒng)會打開一個dos窗口運行相關(guān)的批
處理文件。結(jié)束后會彈出一個名為“\masm32\bin\asmbl.txt”的窗口報告結(jié)果。
若匯編不成功,則顯示信息如下(具體錯誤信息因錯誤而異):
assembling: c:\pwin951\temp\test.asm
c:\pwin951\temp\test.asm(60) : error a2006: undefined symbol : null
c:\pwin951\temp\test.asm(60) : error a2114: invoke argument type mismatch : argument : 1
volume in drive c is liu
volume serial number is 4061-17d7
directory of c:\pwin951\temp
test asm 8,402 06-05-02 19:29 test.asm
1 file(s) 13,010 bytes
0 dir(s) 24,403,968 bytes free
其中包括了詳細出錯信息。如
c:\pwin951\temp\test.asm(60) : error a2006: undefined symbol : null
中
c:\pwin951\temp\test.asm 為源程序文件的文件說明符
(60) 其中60為源程序中引起錯誤的語句的行號
error a2006 a2006為錯誤類型代號
undefined symbol : null 為具體錯誤信息
這時應(yīng)按這些信息修改源程序中相應(yīng)行,存盤后重新匯編。直至窗口顯示如下成功信息:
assembling: c:\pwin951\temp\test.asm
volume in drive c is liu
volume serial number is 4061-17d7
directory of c:\pwin951\temp
test asm 8,401 06-05-02 19:34 test.asm
test obj 3,720 06-05-02 19:35 test.obj
2 file(s) 16,729 bytes
0 dir(s) 22,298,624 bytes free
其中包括了新生成的目標(biāo)文件test.obj的有關(guān)信息。
⒌鏈接目標(biāo)文件。使用菜單欄上的菜單project -> link obj file。這時系統(tǒng)會打開一個dos窗口運行相關(guān)的批處理
文件,并彈出名為“\masm32\bin\lnk.txt”的窗口報告結(jié)果如下:
volume in drive c is liu
volume serial number is 4061-17d7
directory of c:\pwin951\temp
test asm 8,401 06-05-02 19:34 test.asm
test obj 3,720 06-05-02 19:35 test.obj
test exe 4,608 06-05-02 19:38 test.exe
3 file(s) 16,729 bytes
0 dir(s) 24,395,776 bytes free
其中包括新生成的可執(zhí)行文件test.exe的有關(guān)信息.
注:沒有找到資源文件不屬于錯誤,因此如果你的程序匯編和鏈接均順利完成,但運行時卻看不到窗口,很可是你將窗口信息放在資源文件中,但資源文件尚未編譯或編譯沒有成功。
⒍ 運行生成的可執(zhí)行文件.使用菜單欄上的菜單project -> run program。
看到程序運行的結(jié)果了嗎?
如果看不到窗口,很可能是你將窗口信息放在資源文件中,但資源文件尚未編譯或編譯沒有成功。
總之,要注意的是,對源程序文件或資源文件修改后一定要先存盤,然后再進行后繼操作,否則錯誤依舊。
project菜單中其它菜單項的功能和用法:
assemble & link 匯編源程序并鏈接,適用于資源文件未修改,但修改了源程序的情況
build all 編譯資源文件,匯編源程序并鏈接,適用于資源文件和源程序均修改的情況
console link obj file 匯編控制臺型源程序
&console assemble link 匯編并鏈接控制臺型源程序
console build all 生成控制臺可執(zhí)行程序
二、開啟masm32的在線幫助功能
masm32大量使用了windows api函數(shù),眾多的函數(shù)不同的參數(shù)我們很難記住,只能現(xiàn)用現(xiàn)查。
masm32提供了在線幫助功能,但必須進行相應(yīng)設(shè)置,才能“招之即來”。
在qeditor中按功能鍵 f1 ,彈出對話框,幫助文件?.hlp沒找到?怎么辦?跟我做:
選擇菜單tools -> change editor settings,彈出名為“change quick editor settings”的窗口,從double
click item to edit下的列表框中找到&ldqu