Message board for the users of flat assembler.
> DOS > Using coff obj format and C library on DOS
Kevin_Zheng 24 Aug 2005, 01:07
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 ret endp ;============================================================================ 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.
|24 Aug 2005, 01:07||
< Last Thread | Next Thread >
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.