Re: MASM32 vs NASM

From: Frank Kotler (fbkotler_at_comcast.net)
Date: 10/24/03


Date: Fri, 24 Oct 2003 00:12:34 GMT

Mário Lopes wrote:

> Hello there!
>
> I've started programming ASM (x86) due to a class i have on faculty.
> Unfortunately, the teacher uses MASM32 and win32 code-specific instructions
> like invoke and others, as wells as win32 libraries. The problem is that i
> only use Linux and i would rather continue doing it. So i would like to how
> can i program asm on linux using win32 libraries or something similiar to
> emulate MASM32..
>
> Thanks in advance and best regards!
>

Hi Mário,

Unless you're running a Windows emulator, win32 libraries won't do you
much good on Linux :) As you know, Nasm doesn't have any of that "high
level stuff" built in. You can "%include" macro files to get "invoke"
and "if" and "while" and "switch/case" and all that. You wouldn't want
"invoke" for Linux anyway - you want something that does syscalls. Get
the "asmutils" package from http://linuxassembly.org and I think you'll
find macro files that do pretty much what you want. You can write code like:

%include "system.inc"

sys_open filename, O_RDONLY
sys_read eax, buffer, BUF_SIZ
sys_write STDOUT, buffer, BUF_SIZ
sys_exit 0

If those files don't give you all the Masm-like functionality you want,
you may need to include other files, or cut-and paste a "custom" job.
Nasm's macro syntax is horrid - like Gas on bad acid - I'd cut-and-paste
macros others have written, rather than write my own, where possible :)

I don't think there's any question that Masm's macro capabilities are
better than Nasm's, but you should be able to do most of the same things
with Nasm. If you want something "Windows-like" in the sense of a GUI,
Numa has posted a couple Xwindows examples:

Xlib sample
1. http://mipagina.cantv.net/porrasgarcia/xl.tar.gz

2. GTK samples
http://mipagina.cantv.net/porrasgarcia/gnometest.zip
http://mipagina.cantv.net/porrasgarcia/gnometest.tar.gz

To be honest, I haven't had a chance to look at 'em. There may be
something there that would interest you. Worth noting that HLA runs on
Linux (Fasm, too) - perhaps that would be what you want. Whatever you
do, don't abandon Linux just for MASM32... we'll think of something!

Best,
Frank



Relevant Pages

  • Re: MASM32 vs NASM
    ... as wells as win32 libraries. ... > only use Linux and i would rather continue doing it. ... FASM, NASM, HLA, and Gas are your only choices ... HLL-like control statements like invoke, ...
    (alt.lang.asm)
  • Re: Future of IT in Lebanon
    ... IT industry to target, and given the numbers out there, I would say that for the desktop, Windows will continue to blow Linux away, so between the two, I would pick Windows, and yes, Linux for the desktop remains an experiment. ... Open Source can be for Windows, Linux, etc. ... So, when you record a macro, it simply records the keystrokes. ...
    (soc.culture.lebanon)
  • Re: Use macro parameter in string; Find type definition
    ... I am new to linux and all the type definitions are driving me mad. ... When a type name is actually a macro, ... int main { ...
    (comp.lang.c)
  • Re: Two Click disassembly/reassembly
    ... I had in mind to run the Linux version of this through Jeff Owens' "asmsrc", just to see what it would do. ... Macro called in file "rhbottle.hla" at line 115 ... Index size must be an unsigned value greater than or equal to zero. ...
    (alt.lang.asm)
  • static inline vs macros for kernel functions ? (was how to handle name clashes in linux/freebsd kern
    ... msleep() changed from a function to a macro wrapping _sleep. ... Being a macro, it is a lot harder to hide it in case of name clashes ... we are integrating some linux kernel source code with FreeBSD source, ... msleep- used to be a function in FreeBSD 6.x, but now it is a macro ...
    (freebsd-current)