flat assembler
Message board for the users of flat assembler.

Index > DOS > Using coff obj format and C library on DOS

Thread Post new topic Reply to topic

Joined: 04 Jul 2003
Posts: 125
Location: China
Dear All:
We known that fasm only create a pure dos exectutive format, it can't create a OMF obj format, so it can't use another libarys, for example: BC3.1 library, MSVC1.5 library, etc.

Now, I find a method can do it. We known that fasm can create coff obj format, and we know that djgpp can use coff obj format. so we can combine these comlliers togther. We need download DJGPP complier 2.03 from internet. It's free and based on GNU GCC. Please see below demo program:
;FileName       :COFFDEMO.ASM
;Function       :fasm example of using the C library in DGPPP V2.03
;Complier       :fasm coffdemo.asm
;                gcc coffdemo.obj -o coffdemo.exe
;                strip libcdemo.exe
;Author         :Kenneth Zheng (Zheng Hongwen) 
;Date           :August 08th,2005 20:22:00 AM 
;Nationality    :China
;Notice         :None
FORMAT          COFF
include         'private\dos.inc'
section '.text' code
 public main as '_main'
 extrn  '_printf' as printf:dword
 extrn  '_getpid' as getpid:dword
proc    main
        ccall   printf, hello
        call    getpid
        ccall   printf, msg,eax
section '.data' data
        hello   db      09h,"FASM example of using the C library in DGPPP V2.03",0Ah
                db      09h,"   Author:Kenneth Zheng Date:August 08th, 2005",0Ah,0
        msg     db      09h,"Current process ID is %d.",0Ah,0

The build batch file is below:
@echo off
set include=c:\fasm\include
\fasm\fasm.exe coffdemo.asm
gcc coffdemo.obj -v -s -save-temps -Wall -O -o coffdemo.exe
rem strip -v coffdemo.exe
exe2coff coffdemo.exe
copy /b e:\djgpp\bin\cwsdstub.exe+coffdemo coffdemo.exe

The finally exeutive can use 4G memory on DOS platform.and it can use all of APIs on DJGPP library.
Of course, I known that alink.exe can do it, but I find that alink present a bug, it can't analyze more and more APIs on a library. So if you use alink to link coff object file and C library, it will hung up.

Using these method, we can exceed fasm's limit, and we can use fasm coff obj and other coff library together.

And other, I found that djgpp linker can't use "MS COFF" object format, it only use standard "COFF" object format. So if you used this method, please remember this rule. The linker don't report any errors if you use "MS COFF" format, but the program will hung up.

Kenneth Zheng
August 24th,2005

Description: fasm example of using the C library in DGPPP V2.03
Filename: coffdemo.zip
Filesize: 66.74 KB
Downloaded: 224 Time(s)

Description: Some of extended macros, please put it on "fasmincludeprivate".
Filename: private.zip
Filesize: 19.29 KB
Downloaded: 198 Time(s)

Post 24 Aug 2005, 01:07
View user's profile Send private message MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum

Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.