No announcement yet.

MASM to PB assembler conversion tool.

  • Filter
  • Time
  • Show
Clear All
new posts

  • MASM to PB assembler conversion tool.

    Hi Folks,

    I am just in the process of digesting the two current PB compilers and updating some of the tools I use with PowerBASIC. As the PB forum now has attachment capacity I have attached a conversion tool aimed at the massive amount of MASM 32 bit code available to do at least some of the conversion to a PowerBASIC function.

    It is updated from an earlier version and has the full range of mnemonics published in the current PB help files and it supports the new PB #ALIGN directive as a translation from MASM.

    There are limitations with a tool of this type. If the MASM procedure is built with a normal stack frame and is written wholly in mnemonics the quality is reasonably good but if the MASM procedure is written without a stack frame the results will take some careful editing to get it workable as the address of arguments on the stack are [ESP] based and the mnemonic may change depending on external function calls or stack address changes with PUSH / POP etc ... It is normally better to convert the MASM proc back to a stack frame first so you don't have to track ESP through the proc.

    It is normal in a MASM proc to do your own stack preservations and the tool will convert these with no modifications but PowerBASIC already preserves EBX ESI & EDI so you can take out MASM code that does this to avoid extra overhead.


    hutch at movsd dot com
    Attached Files
    hutch at movsd dot com
    The MASM Forum - SLL Modules and PB Libraries

  • #2
    Welcome back Hutch.
    Glad to see you posting again.

    You're never too old to learn something stupid.


    • #3
      Thanks, Hutch !

      We know you do some amazing things in assembler... Look forward to even more!



      • #4
        There was something I did not put in this tool yet as I am still digesting the capacity addons for the two new compilers, a duplicate guard so that you don't accidentally include two copies of the same function. It occurs in this form.

        ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
            #IF NOT %DEF(%f_myproc)
            %f_myproc = 1
        FUNCTION myproc() as LONG
          ' your code goes here
            FUNCTION = YourReturnValue
        ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
        In conjunction with the #include ONCE option for add in files and the removal of the need to prototype functions local to the source code, this puts reusable code in close to library form in sight where you can just include a file you need and get the dependencies it requires without duplicate problems.
        hutch at movsd dot com
        The MASM Forum - SLL Modules and PB Libraries


        • #5
          Dave and Bob,

          Pleasure to be back. I am just setting up around the new compilers and still have a fair bit of work to do.
          hutch at movsd dot com
          The MASM Forum - SLL Modules and PB Libraries