How do you use printf from Assembly?-Collection of common programming errors

I think this article explains it better than I can.

Roughly put, the assembler cannot find the symbol (function) in go.asm. You have to tell it its an external symbol.

The linked article approaches building a mixed-code app from the point of view of using assembly as the main language including running the main routine. If you’re using a C based main routine, much of what is done is unnecessary, you should just need:

Assemble the assembly module with /Mx to preserve the case of nonlocal names. If using MASM version 6.0 or later, use /Cx to preserve the case of nonlocal names.


Include the statement .MODEL , c in the assembly module to ensure that C naming and calling conventions are used and that the modules use the same default segments. The will be small, medium, compact, or large.

and EXTERN directives for each function you wish to call in the format: EXTERN printf:proc.

Originally posted 2013-11-09 23:05:08.