2

I have wrote several ASM programs and compiled it using VS 2008/2010/2013 using the Visual Studio Command Prompt as follows

ml program.asm /link msvcrt.lib

The code

.586
.MODEL FLAT
.STACK 100h

EXTERN  _printf     :PROC

.DATA
arg     BYTE    "hello world", 0dh, 0ah, 0

.CODE

_main   PROC

    push    OFFSET arg
    call    _printf
    add     esp, 4

    xor     eax, eax
    ret

_main   ENDP

END

Up to 2013, I was able to compile it, but for VS 2015, it says that _printf is not found. Doing a dumpbin /exports on msvcrt.dll, it says that printf is an export (but _printf is not found). I tried changing _printf to printf but still no luck.

Does anyone know how to resolve this?

Bran
  • 617
  • 8
  • 21
  • So maybe it no longer requires the leading underscore, have you tried that? (Although microsoft is generally very keen on compatibility.) – Jester Feb 23 '16 at 02:37
  • Hey Jester, I tried both _printf and printf, no luck unfortunately. It seems that only _printf is having this issue. Other cstdlib functions are there and working. – Bran Feb 23 '16 at 02:39
  • 2
    Since you are observing this in VS 2015 and not 2013 - any possibility this is related? http://stackoverflow.com/questions/33721059/call-c-standard-library-function-from-asm-in-visual-studio . I gave a couple of answers that may help. – Michael Petch Feb 23 '16 at 02:42
  • Thanks Michael, ml test.asm /link msvcrt.lib legacy_stdio_definitions worked like a charm! Can you post it as an answer so I can accept it? – Bran Feb 23 '16 at 02:55
  • @Bran, what you can do (and you likely already did) is upvote the other answer (under the other question) and I'll mark this question as "close as duplicate". I'm glad you got it going. – Michael Petch Feb 23 '16 at 03:00
  • 1
    @MichaelPetch Thanks, I upvoted the other answer and closed this one. – Bran Feb 23 '16 at 04:44

0 Answers0