Thread: NASM 'import' directive failing with "Expected an instruction" error?

  1. #1
    Registered User
    Join Date
    Aug 2008
    Location
    Belgrade, Serbia
    Posts
    163

    NASM 'import' directive failing with "Expected an instruction" error?

    Well, the title says it all. It's like "import" doesn't exists at all, but it's documented in the official manual. It worked before.. Has someone had this problem?
    Vanity of vanities, saith the Preacher, vanity of vanities; all is vanity.
    What profit hath a man of all his labour which he taketh under the sun?
    All the rivers run into the sea; yet the sea is not full; unto the place from whence the rivers come, thither they return again.
    For in much wisdom is much grief: and he that increaseth knowledge increaseth sorrow.

  2. #2
    Registered User
    Join Date
    Aug 2008
    Location
    Belgrade, Serbia
    Posts
    163
    NO ONE had this problem?

    For example:
    Code:
    [BITS 32]
    
    SEGMENT .idata
        extern _printf
        import printf msvcrt.dll _printf
        extern _ExitProcess
        import ExitProcess kernel32.dll _ExitProcess
    
    
    SEGMENT .data
        fmt db "%d\0"
    
    
    SEGMENT .text
        global main
    main:
        push word 100
        push [fmt]
        call printf
        add ebp, byte 8
    
        push 1
        call ExitProcess
    I get the mentioned error at the 'import' lines.
    Vanity of vanities, saith the Preacher, vanity of vanities; all is vanity.
    What profit hath a man of all his labour which he taketh under the sun?
    All the rivers run into the sea; yet the sea is not full; unto the place from whence the rivers come, thither they return again.
    For in much wisdom is much grief: and he that increaseth knowledge increaseth sorrow.

  3. #3
    Registered User
    Join Date
    Aug 2008
    Location
    Belgrade, Serbia
    Posts
    163
    Found the mistake.. 'import' only works with the 'obj' format. That format has problems with LD and some other linkers so I've used ALINK for producing an .exe. Works like a charm.
    Vanity of vanities, saith the Preacher, vanity of vanities; all is vanity.
    What profit hath a man of all his labour which he taketh under the sun?
    All the rivers run into the sea; yet the sea is not full; unto the place from whence the rivers come, thither they return again.
    For in much wisdom is much grief: and he that increaseth knowledge increaseth sorrow.

  4. #4
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    Yea, I have also ended up using ALINK to make win32 binaries -- using the 'extern' directive to specify externals. I suppose the import format you have is similar. I also found that gcc would link the binaries but I could not get win32 api linkage using the gcc. Also, I use these import libraries on the alink website Download page and they do not work in the gcc

    Did you get both the CRT printf and the Win32 functions working? I can't get them to both work same time for these issues

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 10:17 AM
  2. Getting other processes class names
    By Hawkin in forum Windows Programming
    Replies: 3
    Last Post: 03-20-2008, 04:02 PM
  3. Crazy errors caused by class, never seen before..
    By Shamino in forum C++ Programming
    Replies: 2
    Last Post: 06-10-2007, 11:54 AM
  4. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  5. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM