Using Fasm with Pelles C

Started by Vortex, February 06, 2005, 05:12:11 PM

Previous topic - Next topic

Vortex

Hi friends,

Here is a tiny example demonstrating how to link Fasm object files with Pelles C

Main file Fasmsamp.c

#define WIN32_LEAN_AND_MEAN
#include <stdio.h>
#include <windows.h>

extern void WINAPI StdOut(char *message);

int main()
{
StdOut("Hello world!");
return 0;
}


StrLen.asm:

format MS COFF ; Original StrLen algo available from
; Hutch's masm32 package

public StrLen as "_StrLen@4"

include '%fasminc%\win32a.inc'

section '.text' code readable executable
proc StrLen,item

    push    ebx
    mov     eax,[item]             
    lea     edx,[eax+3]           
  @@:     
    mov     ebx,[eax]             
    add     eax,4                 
    lea     ecx,[ebx-01010101h] 
    not     ebx                   
    and     ecx,ebx               
    and     ecx,80808080h   
    jz      @B                   
    test    ecx,00008080h         
    jnz     @F
    shr     ecx,16               
    add     eax,2
  @@:
    shl     cl,1                 
    sbb     eax,edx           
    pop     ebx
    return

endp


StdOut.asm

format MS COFF; Original StdOut algo available from
; Hutch's masm32 package

extrn '__imp__GetStdHandle@4' as GetStdHandle:DWORD
extrn '__imp__WriteFile@20' as WriteFile:DWORD
extrn '_StrLen@4' as StrLen:DWORD

public StdOut as "_StdOut@4"

Include '%fasminc%\win32a.inc'

section '.text' code readable executable

proc StdOut,lpszText

__hOutPut dd ?
bWritten dd ?
sl dd ?
enter
        invoke GetStdHandle,STD_OUTPUT_HANDLE
        mov [__hOutPut], eax
        stdcall StrLen,[lpszText]
        mov [sl],eax
        lea eax,[bWritten]
        invoke WriteFile,[__hOutPut],[lpszText],[sl],eax,NULL
        mov eax,[bWritten]
        return
endp

[attachment deleted by admin]

Vortex

#1
Example revised and rebuilt with Fasm 1.64 and PellesC 4.00.43

[attachment deleted by admin]