Using Pelle's C run-time library with Masm

Started by Vortex, September 11, 2005, 12:58:54 PM

Previous topic - Next topic

Vortex

Hi friends,

Here a simple Masm example using functions from Pelle's C run-time static library crt.lib :

.386
.model flat,stdcall
option casemap:none

include     \masm32\include\windows.inc
include     \masm32\include\kernel32.inc
include     \masm32\include\user32.inc
include     \masm32\include\masm32.inc

includelib  \masm32\lib\kernel32.lib
includelib  \masm32\lib\user32.lib
includelib  \masm32\lib\masm32.lib
includelib  \pellesc\lib\crt.lib ; Pelle's CRT static library

strcat PROTO C :DWORD,:DWORD
strstr PROTO C :DWORD,:DWORD
strchr PROTO C :DWORD,:DWORD

.data
dest    db 'strcat example : ',0
       db 20 dup(0)
source  db 'Hello my friend',13,10,0
string2 db 'friend',0
crlf    db 13,10,0

.data?
buffer  db 20 dup(?)

.code

start:
invoke strcat,ADDR dest,ADDR source
invoke StdOut,ADDR dest
invoke strstr,ADDR dest,ADDR string2
call   print
invoke strchr,ADDR dest,114 ; look for 'r'
call   print
invoke ExitProcess,0

print   PROC
invoke dw2hex,eax,ADDR buffer
invoke StdOut,ADDR buffer
invoke StdOut,ADDR crlf
ret
print   ENDP

END start
Code it... That's all...

tomlau

Great done, vortex!
I know you on the fasm forum, hoho.

Vortex

tomlau,

Thanks for your kind words. Yes, I am a member of Fasm forum.
Code it... That's all...

Grincheux