From vapier at gentoo.org Mon Dec 3 19:31:32 2007 From: vapier at gentoo.org (Mike Frysinger) Date: Mon, 3 Dec 2007 22:31:32 -0500 Subject: yasm vs nasm differences Message-ID: <200712032231.33376.vapier@gentoo.org> is there a section that does an outline of places where yasm/nasm differ ? i think such a thing would be quite handy ... we've been trying to get all packages in Gentoo working with yasm rather than nasm ... one of the places we noticed was %include handling. this is half-mentioned offhand in the yasm documentation. yasm: - %include will not search $PWD - paths given to -I will have a path separator appended to it nasm: - %include will search $PWD before any -I paths - paths given to -I will not have a path separator appended to it personally i think the yasm behavior is saner on both counts. -mike -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 827 bytes Desc: This is a digitally signed message part. URL: From peter at tortall.net Mon Dec 3 21:42:11 2007 From: peter at tortall.net (Peter Johnson) Date: Mon, 3 Dec 2007 21:42:11 -0800 (PST) Subject: yasm vs nasm differences In-Reply-To: <200712032231.33376.vapier@gentoo.org> References: <200712032231.33376.vapier@gentoo.org> Message-ID: <20071203212449.M1191@cvs.tortall.net> On Mon, 3 Dec 2007, Mike Frysinger wrote: > is there a section that does an outline of places where yasm/nasm differ ? i > think such a thing would be quite handy ... we've been trying to get all > packages in Gentoo working with yasm rather than nasm ... Unfortunately there's not really a unified list. I should probably work on one; I'll try to put together an initial list in this email. Generally we try to be compatible except where there's a compelling reason to be different (such as with %include file handling). There's a note of %include being C-compiler-like in the most recent release notes and its behavior is more precisely described in the Yasm manual. There's a few 64-bit differences, as Yasm had support first and I don't want to break backwards compatibility with older Yasm programs. The differences are detailed in a few different places in the Yasm manual and in one place on the "AMD64" wiki page. You've already run across the preprocessor not handling relocatable expressions in %if. We're working on trying to handle the simpler cases, but Yasm will probably never handle everything NASM does in this area due to its different internal structure. By and large it's possible to do most of these differently. Yasm doesn't need a -O option (although it accepts it for compatibility purposes); it always generates the most optimal code possible. Yasm handles ALIGN more intelligently; when executed in a known code section, it fills not with 0x90 (one-byte NOP) but with more efficient multi-byte NOPs where possible. It also automatically adjusts section alignment to the largest ALIGN value. ALIGNB operates the same way as in NASM. This is documented in the Yasm manual (section 3.8.6). Yasm has a number of features NASM doesn't have, such as structured exception handling support for Win64 targets, more extensive CPU directive options, and DWARF debugging support. Hope this helps, and thanks for all the bug reports! We're already working on fixing most of them. Peter From yh8h at cs.virginia.edu Sun Dec 16 20:30:45 2007 From: yh8h at cs.virginia.edu (Yan Huang) Date: Sun, 16 Dec 2007 23:30:45 -0500 Subject: question of the usage Message-ID: <4765FB75.5080109@cs.virginia.edu> Hi, I am new to Yasm. I am wondering if yasm provides a library interface of assembling human-readable assembly instructions into binary code and disassembling binary code to human-readable assembly instructions (assuming all the tags used in the instructions have already been translated to numbers). I am expecting a well-defined APIs to use in my own program. Could anyone help me out? I really appreciate any information. Thanks, Yan From peter at tortall.net Mon Dec 17 23:22:19 2007 From: peter at tortall.net (Peter Johnson) Date: Mon, 17 Dec 2007 23:22:19 -0800 (PST) Subject: question of the usage In-Reply-To: <4765FB75.5080109@cs.virginia.edu> References: <4765FB75.5080109@cs.virginia.edu> Message-ID: <20071217231113.H52330@cvs.tortall.net> On Sun, 16 Dec 2007, Yan Huang wrote: > I am new to Yasm. I am wondering if yasm provides a library interface of > assembling human-readable assembly instructions into binary code and > disassembling binary code to human-readable assembly instructions > (assuming all the tags used in the instructions have already been > translated to numbers). I am expecting a well-defined APIs to use in my > own program. Yan, Yasm provides half that solution; currently there's no disassembly support, but it does have a pretty complete API for assembly (see http://www.tortall.net/projects/yasm/wiki/ProgrammerReferences). This documentation is for libyasm, the core library used by the "yasm" frontend. If you want to parse a certain syntax (such as NASM syntax), it's probably easiest to look at the yasm.c frontend code (http://www.tortall.net/projects/yasm/browser/trunk/yasm/frontends/yasm/yasm.c) and trim it down to your needs. For disassembly, I can direct you to a disassembler library called diStorm64 (http://www.ragestorm.net/distorm/). Disassembly has a significantly simpler API compared to assembly; the reason assembly is much more complex is due to the need to handle user expressions, symbol tables, etc. We're gradually working on trying to simplify the assembler API, but it's an evolutionary process. Feel free to post here if you have any yasm API questions. Peter From vapier at gentoo.org Mon Dec 3 19:31:32 2007 From: vapier at gentoo.org (Mike Frysinger) Date: Mon, 3 Dec 2007 22:31:32 -0500 Subject: yasm vs nasm differences Message-ID: <200712032231.33376.vapier@gentoo.org> is there a section that does an outline of places where yasm/nasm differ ? i think such a thing would be quite handy ... we've been trying to get all packages in Gentoo working with yasm rather than nasm ... one of the places we noticed was %include handling. this is half-mentioned offhand in the yasm documentation. yasm: - %include will not search $PWD - paths given to -I will have a path separator appended to it nasm: - %include will search $PWD before any -I paths - paths given to -I will not have a path separator appended to it personally i think the yasm behavior is saner on both counts. -mike -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 827 bytes Desc: This is a digitally signed message part. URL: From peter at tortall.net Mon Dec 3 21:42:11 2007 From: peter at tortall.net (Peter Johnson) Date: Mon, 3 Dec 2007 21:42:11 -0800 (PST) Subject: yasm vs nasm differences In-Reply-To: <200712032231.33376.vapier@gentoo.org> References: <200712032231.33376.vapier@gentoo.org> Message-ID: <20071203212449.M1191@cvs.tortall.net> On Mon, 3 Dec 2007, Mike Frysinger wrote: > is there a section that does an outline of places where yasm/nasm differ ? i > think such a thing would be quite handy ... we've been trying to get all > packages in Gentoo working with yasm rather than nasm ... Unfortunately there's not really a unified list. I should probably work on one; I'll try to put together an initial list in this email. Generally we try to be compatible except where there's a compelling reason to be different (such as with %include file handling). There's a note of %include being C-compiler-like in the most recent release notes and its behavior is more precisely described in the Yasm manual. There's a few 64-bit differences, as Yasm had support first and I don't want to break backwards compatibility with older Yasm programs. The differences are detailed in a few different places in the Yasm manual and in one place on the "AMD64" wiki page. You've already run across the preprocessor not handling relocatable expressions in %if. We're working on trying to handle the simpler cases, but Yasm will probably never handle everything NASM does in this area due to its different internal structure. By and large it's possible to do most of these differently. Yasm doesn't need a -O option (although it accepts it for compatibility purposes); it always generates the most optimal code possible. Yasm handles ALIGN more intelligently; when executed in a known code section, it fills not with 0x90 (one-byte NOP) but with more efficient multi-byte NOPs where possible. It also automatically adjusts section alignment to the largest ALIGN value. ALIGNB operates the same way as in NASM. This is documented in the Yasm manual (section 3.8.6). Yasm has a number of features NASM doesn't have, such as structured exception handling support for Win64 targets, more extensive CPU directive options, and DWARF debugging support. Hope this helps, and thanks for all the bug reports! We're already working on fixing most of them. Peter From yh8h at cs.virginia.edu Sun Dec 16 20:30:45 2007 From: yh8h at cs.virginia.edu (Yan Huang) Date: Sun, 16 Dec 2007 23:30:45 -0500 Subject: question of the usage Message-ID: <4765FB75.5080109@cs.virginia.edu> Hi, I am new to Yasm. I am wondering if yasm provides a library interface of assembling human-readable assembly instructions into binary code and disassembling binary code to human-readable assembly instructions (assuming all the tags used in the instructions have already been translated to numbers). I am expecting a well-defined APIs to use in my own program. Could anyone help me out? I really appreciate any information. Thanks, Yan From peter at tortall.net Mon Dec 17 23:22:19 2007 From: peter at tortall.net (Peter Johnson) Date: Mon, 17 Dec 2007 23:22:19 -0800 (PST) Subject: question of the usage In-Reply-To: <4765FB75.5080109@cs.virginia.edu> References: <4765FB75.5080109@cs.virginia.edu> Message-ID: <20071217231113.H52330@cvs.tortall.net> On Sun, 16 Dec 2007, Yan Huang wrote: > I am new to Yasm. I am wondering if yasm provides a library interface of > assembling human-readable assembly instructions into binary code and > disassembling binary code to human-readable assembly instructions > (assuming all the tags used in the instructions have already been > translated to numbers). I am expecting a well-defined APIs to use in my > own program. Yan, Yasm provides half that solution; currently there's no disassembly support, but it does have a pretty complete API for assembly (see http://www.tortall.net/projects/yasm/wiki/ProgrammerReferences). This documentation is for libyasm, the core library used by the "yasm" frontend. If you want to parse a certain syntax (such as NASM syntax), it's probably easiest to look at the yasm.c frontend code (http://www.tortall.net/projects/yasm/browser/trunk/yasm/frontends/yasm/yasm.c) and trim it down to your needs. For disassembly, I can direct you to a disassembler library called diStorm64 (http://www.ragestorm.net/distorm/). Disassembly has a significantly simpler API compared to assembly; the reason assembly is much more complex is due to the need to handle user expressions, symbol tables, etc. We're gradually working on trying to simplify the assembler API, but it's an evolutionary process. Feel free to post here if you have any yasm API questions. Peter