masm32v12编译器自带库masm32.lib在nasm中的使用。
修改了masm32.inc文件在nasm中使用。
;╔═══════════════════════════════╗ ;║ MASM32 库改nasm ║ ;╚═══════════════════════════════╝ ; ruYYLYLsYsYsLsYuY: ; :::vdQRggDgDgDgDgDRRMUi.:. ; .IQBg1:................7bBBZr ; .1dJrrr...................irrvXK7 ; .rj27: ..................... . .r1UL:. ; LBZ: . . . . . . ... UQE. ; 7ZI: . ............. .vZI. ; v5j:. iBBBBQ. .... . ..... 2BBBBZ .75U: ; .5Q1. LBBBBB: ... . BBBBBB iggr ; jZ1. :BBBBR. .:i:. LBBBB5 rbP: ; YDJ... .vBBBK: ...rPKi ; uZJ...:. .75EDQBBBBDEKs: ... rPb: ; .5B2:.rv7:..rSBBBBBQMEgRBBBQBZY...rvv:.rMgr ; isuvLvYr: .rbREqDQBBBQBBRPPgMJ. .ivLv7sJ7. ; rMdr.::. :2bRRQZq7. ..:.:uQ5. ; vMd: .... . . ..... .uRP. ; :vSs: ......... . ......:....rSui. ; i1uvi..:.:...:.....:.:....:7Y27. ; .IEJ.......:.....:.......rqPr ; rSPSKIsr:.. ... . ... ..:ivuXXPqJ. ; iYrrsPKs:.. iLY: ... .rs7. .:72d27rv7. ; .ijYriJKJ.....ivj7: . .iJYr:. . r55ri727:. ; rPS:.iKdK7:. .uPY .. .. :XPi .i1bdL:.vEU. ; ibS:.:rr.... .jbv .j5r :uSi :qXi ....:ri..vZs. ; .iJIvi...... .:7jX5u7r7UXSL7rYUqUYi:.......:rUU7.. ; ijqI7..... .YXXr. :YKUr :1X2i. ....iJPIr. ; iur:.... . .....iY7. ; ...... . . . . . . . . ...... ; .i:........... . ..... . . ... .......:r: ; :sQgJ.....:.. ... . ........... .......rbBqr. ; .LEPILr:....... ... . . . ..............:ruXD5i ; 7dqi......... . . . . . ..........jDS. ; .JE5i ....................... .YZ5r. ; r2I1j7:. ................rsI25v: ; 7gBBdr::..::iii::...::2QBQ2. ; rgQgdZEZZgMQMMDDdDdDRQ2. ; :qdbPbr :KBBBs...idBBM7 .SbbPEv ; .vDBBBBQRv:... :SBBP. LBBZ7. ...iPBBBBBBI: ; :gBQBgMgQBBBBBBQBQQQgi .5QBRBBBBBBBBQgMgRBBBJ ; ; by Pierre.Y 2021/5/16 %ifndef NASM_INC %define NASM_INC ;╔══════════════════════╗ ;║ 必选的宏定义 invoke 函数引用 ,x1,...,x2 ║ ;╚══════════════════════╝ %macro invoke 2-* %define _j %1 %rep %0-1 %rotate -1 push dword %1 %endrep invoke _j %endmacro extern AssociateColorProfileWithDeviceA ; 命令行两个参数 字串 和 数 extern ArgCl ;图形模式 extern ArgClC ;终端模式 extern GetCL ;128 字节缓冲版本 extern getcl_ex ;不限制尺寸版本 extern Alloc extern Free ;╔════════╗ ;║ 数字和文本转换 ║ ;╚════════╝ extern a2dw extern atodw ;返回值在EAX extern htodw ;返回值在EAX extern dwtoa ;值在缓冲区 extern dw2a extern dw2hex extern ustr2dw extern udw2str extern GetErrDescription ;╔══════════╗ ;║ 字串和浮点指针转换 ║ ;╚══════════╝ ;extern FloatToStr stdcall fpin:QWORD, szDbl:PTR CHAR ;extern FloatToStr2 stdcall fpin:QWORD, szDbl:PTR CHAR ;extern StrToFloat stdcall szIn:PTR BYTE, fpout:PTR DWORD ;〓〓〓〓〓〓〓〓〓〓 ;▓ 搜索功能 ▓ ;〓〓〓〓〓〓〓〓〓〓 extern InString extern BinSearch extern partial ; Boyer Moore 基本功能 ; ~~~~~~~~~~~~~~~~~~~~ extern BMBinSearch extern BMHBinsearch extern SBMBinSearch extern WordCount ;〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓 ;▓ "one shot"或 "one pass" 逻辑解码 ▓ ;〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓 extern XorData extern RolData extern RorData extern StrLen ; Agner Fog's 快速字串求长度 ;〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓 ;▓ 字串后为0的转换处理函数 ▓ ;▓ (必须和旧名相等) ▓ ;〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓 extern szappend extern szCatStr extern szCmp extern szCmpi extern Cmpi extern szCopy extern szLeft extern szLen extern szLower extern szLtrim extern szMid extern szMultiCat extern szMonoSpace extern szRemove extern szRep extern szRev extern szRight extern szRtrim extern szTrim extern szUpper extern szWcnt ;〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓 ;▓ 必须和原名类型等相等 ▓ ;〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓 %define lnstr szLen %define cmpstr szCmp %define cmpsi szCmpi %define revstr szRev %define lcase szLower %define ucase szUpper %define ltrim szLtrim %define rtrim szRtrim %define trim szTrim %define lstr szLeft %define rstr szRight %define midstr szMid ;╔═══════╗ ;║ shell 处理 ║ ;╚═══════╝ extern shell extern shell_ex extern StripRangeI extern StripRangeX extern MemCopy extern memfill extern GetAppPath extern GetAppPathW extern NameFromPath extern NameFromPathW extern GetPathOnly extern GetPathOnlyW extern exist extern existW extern filesize extern filesizeW extern FrameCtrl extern FrameWindow extern FrameGrp extern Frame3D extern line extern circle extern DisplayBmp extern DisplayIcon extern VerticalTile extern SetBMcolor extern BmpButton extern _Stdout extern StdOutW extern StdErr extern StdErrW extern StdIn extern StdInW extern locate extern ClearScreen extern StripLF extern wait_key extern ret_key extern BrowseForFolder extern FontDialog extern ColorDialog extern PageSetupDialog extern PrintDialog extern Read_File_In extern ofCallBack extern Write_To_Disk extern sfCallBack extern RichEd1 extern RichEd2 extern GetPercent extern IntMul extern IntDiv extern IntSqrt extern nrandom extern nseed ;╔═════════╗ ;║ 预建对话框类型 ║ ;╚═════════╝ extern GetTextInput extern AboutBox extern GetFile extern LoadList extern IPtoString extern GetIP ;╔═══════════════╗ ;║ Ernie Murphy 的图像读取处理 ║ ;╚═══════════════╝ ;〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓 ;▓ 使用 BitmapFromMemory, BitmapFromFile 和 BitmapFromResource 函数 ▓ ;▓ 源码要包括在下面两个函数之间 ▓ ;▓ ▓ ;▓ invoke CoInitialize, NULL 源码开始 ▓ ;▓ invoke CoUninitialize 源码结束 ▓ ;〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓 extern BitmapFromFile extern BitmapFromMemory extern BitmapFromPicture extern BitmapFromResource ;╔═════════╗ ;║ 文件输入输出处理 ║ ;╚═════════╝ extern read_disk_file extern read_disk_fileW extern write_disk_file extern write_disk_fileW ;╔══════════╗ ;║ 内存图表文件处理 ║ ;╚══════════╝ extern CloseMMF extern CreateMMF ;╔══════╗ ;║ 排序处理 ║ ;╚══════╝ extern nrQsortA extern nrQsortD extern CombSortA extern CombSortD extern testreg extern HexDump extern AsciiDump ;╔═════════════╗ ;║ ASCII 和 32位长整数转换 ║ ;╚═════════════╝ extern atol extern ltoa ;╔════════════╗ ;║ 文件打开和关闭对话框 ║ ;╚════════════╝ extern OpenFileDialog extern SaveFileDialog ;╔════════╗ ;║ ASCII到宽字符 ║ ;╚════════╝ extern a2wc ;╔═══════╗ ;║ 数组计算处理 ║ ;╚═══════╝ extern arr_add extern arr_mul extern arr_sub ; ------------------- ; create dynamic aray ; ------------------- ;╔════════╗ ;║ 建立动态数组 ║ ;╚════════╝ extern create_array ;╔══════════╗ ;║ 文件字节计数处理 ║ ;╚══════════╝ extern byte_count ;╔══════════╗ ;║ 读入驱动列表字符 ║ ;╚══════════╝ extern load_drives ;╔══════════╗ ;║ C风格字符测试处理 ║ ;╚══════════╝ ;extern isalpha ;extern isupper ;extern islower ;extern isnumber ;extern isalphanum ;╔═════════╗ ;║ hybrid 快速排序 ║ ;╚═════════╝ extern assort extern dssort ;╔═════════╗ ;║ hybrid 快速排序 ║ ;╚═════════╝ extern asqsort extern dsqsort ;╔═════════╗ ;║ hybrid 快速排序* ║ ;╚═════════╝ extern acisort extern dcisort ;╔═════════╗ ;║ hybrid 插入排序 ║ ;╚═════════╝ extern aissort extern dissort ;╔══════════╗ ;║ sharker 排序(安全) ║ ;╚══════════╝ extern ccsorta extern ccsortd ;╔════════╗ ;║ 快速排序 ║ ;╚════════╝ extern qssorta extern qssortd ;╔════════╗ ;║ Shell 字串排序 ║ ;╚════════╝ extern ssorta extern ssortd ;╔════════╗ ;║ Comb 字串排序 ║ ;╚════════╝ extern cstsorta extern cstsortd ;╔════════╗ ;║ 冒泡排序法 ║ ;╚════════╝ extern bstsorta extern bstsortd ;╔════════╗ ;║ 读写内存文本行 ║ ;╚════════╝ extern readline extern writeline extern tstline extern parse_line extern lfcnt ;╔════════╗ ;║UNICODE字串处理 ║ ;╚════════╝ extern ucappend extern ucArgByNum extern ucCatStr extern ucCopy extern ucCmdTail extern ucCmp extern ucFind extern ucGetCL extern ucgetline extern ucLen extern ucLeft extern ucLtrim extern ucMid extern ucMonoSpace extern ucRemove extern ucRep extern ucRight extern ucRtrim extern ucLower extern ucUpper extern ucRev extern ucMultiCat extern ucWcnt extern ucOpenFileDialog extern ucSaveFileDialog ;╔═════╗ ;║ 单词覆盖 ║ ;╚═════╝ extern wordreplace ;╔═════╗ ;║ 扩展函数 ║ ;╚═════╝ extern atodw_ex extern byt2bin_ex extern wrd2bin_ex extern dw2bin_ex extern bin2byte_ex extern dw2hex_ex extern hexflip32 ;╔═════════════╗ ;║ 高速二进制/十六进制转换 ║ ;╚═════════════╝ extern bin2hex extern hex2bin ;╔═════════╗ ;║ 附加 shell 函数 ║ ;╚═════════╝ extern wshell ;╔═══════════╗ ;║ 比较已知长度的内存块 ║ ;╚═══════════╝ extern cmpmem ;╔═══════╗ ;║ 代码结构定义 ║ ;╚═══════╝ ;struc RUN_SYNCH_PROCESS_EX\ ; ; .priority dd ? ; priority setting ; .timeou dd ? ; timeout interval ; .rvcreate dd ? ; CreateProcess() return value ; .exitcode dd ? ; GetExitCodeProcess() exit code ; .rvwait dd ? ; WaitForSingleObjectEx() return value ; ;endstruc ;extern run_synch_process_ex ;╔════════════════╗ ;║ 返回 CreateFont 函数的字体句柄 ║ ;╚════════════════╝ extern RetFontHandle extern ArgByNumber extern get_ml extern decomment ;╔═════╗ ;║ 文本函数 ║ ;╚═════╝ extern ltok extern wtok ; -------------------- ; clipboard text algos ; -------------------- ;╔════════╗ ;║ 剪贴板文本处理 ║ ;╚════════╝ extern GetClipboardText extern SetClipboardText ;〓〓〓〓〓〓〓〓〓〓〓〓 ;▓ 动态数组函数 ▓ ;〓〓〓〓〓〓〓〓〓〓〓〓 extern arralloc extern arrealloc extern arrfree extern arrset extern arrget extern arrcnt extern arrlen extern arrtrunc extern arrextnd extern arrtotal extern arr2file extern arr2mem extern arr2text extern arrtxt extern arrfile extern arrbin %else %warning "〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓" %warning "▓ nasm 的 masm32.lib 库文件头 ▓" %warning "〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓" %endif
库文件:m32lib.zip
使用方法 asm 文件中包含include "masm32.inc",
使用golink链接器例子:
把函数的obj文件直接加到主程序之后,可以和动态链接库一起链接。
GoLINK /mix /console /entry start ID.obj stdout.obj strlen.obj msvcrt.lib kernel32.dll user32.dll [msvcrt.dll]可选