Hi all,

I have a *.asm file coded in MASM it's consists of about 7K lines.. now I have to port this assembly file to linux. So I google for Masm2as but it didn't work out.

then I thought with little modification will convert the code to NASM style and since NASM is available for both the OS and platform so it will be easy.

But I got stuck since i am not familiar with NASM coding syntax on win32. can anybody help me out of this situation..

Posted on 2003-07-28 00:19:36 by processingspeed
Try FASM instead of NASM. NASM is an old assembler without support. FASM have Linux version and have very easy and full documented syntax. Also good online support.

http://www.flatassembler.net - main site of FASM
http://board.flatassembler.net - FASM board where you can take support and help.
Posted on 2003-07-28 01:15:09 by JohnFound
Since I have to use NASM,

So i found out the solution,

many tutorials are avaiable so I dont' find any problem porting MASM compatible code to NASM. It's working fine and as efficient as MASM generated code.

If someone is struggling with similar problem, do see the NASM development site as sourceforge. answer is there...

Posted on 2003-07-29 06:47:31 by processingspeed
> NASM is an old assembler without support.


NASM has support. I think that it's more diffused than any other
asembler for Linux (except gnu as, that is other option to port between
Windows and Linux).

But I don't want waste my time speaking about what is better, NASM or
FASM. I only say that I use NASM and I have written codes that runs
fine in any ix86+ platform. I love its -fbin option :)

NASM is ever in progress.

NASM includes a option for TASM compatibility, and is not so hard
to write macros for MASM instructions like "invoke", ".if", "while", "proc",
"local", and anything that you want use from MASM.

processingspeed, I don't understand what is you problem to port your
code from MASM to NASM. But if you want to know anything about this
only ask for here or at my email:http://www.asmcommunity.net/board/cryptmail.php?tauntspiders=in.your.face@nomail.for.you&id=9d18fe5103248ba0997650f8b70cb749

Posted on 2003-07-29 23:16:03 by n u M I T_o r
Hi n u M I T_o r,

In order to assemble my masm code i have to make hell lot of changes in masm code as result the code lost it readibiliy, which i don't want and it started looking ugly and scary.

so I want to use macros for the same code. Can it be possible for u to provide these macros so that I can maintain my source code and certain others will definitely get benefits from this also.

Posted on 2003-08-01 06:54:05 by processingspeed
uuu... one more time.. i will not say what append with my original post lol...

ok , you can see this: http://www.asmcommunity.net/board/index.php?topic=9951

also i see that the page of the original pakage win32n.zip is down.. alot of info and examples..

I have a modified version of funct that work ok and more easy, also can "export" easy the names for call from a programm in C.

Also can try http://www.drpaulcarter.com/pcasm/

Nice day.
Posted on 2003-08-01 22:04:55 by rea

If you want assembly portable source codes, you must consider some facts.
The readibility of a assembly source code does not depend of the assembler,
does depend of the programmer and his knowledge of assemble language and
of the assembler that he uses. Without use MASM macro instructions you can
obtain a very readible ix86 portable source codes.

With NASM you have many posibilities using its preprocessor to write
macros; the best, I think, is what you have created, because you know
exactly what is happening with each macro, and each programmer has his
preferences and program specifications. It's impossible to find something
so abstract and general that be usefull for all.

I advise you read this article of mammon_:

and look at some interesting .inc files, e.g., nagoa.inc:

In NAGOA page you will find some usefull info about NASM.

You can look at the codes that I attach here. Are NASM
source codes with macros to write a gtk-gnome application. These
macros are very simple to use. I don't include macros for
control constructs because I use it not much. You can use
a macro instruction "invoke" like MASM to call extern functions
and a macro directive "PROC - ENDP" to declare procedures and
easily handle local variables.
Posted on 2003-08-02 12:12:31 by n u M I T_o r
Here is the attach
Posted on 2003-08-02 12:14:08 by n u M I T_o r
Hi hgb!

I discovered why some NASM users are not agreed about changes to the
NASM source code to get a intuitivest way to use structures and unions.
Some guys have written macros to do it. They use it since a year ago.
They think publish it soon with a full porting of the MASM32 window.inc
to NASM.

You know something about this?
Posted on 2003-08-02 12:23:43 by n u M I T_o r
n u M I T_o r,

Thanks alot for those macros. Actually by readibility i mean to say that .. since i have to replace all the invokes and .if macros with plain assembly instructions so the code started looking ugly. Since the entire code is somewhat about 10K lines so it was pretty tought for me to add the comments to increase the visibility of logic to other.

But anyways those links provided by you is not working.

Once again..thanks alot.

Posted on 2003-08-03 23:45:57 by processingspeed
well, try this link:


and look at the pappers:
APJ: Extending NASM. Using and abusing the NASM preprocessor.

About NAGOA, I don't know what is happenig :(

I atach here the nagoa.inc in a zip. Maybe is not the last version,
but must include some macros for control structures like if, for,
and while. Anyway, the papper of mammon_ explains well how to
write this macros. Now is easiest write it because the NASM
preprocessor has more features.
Posted on 2003-08-04 03:40:53 by n u M I T_o r
If the link fails, here is the papper...
Posted on 2003-08-04 03:42:28 by n u M I T_o r
Originally posted by n u M I T_o r

Some guys have written macros to do it. They use it since a year ago.
They think publish it soon with a full porting of the MASM32 window.inc
to NASM.

You know something about this?

If I am not wrong you are calling about xstruct???, if is this the case, yes i know about it, also other peple are clening it up and try a best thing, i dont know the advances about this approach, but aparenly will look good ;). But also i dont agree completely with the form f use, lke you say, is not much intuitive.... :(, also i try modificate that macro but i get in troubles in the way that i whant, also is a little more fast the assembly time implement in the code this.

In fact the only thing left to the change i do is let the user initialize its structs, unions with the way like < 45, "hola">, etc, is the only left thing.. I see that i can do for structs.. near to easy, but the problem comes with unions, is a little more hard to implement and will need more work, then I choice to stop or implement the initialization for both or not implement nothing of initializet data in the code with structs unions, and I choise the second.. also is not the final thing that i will try, i am rethinking and planing a secon way.. I dont know how many time this will take me.

You can visit my page, now i dont have nothing more than some example and the win32n modificated, but not the source code that i modificate ... I will ask if I can put or they whant a diff with the actual code...and some one if whant to use.. simply patch the code and compile in his machine.. also the code dont cut the normal use of nasm, you can continue using struc or any other macro that you have ;).

Nice day dude.
Posted on 2003-08-04 11:34:50 by rea
> If I am not wrong you are calling about xstruct???

Yes, is that work. And the authors have a packet that includes a NASM
version of masm32's WINDOWS.INC

> also the code dont cut the normal use of nasm, you can continue using
> struc or any other macro that you have

That is important, because, imagine!, what would happen with the old
NASM source codes that use struct?

I've look at the ALINK sources, and I found & fixed some bugs. I advised
to the author, though I go on working on that. I fixed problems in the
code section characteristics and in the resources section virtual address

If you want, I can send you this version.

Posted on 2003-08-04 22:13:46 by n u M I T_o r
Heh, heh, heh,...

"NASM is old","NASM hasnt got support",...

Sorry If I sound like too rude, but THATS BULLSHIT... Those are just some library phrases that someone once said and now a lot of people ( people who really dont know ENOUGH about NASM and its support ) follow and copy&paste as zealots...

See, me and Jibz have been translating WINDOWS.INC from MASM32 ( yes, MASM32 has a big support, although I dislike its syntax - as I dislikes FASM?s - cos they are simply non real, plain and raw ASM, NASM IS ). And we will publish it in a few days time ( in a complete ready to use package ). Maybe today...

Jibz XSTRUC macros are really cool and powerfull ( also, they ARE INTUITIVE... and obly people to learn the structs... every asm writer should do this... )

P.S.: I could give anyone some guidelines of the criteria that I use to know what "real" ASM syntax is... ( mov eax,Var == mov eax, >> this is pure shit, not real asm... ).

Bye, hoping truth doesnt hurt...
Posted on 2003-08-05 09:45:25 by sheroc
--This is not a flame, simply my personal disagreement, I hope it doesn't burn--

as I dislikes FASM?s - cos they are simply non real, plain and raw ASM, NASM IS ).

FASM is asm! FASM is real, fasm in plain, raw and 1:1 (when no macros are used).
If NASM isn't dead now it has been revived, because it was dead for a while, I sure looked for it, but all I found was dead links and a dead "official site", or did Google give me the wrong non-real non-asm results?

P.S.: I could give anyone some guidelines of the criteria that I use to know what "real" ASM syntax is... ( mov eax,Var == mov eax, >> this is pure shit, not real asm... ).

FASM syntax:
mov eax, Var ; mov address of var to eax
mov eax, ; mov the dword at Var to eax
Isn't this real asm? Then what is real asm?
Posted on 2003-08-05 13:14:40 by scientica
Originally posted by sheroc
I could give anyone some guidelines of the criteria that I use to know what "real" ASM syntax is... ( mov eax,Var == mov eax, >> this is pure shit, not real asm... ).

If your assembler has the capacity for the OFFSET directive then mov eax,VAR generally does not mov the address into eax, in some assemblers (i.e. GoAsm) it will just throw an error. Since most assemblers that use the OFFSET directive will not allow the direct mov of an address in this manner why not have the assembler assume that you have put [] around VAR, it does not affect anything else. As for what is asm syntax, well, that depends on how you look at it. I exchanged some emails with Intel Developper Support and they tend to lean towards MASM syntax since they got rid of their assembler though they do not have a real preference. Since Intel never provided a standard for syntax, and since they no longer have an assembler, they basically said that they don't really care much either way. Intel has left it up to each assembler author to decide on his/her own syntactical structure so the correct answer is all assembler syntaxes are the correct syntax and none are.
From Elizabeth S.
Intel Developper support

...Intel does not have a preference, since we do not have an assembler any more.
The syntax is determined by the assembler; all Intel cares about is that the
encoding of the instruction is correct.

I am unaware of any Intel provided standards for IA32 processor-specific
assemblers. You may find the processor manuals, especially the optimization
guide useful...

They are the first and last word in x86 syntax, end of argument.
Posted on 2003-08-05 13:42:21 by donkey
The problem is that MASM and others let you do it in both or even 3 ways... so? ambiguosness.

Also, if intel is lazy/careless ( they weren?t so some time ago ), I am also careless to say that the machine itself dictates some strict rules & concepts, and even if theres is not a ONLY syntax, MASM and others piss off over theese rules.

I see lots of misunderstanding problems ( mostly with newcomers to x86 ASM ) with memory addresses and indirections ( as with memory operand sizes... ) and some other things? why does this happen? most of them start using MASM ( believe it or not ).

Cos MASM gives variables more abstraction than the needed ( among other inconsistences ) and is the double sided blade ( yes, it simplifies things a bit or so it seems ) cos its more "user friendly" and the user doesnt need to bother with those facts/small concepts... but it makes people not to dive into the deepest little details

This is my last end too... people who comes from the old era knows what I am talking about and they know that to learn ASM is also to think at machine code level concepts in a strict way ( yes: from the first beginning ).


P.S.: Yes, I tried FASM and it has a lot of common thing with NASM; for FASM I just said I dislike its syntax ( and import/exports... ) although is the second assembler I would use if there was no NASM.
Posted on 2003-08-05 14:05:44 by sheroc
The release I promised... If someone wants to try it ( just last NASM with a structured package and complete include file -Tamas Kaproncai?s win32n.inc is cool but its far lesser than WINDOWS.INC- and Jibz XSTRUC macros ).

for those who try it and want to contribute with bugs, possible additions,...

see the mail address in the package ( its a RAR SFX .EXE, although I had to zip it to be able to attatch it here ;) )

Posted on 2003-08-05 14:14:43 by sheroc
No MASM does not let you do it in both ways.

mov eax,VAR will never mov the address of VAR into eax. MASM does it the right way. If you wish to mov an address into eax that is only known at run time you use lea, if you wish to mov the offset of a variable that is known at compile time you use OFFSET (after all when it is assembled it is an offset and not an address until the PE loader is done), all other forms mov a value. You can go the route of GoAsm and throw an error or the route of A386 and just muddle the whole thing by basing it on whether the label was declared with a colon (:) or not. But I like MASM's way of doing it, a personal preference yes, but it is also the personal preference of 90+% of all assembly programmers. The only way in an x86 processor you can use a referenced address is from within a register so that is the only place in MASM that the [] rule for dereferencing is applied. All other applications of the [] are just idiosyncracies of the assembler author, nothing more.
Posted on 2003-08-05 14:29:21 by donkey