JWASM简介

来源:互联网 发布:php删除符号 编辑:程序博客网 时间:2024/06/05 14:41

JWASM是一个免费开源的MASM兼容汇编编译器(现在所说的MASM一般指MASM V8.0版本,因其支持X64),但又扩展了很多功能,尤其是64位汇编模式下,支持使用.if,.while、invoke等高级语法,而MLx64至现在仍然没有这些功能。所以写64位汇编,用JWASM要相对MASM容易许多


具体功能:

1、原生支持Intel OMF,微软的Coff(32/64位),Linux的ELF(32/64位),二进制,Windows PE(32/64位)和Dos MZ格式

2、JWASM编译的二进制文件可以在DOS、Windows、Linux下使用。对于OS/2、FreeBSD提供了makefiles。

3、支持AVX指令

4、JWASM的源代码是用C写的,可以移植,已经成功在Open Watcom, MS VC, GCC等上成功编译

5、对于Windows编程,JWASM自V2.01版本后,就可以与WinInc(32/64位)和Masm32(32位)一起使用。当然也可以与Sven B. Schreiber的WALK32.一起使用

6、C的头文件可以用h2incX转换为JWASM可用的include文件

7、JWasm的源代码在 Sybase Open Watcom Public License协议下发布,允许免费商业和非商业用途。

8、在发布的JWASM二进制包中包含一些源码例子。


JWASM始于2008年3月,是Open Watcom的WASM的一个分支。现在WASM的代码在JWASM中仍占的20%左右。


关于命令行选项,用 "jwasm -?" 或 "jwasm -h"查看,JWASM选项与MASM V8.0基本相同,当然有一些是JWASM特有的,有一些MASM V8.0的选项被JWASM舍弃了。

一个比较大的区别是JWASM无法自动调用Link程序(MASM里-c选项可以调用Link程序)。


语法:同Masm V8.0

指令集:同MASM V8,另外还添加了 AVX、SSE4.1 和 SSE4.2指令集,在MASM V9和V10中才加入这些指令集。

二进制代码的区别:JWASM编译出的二进制代码MASM有一些轻微的区别,在命令行中使用-Zg选项基本可以消除大部分有区别的代码,而有些代码区别没有被消除是因为JWASM修复了MASM的Bug所致。

修复MASM的Bug如下
#DescriptionFixed Masm Version1   the infamous "invoke" bug: if an argument for invoke has to be expanded (from BYTE or WORD to DWORD, for example ), bad code was generated.9 PROTOs contained twice in the source caused an EXTDEF entry to be generated in the object module.--3   "TYPE xmm0" will return 10 in Masm v6 and v7 - the correct value is 16.84   a nested structure might cause a GPF in Masm if the embedded STRUCT's starting offset has to be adjusted due to alignment.--5   defining huge arrays in Masm is very slow and might even cause a deadlock if COFF has been selected as output format.--6   for Masm v6 and v7, if an array > 64 kB is defined and output format OMF is selected, the array's size will be mod 0x10000 only.87Masm doesn't flag invalid numbers in struct/array initializer strings.--8if an ALIAS is defined somewhere in the source and the symbol table is listed, a 'General Failure' error occurs in Masm if output format is OMF. 9Type "coerces" for DWORD data items defined in a 32bit segment are ignored by Masm, i.e., "dd far16 ptr <symbol>" will generate a near32 fixup instead of a far16 one.--10if the ALIGN directive has to add 5 bytes in 32bit code segments, Masm includes an "add eax,0" opcode, which isn't a no-op because flags are modified.--11silent truncation of immediate constants: Masm v6 and v7 will accept line "mov [word_variable],12345h" without error.812preprocessed output with option -EP may erroneously contain text macros and macro function calls if the macros are located in the initialization string of a structured variable.--13Masm generates wrong code if a conditional jump is coupled with a type coercion which modifies offset magnitude. Examples: "jz near32 ptr ..." in 16bit code or "jz near16 ptr ..." in 32bit code).--14if the arguments given to Masm end with an option which expects a parameter (i.e. "ml -c -Fo"), a 'General Failure' may occur.--15floating-point data items in Masm can be followed by any suffix (example: REAL4 1.0foo, 2.0bar). JWasm won't accept this.--16If a local is defined inside a macro, Masm will create a unique name for it. The name is constructed by using '??' as prefix, followed by a hexadecimal number with 4 digits. There is no check for overflow, however, so if the total of locals in all macros exceeds 65536, strange errors will occur.--17If a weak external is defined for -coff with the ALIAS directive, an invalid fixup - and also a strange entry in the module's symbol table - is created.--18   If a section contains more than 0xffff relocations in COFF, the number of relocations that is stored in the object module is just the value of the lower 16-bit half of the relocation count.819If a symbolic constant (=equate) is made public in OMF format, Masm will store the symbol's value in a 16-bit record if it is in the range -32768 ... 65535. If the symbol is referenced in another module as a 32-bit number, it is always zero-extended, never sign-extended; hence values -1 ... -32768 will become 65535 ... 32768.--20if data labels become public by the -Zf option ( and not by the PUBLIC directive ), their names are not decorated. Also, if format is COFF, they won't become true publics, they're just included in the symbol table with class "static",--


下列的MASM功能被JWASM舍弃

1、“xmm(n)”和“mm(n)”语法,此语法仅MASM V6与V7支持

2、命令行选项 -Bl, -F, -Fe, -Fm 和 -link:因JWASM不能自动调用Link程序,所以这些选项被舍弃

3、命令行选项 -Fr 与 -FR:generate browser info

4、命令行选项 -Sc:generate timings in listing

5、命令行选项 -errorReport:通过Internet向微软报告编译器的错误信息


下列功能还未被支持

1、OPTION参数:OLDMACROS, EXPR16,READONLY

2、命令行选项 -AT:允许Tiny模式

3、命令行选项 -Sp, -Ss and -St:设置页长度、副标题与标题

4、命令行选项 -H:set max external name length

5、命令行选项 -Ta:编译非.asm文件

6、命令行选项-Zd:不支持ELF格式输出

7、命令行选项-Zi:不支持ELF格式输出


原创粉丝点击