Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

nasm compiled asm files

OSR_Community_UserOSR_Community_User Member Posts: 110,217
Hello everyone,

Is it possible to set the sources file to compile an asm file with nasm
instead of masm?


Problem:
I have a customer that insists of having 32bit asm "optimized" code a
driver and it's compiler is nasm.
When I finally got the thing to compile for i386 base files, I am
getting errors about the .h file, but not when i compile with nasm.
So is it possible to tell build to use nasm instead of masm?

Cheers
Obble.

Comments

  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    You might be able to do something with 'makefile.inc;' if nasm has a ml compatibility mode (don't recall), you might be able to cheat and redefine AS.

    Good luck,

    mm
  • Gary_Little-3Gary_Little-3 Member Posts: 1,208
    What is the error that is causing the header file to barf when using MASM?
    Extending the make/build is possible using the makefile.inc as Martin
    suggested, but the question then is will Link be happy with the obj file?
    The best bet is to "fix" the header file and stay within the realm of tools
    that are known to work when building drivers.

    And really, what is so "special" about that "optimized" code? I remember
    when it was common practice to write your code in PASCAL, FORTRAN, or even
    C, generate ASM files and then butcher the living hell out of them to get
    the final executable to fit in that 16K of RAM in which you had to run.
    That's how the boys and girls at Apple got the first Macintosh to fit in
    it's original 64k. "Optimized" code to day? Can you spell "bullshit"? I'll
    bet it's the "pet code" of some arrogant developer who thinks his shit don't
    stink and more than likely it is now done better in the OS or exsiting
    support libs :)

    Gary G. Little
    H (952) 223-1349
    C (952) 454-4629
    xxxxx@comcast.net



    -----Original Message-----
    From: xxxxx@lists.osr.com
    [mailto:xxxxx@lists.osr.com] On Behalf Of NCH Obble Smith
    Sent: Monday, November 23, 2009 10:39 PM
    To: Windows System Software Devs Interest List
    Subject: [ntdev] nasm compiled asm files

    Hello everyone,

    Is it possible to set the sources file to compile an asm file with nasm
    instead of masm?


    Problem:
    I have a customer that insists of having 32bit asm "optimized" code a
    driver and it's compiler is nasm.
    When I finally got the thing to compile for i386 base files, I am
    getting errors about the .h file, but not when i compile with nasm.
    So is it possible to tell build to use nasm instead of masm?

    Cheers
    Obble.

    ---
    NTDEV is sponsored by OSR

    For our schedule of WDF, WDM, debugging and other seminars visit:
    http://www.osr.com/seminars

    To unsubscribe, visit the List Server section of OSR Online at
    http://www.osronline.com/page.cfm?name=ListServer


    __________ Information from ESET Smart Security, version of virus signature
    database 4633 (20091124) __________

    The message was checked by ESET Smart Security.

    http://www.eset.com



    __________ Information from ESET Smart Security, version of virus signature
    database 4633 (20091124) __________

    The message was checked by ESET Smart Security.

    http://www.eset.com
  • Prokash_Sinha-1Prokash_Sinha-1 Member - All Emails Posts: 1,214
    May be compiler gurus can shed lights ... But after ignoring the macro
    expansions, if I write codes is assembler instructions, how would the
    assembler optimize it, how much scope for optimization is still left
    there? Different compilers ( with or w/o different settings) of language
    X can possibly generate optimized code that might be vastly different...
    But once I start writing in assembler ( hardly much of macros), how the
    assembler gets significant optimization??

    Sounds like someone hacked some code from open src ( => nasm ).

    -pro

    Gary G. Little wrote:
    > What is the error that is causing the header file to barf when using MASM?
    > Extending the make/build is possible using the makefile.inc as Martin
    > suggested, but the question then is will Link be happy with the obj file?
    > The best bet is to "fix" the header file and stay within the realm of tools
    > that are known to work when building drivers.
    >
    > And really, what is so "special" about that "optimized" code? I remember
    > when it was common practice to write your code in PASCAL, FORTRAN, or even
    > C, generate ASM files and then butcher the living hell out of them to get
    > the final executable to fit in that 16K of RAM in which you had to run.
    > That's how the boys and girls at Apple got the first Macintosh to fit in
    > it's original 64k. "Optimized" code to day? Can you spell "bullshit"? I'll
    > bet it's the "pet code" of some arrogant developer who thinks his shit don't
    > stink and more than likely it is now done better in the OS or exsiting
    > support libs :)
    >
    > Gary G. Little
    > H (952) 223-1349
    > C (952) 454-4629
    > xxxxx@comcast.net
    >
    >
    >
    > -----Original Message-----
    > From: xxxxx@lists.osr.com
    > [mailto:xxxxx@lists.osr.com] On Behalf Of NCH Obble Smith
    > Sent: Monday, November 23, 2009 10:39 PM
    > To: Windows System Software Devs Interest List
    > Subject: [ntdev] nasm compiled asm files
    >
    > Hello everyone,
    >
    > Is it possible to set the sources file to compile an asm file with nasm
    > instead of masm?
    >
    >
    > Problem:
    > I have a customer that insists of having 32bit asm "optimized" code a
    > driver and it's compiler is nasm.
    > When I finally got the thing to compile for i386 base files, I am
    > getting errors about the .h file, but not when i compile with nasm.
    > So is it possible to tell build to use nasm instead of masm?
    >
    > Cheers
    > Obble.
    >
    > ---
    > NTDEV is sponsored by OSR
    >
    > For our schedule of WDF, WDM, debugging and other seminars visit:
    > http://www.osr.com/seminars
    >
    > To unsubscribe, visit the List Server section of OSR Online at
    > http://www.osronline.com/page.cfm?name=ListServer
    >
    >
    > __________ Information from ESET Smart Security, version of virus signature
    > database 4633 (20091124) __________
    >
    > The message was checked by ESET Smart Security.
    >
    > http://www.eset.com
    >
    >
    >
    > __________ Information from ESET Smart Security, version of virus signature
    > database 4633 (20091124) __________
    >
    > The message was checked by ESET Smart Security.
    >
    > http://www.eset.com
    >
    >
    >
    > ---
    > NTDEV is sponsored by OSR
    >
    > For our schedule of WDF, WDM, debugging and other seminars visit:
    > http://www.osr.com/seminars
    >
    > To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
    >
    >
  • anton_bassovanton_bassov Member Posts: 5,003
    > I'll bet it's the "pet code" of some arrogant developer who thinks his shit don't stink and more than
    > likely it is now done better in the OS or exsiting support libs :)

    There is a good chance that you are about to lose your bet. The very fact that NASM (not MASM and not TASM and not GNU ASM but precisely NASM) is being used strongly suggests real mode and bootloaders...


    Anton Bassov
  • anton_bassovanton_bassov Member Posts: 5,003
    > But after ignoring the macro expansions, if I write codes is assembler instructions, how would
    > the assembler optimize it, how much scope for optimization is still left there?


    1. The ability the mix 16-bit and 32-bit code in the same source file

    2. Ability to tell assembler to generate its output as a plain binary data without any OBJ headers..



    Anton Bassov
  • Prokash_Sinha-1Prokash_Sinha-1 Member - All Emails Posts: 1,214
    > 1. The ability the mix 16-bit and 32-bit code in the same source file
    >
    > 2. Ability to tell assembler to generate its output as a plain binary data without any OBJ headers..
    >
    >
    >
    Does it imply that none of the above can be done using masm?

    -pro
  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,002
    Prokash Sinha wrote:
    >
    >> 1. The ability the mix 16-bit and 32-bit code in the same source file
    >>
    >> 2. Ability to tell assembler to generate its output as a plain binary
    >> data without any OBJ headers..
    >>
    > Does it imply that none of the above can be done using masm?

    I don't know what it implies, but both of those things are achievable in
    MASM. #2 takes some trickery, and is EASIER with other assemblers, but
    it can be done with MASM, using "tiny" model.

    --
    Tim Roberts, xxxxx@probo.com
    Providenza & Boekelheide, Inc.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,002
    Prokash Sinha wrote:
    > May be compiler gurus can shed lights ... But after ignoring the macro
    > expansions, if I write codes is assembler instructions, how would the
    > assembler optimize it, how much scope for optimization is still left
    > there? Different compilers ( with or w/o different settings) of
    > language X can possibly generate optimized code that might be vastly
    > different... But once I start writing in assembler ( hardly much of
    > macros), how the assembler gets significant optimization??

    With x86 code, you can't. There certainly ARE architectures where the
    assembler does significant optimization, in instruction placement and
    reordering. The Trimedia processor is a VLIW machine with multiple
    functional units, where you can get up to 5 operations in a single
    instruction word. The assembler for that is a multi-pass beast that is
    as close to magic as I've ever encountered in an assembler.

    --
    Tim Roberts, xxxxx@probo.com
    Providenza & Boekelheide, Inc.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • Prokash_Sinha-1Prokash_Sinha-1 Member - All Emails Posts: 1,214
    That was my suspect ... though did not want to look / search...

    But I loose my brain when the OP says optimization using NASM...

    -pro

    Tim Roberts wrote:
    > Prokash Sinha wrote:
    >
    >>> 1. The ability the mix 16-bit and 32-bit code in the same source file
    >>>
    >>> 2. Ability to tell assembler to generate its output as a plain binary
    >>> data without any OBJ headers..
    >>>
    >>>
    >> Does it imply that none of the above can be done using masm?
    >>
    >
    > I don't know what it implies, but both of those things are achievable in
    > MASM. #2 takes some trickery, and is EASIER with other assemblers, but
    > it can be done with MASM, using "tiny" model.
    >
    >
  • Prokash_Sinha-1Prokash_Sinha-1 Member - All Emails Posts: 1,214
    Yep, it is understandable for VLIW type architecture but on x86 ....

    -pro

    Tim Roberts wrote:
    > Prokash Sinha wrote:
    >
    >> May be compiler gurus can shed lights ... But after ignoring the macro
    >> expansions, if I write codes is assembler instructions, how would the
    >> assembler optimize it, how much scope for optimization is still left
    >> there? Different compilers ( with or w/o different settings) of
    >> language X can possibly generate optimized code that might be vastly
    >> different... But once I start writing in assembler ( hardly much of
    >> macros), how the assembler gets significant optimization??
    >>
    >
    > With x86 code, you can't. There certainly ARE architectures where the
    > assembler does significant optimization, in instruction placement and
    > reordering. The Trimedia processor is a VLIW machine with multiple
    > functional units, where you can get up to 5 operations in a single
    > instruction word. The assembler for that is a multi-pass beast that is
    > as close to magic as I've ever encountered in an assembler.
    >
    >
  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,002
    NCH Obble Smith wrote:
    >
    > Is it possible to set the sources file to compile an asm file with
    > nasm instead of masm?

    Possible? Yes. Supported? No. In order to get support, you have to
    use the tools supplied in the WDK.


    > Problem:
    > I have a customer that insists of having 32bit asm "optimized" code a
    > driver and it's compiler is nasm.
    > When I finally got the thing to compile for i386 base files, I am
    > getting errors about the .h file, but not when i compile with nasm.
    > So is it possible to tell build to use nasm instead of masm?

    It isn't that hard to convert nasm to masm. How much code do you have?

    --
    Tim Roberts, xxxxx@probo.com
    Providenza & Boekelheide, Inc.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    Hi all,

    That is why I had it "quoted" as optimized. I am thinking the same as
    well but I have to do the customer's bidding as that is what I am paid
    for. I would really preferred this code to remain in the user mode dll.

    Not my will, but theirs is all that matters.

    Thanks for the makefile.inc suggestion, I'll look into that.

    Cheers
    Obble.



    On 25/11/2009 1:47 AM, Gary G. Little wrote:
    > What is the error that is causing the header file to barf when using MASM?
    > Extending the make/build is possible using the makefile.inc as Martin
    > suggested, but the question then is will Link be happy with the obj file?
    > The best bet is to "fix" the header file and stay within the realm of tools
    > that are known to work when building drivers.
    >
    > And really, what is so "special" about that "optimized" code? I remember
    > when it was common practice to write your code in PASCAL, FORTRAN, or even
    > C, generate ASM files and then butcher the living hell out of them to get
    > the final executable to fit in that 16K of RAM in which you had to run.
    > That's how the boys and girls at Apple got the first Macintosh to fit in
    > it's original 64k. "Optimized" code to day? Can you spell "bullshit"? I'll
    > bet it's the "pet code" of some arrogant developer who thinks his shit don't
    > stink and more than likely it is now done better in the OS or exsiting
    > support libs :)
    >
    > Gary G. Little
    > H (952) 223-1349
    > C (952) 454-4629
    > xxxxx@comcast.net
    >
    >
    >
    > -----Original Message-----
    > From: xxxxx@lists.osr.com
    > [mailto:xxxxx@lists.osr.com] On Behalf Of NCH Obble Smith
    > Sent: Monday, November 23, 2009 10:39 PM
    > To: Windows System Software Devs Interest List
    > Subject: [ntdev] nasm compiled asm files
    >
    > Hello everyone,
    >
    > Is it possible to set the sources file to compile an asm file with nasm
    > instead of masm?
    >
    >
    > Problem:
    > I have a customer that insists of having 32bit asm "optimized" code a
    > driver and it's compiler is nasm.
    > When I finally got the thing to compile for i386 base files, I am
    > getting errors about the .h file, but not when i compile with nasm.
    > So is it possible to tell build to use nasm instead of masm?
    >
    > Cheers
    > Obble.
    >
    > ---
    > NTDEV is sponsored by OSR
    >
    > For our schedule of WDF, WDM, debugging and other seminars visit:
    > http://www.osr.com/seminars
    >
    > To unsubscribe, visit the List Server section of OSR Online at
    > http://www.osronline.com/page.cfm?name=ListServer
    >
    >
    > __________ Information from ESET Smart Security, version of virus signature
    > database 4633 (20091124) __________
    >
    > The message was checked by ESET Smart Security.
    >
    > http://www.eset.com
    >
    >
    >
    > __________ Information from ESET Smart Security, version of virus signature
    > database 4633 (20091124) __________
    >
    > The message was checked by ESET Smart Security.
    >
    > http://www.eset.com
    >
    >
    >
    > ---
    > NTDEV is sponsored by OSR
    >
    > For our schedule of WDF, WDM, debugging and other seminars visit:
    > http://www.osr.com/seminars
    >
    > To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
    >
    >
  • Pavel_APavel_A Member Posts: 2,674
    "NCH Obble Smith" <xxxxx@NCHSoftware.com> wrote in message
    news:xxxxx@ntdev...
    > Hi all,
    >
    > That is why I had it "quoted" as optimized. I am thinking the same as
    > well but I have to do the customer's bidding as that is what I am paid
    > for. I would really preferred this code to remain in the user mode dll.
    >
    > Not my will, but theirs is all that matters.
    >
    > Thanks for the makefile.inc suggestion, I'll look into that.
    >
    > Cheers
    > Obble.

    IMHO your best bet is to coerce this code to compile with ML
    (fix the syntax, etc.)
    Linking object produced by nasm or anything else, with a kernel driver can
    bring more grief than you're paid for.

    Regards,
    --pa


    > On 25/11/2009 1:47 AM, Gary G. Little wrote:
    >> What is the error that is causing the header file to barf when using
    >> MASM?
    >> Extending the make/build is possible using the makefile.inc as Martin
    >> suggested, but the question then is will Link be happy with the obj file?
    >> The best bet is to "fix" the header file and stay within the realm of
    >> tools
    >> that are known to work when building drivers.
    >>
    >> And really, what is so "special" about that "optimized" code? I remember
    >> when it was common practice to write your code in PASCAL, FORTRAN, or
    >> even
    >> C, generate ASM files and then butcher the living hell out of them to get
    >> the final executable to fit in that 16K of RAM in which you had to run.
    >> That's how the boys and girls at Apple got the first Macintosh to fit in
    >> it's original 64k. "Optimized" code to day? Can you spell "bullshit"?
    >> I'll
    >> bet it's the "pet code" of some arrogant developer who thinks his shit
    >> don't
    >> stink and more than likely it is now done better in the OS or exsiting
    >> support libs :)
    >>
    >> Gary G. Little
    >> H (952) 223-1349
    >> C (952) 454-4629
    >> xxxxx@comcast.net
    >>
    >>
    >>
    >> -----Original Message-----
    >> From: xxxxx@lists.osr.com
    >> [mailto:xxxxx@lists.osr.com] On Behalf Of NCH Obble Smith
    >> Sent: Monday, November 23, 2009 10:39 PM
    >> To: Windows System Software Devs Interest List
    >> Subject: [ntdev] nasm compiled asm files
    >>
    >> Hello everyone,
    >>
    >> Is it possible to set the sources file to compile an asm file with nasm
    >> instead of masm?
    >>
    >>
    >> Problem:
    >> I have a customer that insists of having 32bit asm "optimized" code a
    >> driver and it's compiler is nasm.
    >> When I finally got the thing to compile for i386 base files, I am
    >> getting errors about the .h file, but not when i compile with nasm.
    >> So is it possible to tell build to use nasm instead of masm?
    >>
    >> Cheers
    >> Obble.
    >>
    >> ---
    >> NTDEV is sponsored by OSR
    >>
    >> For our schedule of WDF, WDM, debugging and other seminars visit:
    >> http://www.osr.com/seminars
    >>
    >> To unsubscribe, visit the List Server section of OSR Online at
    >> http://www.osronline.com/page.cfm?name=ListServer
    >>
    >>
    >> __________ Information from ESET Smart Security, version of virus
    >> signature
    >> database 4633 (20091124) __________
    >>
    >> The message was checked by ESET Smart Security.
    >>
    >> http://www.eset.com
    >>
    >>
    >>
    >> __________ Information from ESET Smart Security, version of virus
    >> signature
    >> database 4633 (20091124) __________
    >>
    >> The message was checked by ESET Smart Security.
    >>
    >> http://www.eset.com
    >>
    >>
    >>
    >> ---
    >> NTDEV is sponsored by OSR
    >>
    >> For our schedule of WDF, WDM, debugging and other seminars visit:
    >> http://www.osr.com/seminars
    >>
    >> To unsubscribe, visit the List Server section of OSR Online at
    >> http://www.osronline.com/page.cfm?name=ListServer
    >>
    >>
    >
  • anton_bassovanton_bassov Member Posts: 5,003
    >> 1. The ability the mix 16-bit and 32-bit code in the same source file
    > > 2. Ability to tell assembler to generate its output as a plain binary data without any OBJ headers..

    > Does it imply that none of the above can be done using masm?


    No - the only thing it implies is that NASM is an ideal assembler for someone with the above mentioned requirements.....


    Anton Bassov
  • Prokash_Sinha-1Prokash_Sinha-1 Member - All Emails Posts: 1,214
    > No - the only thing it implies is that NASM is an ideal assembler for someone with the above mentioned requirements.....
    >
    >
    Long back ( when we were moving from 16 bit to 32 bit ), I tried out a
    boot loader, I compiled( well assembled ) using masm, dumped into a
    floppy and booted ... so that was what I was thinking about plain
    binary... I don't know how easy nasm is in this respect though.

    I just searched the net, and I see foot print for claiming that it
    generates plain binary... would be interesting to know more, though bit
    OT for the OP I suppose. As always, if you some infos, mail me
    directly.... xxxxx@garlic.com. Interesting!

    -pro
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
Developing Minifilters 29 July 2019 OSR Seminar Space
Writing WDF Drivers 23 Sept 2019 OSR Seminar Space
Kernel Debugging 21 Oct 2019 OSR Seminar Space
Internals & Software Drivers 18 Nov 2019 Dulles, VA