flat assembler
Message board for the users of flat assembler.
Index
> High Level Languages > [SOLVED] How to produce .OBJ file for Pelles C |
Author |
|
wht36 01 Jul 2011, 08:29
Inspired by Vortex tiny C startup library I am trying to do something similar but using FASM. However, when I tried to convert his source to FASM format, I seemed to hit a dead end. Here is Vortex's code
Code: .386 .model flat,stdcall option casemap:none ExitProcess PROTO :DWORD GetCommandLineA PROTO GetCommandLine equ <GetCommandLineA> main PROTO C :DWORD,:DWORD GPTR = 40h .data? hMem db 512 dup(?) .code mainCRTStartup: push esi push edi push ebx mov esi,OFFSET hMem lea edi,[esi+256] invoke GetCommandLine lea edx,[eax-1] xor eax,eax mov ch,32 mov bl,9 scan: inc edx mov cl,byte PTR [edx] or cl,cl jz finish cmp cl,32 je scan cmp cl,9 je scan inc eax mov dword PTR [esi],edi add esi,4 restart: mov cl,byte PTR [edx] or cl,cl jz finish cmp cl,ch je end_of_line cmp cl,bl je end_of_line cmp cl,34 jne @f xor ch,32 xor bl,9 jmp next_char @@: mov byte PTR [edi],cl inc edi next_char: inc edx jmp restart end_of_line: mov byte PTR [edi],0 inc edi jmp scan finish: pop ebx pop edi pop esi invoke main,eax,ADDR hMem invoke ExitProcess,eax END mainCRTStartup *Edit* Here's my code and it's working! Code: format MS COFF public mainCRTStartup as '__mainCRTStartup' extrn '__imp__GetCommandLineA@0' as GetCommandLine:dword extrn '__imp__ExitProcess@4' as ExitProcess:dword extrn '_main' as main:dword section '.text' code readable executable mainCRTStartup: push esi push edi push ebx mov esi,hMem lea edi,[esi+256] call [GetCommandLine] lea edx,[eax-1] xor eax,eax mov ch,32 mov bl,9 scan: inc edx mov cl,[edx] or cl,cl jz finish cmp cl,32 je scan cmp cl,9 je scan inc eax mov [esi],edi add esi,4 restart: mov cl,[edx] or cl,cl jz finish cmp cl,ch je end_of_line cmp cl,bl je end_of_line cmp cl,34 jne @f xor ch,32 xor bl,9 jmp next_char @@: mov [edi],cl inc edi next_char: inc edx jmp restart end_of_line: mov byte [edi],0 inc edi jmp scan finish: pop ebx pop edi pop esi push hMem push eax call main push eax call [ExitProcess] section '.bss' readable writeable hMem db 512 dup(?) Notes: Pelles C will merge .text & .bss sections. It doesn't seem to recognize section data directive (so take the "data" word out). It seems to want 2 underscores for the public function, and main is called without [].
|
|||||||||||
01 Jul 2011, 08:29 |
|
typedef 01 Jul 2011, 18:01
Version: 6.00.4 |
|||
01 Jul 2011, 18:01 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.