Search code examples
assemblyx86printfmasmmasm32

Invoking print of c in MASM


I'm trying to print a string using the C print method and Its doesnt print anything. I can print numbers but when I try with string it doesn't work

.386
.model flat, stdcall
.stack 200h
option casemap :none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
include \masm32\include\masm32rt.inc
dll_dllcrt0 PROTO C
printf PROTO C :VARARG

.DATA
_foo DB "String Contents",0

.CODE

START:


invoke printf, cfm$("%s"),_foo

END START 

Solution

  • Just like Jester said, using OFFSET _foo instead of _foo work. This solved the problem.

    ...
    invoke printf, cfm$("%s"),OFFSET _foo
    ...