News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

EasyCode with NASM/YASM

Started by David BS, July 11, 2014, 01:46:56 PM

Previous topic - Next topic

David BS

Hi folks,

I had utilized EasyCode with MASM32 successfully - the IDE is really great! Congratulations Ramon!

I would like to know if there is some way to put YASM/NASM within EasyCode. I would like to compile some INTEL source codes (built to YASM/NASM) and adapt them to DLL (they're almost all built to console mode).

If it's not possible, could you recommend any other IDE to work with YASM/NASM, or, any tool to convert source code from NASM to MASM?

Thanks in advance!


jj2007

Quote from: David BS on July 11, 2014, 01:46:56 PMany tool to convert source code from NASM to MASM?

The NASM example here is hilariously complicated, but it looks feasible. If you can post a source with, say, 500 lines, I could give it a try with RosAsm2Masm.

sinsi

Quote from: jj2007 on July 11, 2014, 04:20:07 PM
The NASM example here is hilariously complicated, but it looks feasible.

I weep for the future of ASM

        sub     esp, 4          ; Allocate space on the stack for one 4 byte parameter

        lea     eax, [fmtStr]
        mov     [esp], eax      ; Arg1: pointer to format string

Pretty sure that nasm has a push instruction...

jj2007

Quote from: sinsi on July 11, 2014, 04:35:26 PM
I weep for the future of ASM

Just in case the noobs who are reading this don't understand why we are whining here:

include \masm32\include\masm32rt.inc

.data
        fmtStr  db 'hello, world',0Ah,0

.code
main:
  if 0            ; MASM syntax, "pure" assembler, 14 bytes
      push offset fmtStr
      call crt_printf
      add esp, 4

  elseif 0            ; MASM syntax using invoke, 14 bytes
      invoke crt_printf, chr$("hello, world", 10)

  elseif 1            ; MASM syntax using a macro, 14 bytes
      printf("hello, world\n")

  else            ; NASM example, 21 bytes
        sub     esp, 4          ; Allocate space on the stack for one 4 byte parameter
        lea     eax, [fmtStr]
        mov     [esp], eax      ; Arg1: pointer to format string
        call    crt_printf         ; Call printf(3):
        add     esp, 4          ; Pop stack once

  endif
        ret
end main


BTW the 50% increase in code size is not the fault of NASM but rather of the Wiki author :(

Gunther


        sub        esp, 4


should be replaced by

        sub        esp, byte 4

It's shorter and faster. Works with NASM as well as with YASM.

Gunther
You have to know the facts before you can distort them.

jj2007

With MASM syntax for the NASM example, sub esp, 4 uses already the short 3-byte encoding.

Gunther

Jochen,

my point was the original code from your link.

Gunther
You have to know the facts before you can distort them.

dedndave

i've seen things like that in compiled code
i suppose, under the right circumstances, it might be justified
for example, you have several larger arguments to pass

so - the SUB ESP,x construct is a "cookie-cutter" template for more complex calls
they calculate the total space required for parameters - then fill it in
one that i saw was for COM - there were a few VARIANT structures passed

the problem i see there is crashability - lol
if you are near the stack limit - SUB ESP,x will get you a silent termination   :redface:

rsala

Hi David BS,

Thanks for your kind words about Easy Code!

Although the IDE is prepared for working with Masm and/or GoAsm, I guess you could use Nasm/Yasm if you disabled all syntax correction and set the compiler path to the folder where Nasm/Yasm is.

Regards,

Ramon
EC coder

David BS

Quote from: rsala on July 12, 2014, 02:36:32 AM
Although the IDE is prepared for working with Masm and/or GoAsm, I guess you could use Nasm/Yasm if you disabled all syntax correction and set the compiler path to the folder where Nasm/Yasm is.

Hmmm.... I understood everything you wrote guys. Thanks.

But my doubt was really about what Ramon answered: if I could put EasyCode to compile code using Yasm AND having syntax correction and some built-in macros. Of course I would like to get that usefull help...

Thank you Ramon. And congrats for the very nice job.

I really don't know what I'm going to do now: if I'll try to translate INTEL's YASM code to MASM (and have EasyCode working and making easier my life) or try anything else. 

One question: is not clear to me in YASM syntax if I have to define the DLLMain routine/header to build a DLL file - as I do in MASM syntax. It's not clear if it is performed just by the compiler and its parameters or if in addition I must define it is a DLL within the code.  Anyone can help me in that question?

Thanks again to all.
Regards.

jj2007

Quote from: David BS on July 12, 2014, 01:08:17 PMif I'll try to translate INTEL's YASM code to MASM (and have EasyCode working and making easier my life) or try anything else.
That is really your decision. Writing a converter is easy, but are you more hooked on YASM, or are you equally comfortable with MASM syntax?

Quote from: jj2007 on July 11, 2014, 04:20:07 PMIf you can post a source with, say, 500 lines, I could give it a try with RosAsm2Masm.

Gunther

Hi Jochen,

Quote from: jj2007 on July 12, 2014, 05:41:41 PM
Quote from: David BS on July 12, 2014, 01:08:17 PMif I'll try to translate INTEL's YASM code to MASM (and have EasyCode working and making easier my life) or try anything else.
That is really your decision. Writing a converter is easy, but are you more hooked on YASM, or are you equally comfortable with MASM syntax?

YASM and MASM syntax are not so far apart. That's a fact. AT&T syntax is another world. There's no doubt about that.

Gunther
You have to know the facts before you can distort them.

rsala

Hi,

I am afraid I was to optimistic in my first answer. Easy Code, both Masm and GoAsm, internally write some compiler options, so it might not work with Nasm/Yasm. I think the best you can do (not just for using Easy Code, but for making things simple) is trying to translate the code to Masm or GoAsm syntax.

Regards,

Ramon
EC coder

David BS

 :dazzled:

Thanks you all for the answers.

I feel confortable with MASM and, since I'm a Visual Studio programmer, I suppose I can utilize the internal source code debugger to step-by-step my ASM sources during the debug session (for instance, to see if the Visual Basic call and parameters are being correctly sent/received and so forth). I'm not sure if with YASM I have the same environment.

EasyCode really makes the job easier, since it has a lot of functions/macros to help us. So, the union between MASM and EasyCode is preferable to me.

BUT, unfortunetly, all INTEL source codes are made to be YASM/NASM compiled and I believe the most of them are to be linked with C or C++ (argh!  :icon13:). I hate C/C++ since the language is in my view the worst between two worlds: the High Level and Low Level languages.  I can make a whole system utilizing Visual Basic in just ONE DAY, what sould be impossible utilizing C++ or C.  The sources I send now here are being focused into .LIB files, which Visual Basic does not see!

For instance, one of my doubts is about how make a DLL file in YASM!  I cannot see any source example! May I have to define the DLLEntry point there or YASM/NASM will create it automatically?  And the EXPORT directive, must I define in within the code?  Should I have also to create .DEF files?

In MASM I know how to create them and make the MASM/LINK undertstand them to create a DLL file, but with these samples I'm not getting succes with YASM. Or it creates an EXE file or a LIB file - and none of them are my target.

Can anyone light my way?
Thank you very much.
Regards!

Gunther

Hi David,

I hope that link will help you.

Gunther
You have to know the facts before you can distort them.