CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2010
    Posts
    907

    Need some help on Watcom assembling....

    Code:
    E103: Operand is expected
    E065: Invalid instruction operands
    Code:
    lea	eax, [esp+30h+var_28]
    Tried to reassemble a decompiled program using wasm.exe
    Compiler: Watcom C++ 11.0
    Target: DOS4G Extended Environment

    Assembled with
    wasm -5p program.asm
    Unsuccessful in finding reference manuals....
    Last edited by lucky6969b; September 17th, 2014 at 05:33 AM.

  2. #2
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: Need some help on Watcom assembling....

    You cannot typically take decompiled output and use that as source for an assembler.

    An assembler will typically need additional information the disassembler doesn't provide
    and a disassembler will often have an output that is oriented towards higher readability but not necessarily being compatible for reassembly.

    That's what's happening with this lea instruction. It's likely using a var_28 pseudovariable name but there's no actual variable nor symbol defined as such.
    considering the use of ESP, it's likely the disassembler differentiating between various different presumed parameters to the function.

    Solution: provide the proper value for var_28 or make sure you've a define for it.

  3. #3
    Join Date
    Dec 2010
    Posts
    907

    Re: Need some help on Watcom assembling....

    Code:
    main_		proc near		; CODE XREF: __CMain+40p
    
    var_28		= byte ptr -28h
    var_20		= byte ptr -20h
    var_18		= dword	ptr -18h
    So I should change that line from
    Code:
    lea	eax, [esp+30h+var_28]
    
    to
    
    lea	eax, [esp+30h-28h] ?

    Update
    Also having the same problem here
    Code:
    dword_74520	dd ?
    
    inc	dword_74520
    Any ideas how to resolve this? Seems to be having trouble with uninitialized data.
    I am using IDA Pro. I have solved the previous problems by specifying no stack variables created.
    Also esp+... are converted to constants. But I don't know how to resolve this one?
    Thanks
    Jack
    Last edited by lucky6969b; September 17th, 2014 at 08:46 AM.

  4. #4
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: Need some help on Watcom assembling....

    The inc command should assemble. If not, try adding square brackets around the variable name (some assemblers are picky about that).

    but you will need to have code somewhere that initializes it to something of course.

    also WASM has a few quirks about syntax issues. If you use IDA Pro, then a MASM 6.1 syntax compatible assembler should be easier.

  5. #5
    Join Date
    Dec 2010
    Posts
    907

    Re: Need some help on Watcom assembling....

    Hello,
    Just wondering how to assemble dos extended program with masm 6.1. I just know how to assemble in real mode.
    Thanks
    Jack

  6. #6
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: Need some help on Watcom assembling....

    Wasm has built in support for the DOS4GW (later called CauseWay) DOS extender.
    This essently just means it'll link in the setup/interface/cleanup for the extender as well. IIRC, this lib isn't just available, rather, the linker hard-links this in.

    MASM can be used for DOS4GW as well, but it doesn't do all of that by itself, you'll need to provide all that setup/interface/cleanup yourself. If you have the dev version of DOS4GW/Causeway, the standard lib to do this (with source) will be available. if you only have the WatCom distributable, you're out of luck on that area and you'll need to do it yourself "the hard way". good luck finding all the necessary documentation to do so

    Note that in the disassembled code, you'll probably have all that DOS extender interface code also as part of the disassembly output, so to get properly workable/linkable code for Wasm/Wlink, you'll need to pull all of that out.

    It's possible IDA pro does this for you (I doubt it), but I honestly don't know, I never used IDA Pro on (extended) DOS programs.

  7. #7
    Join Date
    Dec 2010
    Posts
    907

    Re: Need some help on Watcom assembling....

    It's hard to find the old software though, it's a good start anyways.
    Thanks a lot.
    Jack

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured