Hello, I've been experimenting with calling C functions from ASM, but every time I run the following program I get a windows "cannot be read" error. Could someone please point out to me my mistake. The code below is very similar to the few example that I have been able to find so far, so I am surprised that it doesn't work. Thx.
;ml /Cp /c /coff printf.asm; link32 printf.obj
.model flat,stdcall
.stack 4096
option casemap:none
includelib \masm615\kernel32.lib
includelib \masm615\libc.lib ;copied from VC6.0

format db "This is my %dst printf from assembly!",13,0

extrn printf:proc
ExitProcess PROTO :DWORD


push dword ptr 1
push offset format
call printf
add esp,8

push 0
call ExitProcess

end main
Posted on 2002-11-18 00:11:54 by elotemuygrande
printf uses the "stream" io routines of the c runtime lib. This may need runtime initialization. I suggest to use sprintf instead and do the output in an extra call (to writeconsole). Thats like using wsprintf :)
Posted on 2002-11-18 02:00:07 by japheth
Amigo elotemuygrande,

For an example of using the printf() function in Win32asm, you can check the thread:



Posted on 2002-11-18 02:21:58 by Vortex