flat assembler
Message board for the users of flat assembler.

Index > DOS > Can any1 please explain how to combine Turbo C with Fasm?

Author
Thread Post new topic Reply to topic
wedared



Joined: 25 Dec 2007
Posts: 2
Location: Hong Kong
wedared 15 Mar 2008, 15:06
sorry, i just kinda like turbo c so i was wondering if it was possible to create apps with turbo c and fasm. please i need some info and help regarding it as i am interested in dos programming but just using assembler to code apps is overwhelming as i am just getting to understand assembly instructions.
Post 15 Mar 2008, 15:06
View user's profile Send private message Yahoo Messenger Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4353
Location: Now
edfed 15 Mar 2008, 15:41
you can code windows applications with only fasm. fasmw.exe is an example
Post 15 Mar 2008, 15:41
View user's profile Send private message Visit poster's website Reply with quote
wedared



Joined: 25 Dec 2007
Posts: 2
Location: Hong Kong
wedared 15 Mar 2008, 16:20
i know, but i like dos for what it is, simple. so i was thinking if there was any one who could give me some advise as to how to link turbo c and fasm source in dos.
Post 15 Mar 2008, 16:20
View user's profile Send private message Yahoo Messenger Reply with quote
dap



Joined: 01 Dec 2007
Posts: 61
Location: Belgium
dap 15 Mar 2008, 17:27
Just follow the C convention and it should work : http://blogs.msdn.com/oldnewthing/archive/2004/01/02/47184.aspx
Post 15 Mar 2008, 17:27
View user's profile Send private message Visit poster's website Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1905
DOS386 16 Mar 2008, 00:22
.

edfed wrote:

> you can code windows applications with only fasm. fasmw.exe is an example

Maybe true, but absolutely OFF-topic here, read subforum topic please Sad

> i know, but i like dos for what it is, simple. so i was thinking if there
> was any one who could give me some advise as to how to link turbo c
> and fasm source in dos.

The problem is that FASM can't brew 16-bit OMF objects and "Turbo" C can't output assembly Sad

Several options:

1. 100% assembly
2. Use NASM or LZASM, both can (reportedly) 16-bit OMF
3. For better performance, use DPMI32 instead of real mode. This way some more possibilities open:
- - Link via COFF, DGJPP compiler for C
- - Output assembly from compiler and include into FASM source, DGJPP "MASM INTEL" (does it really work ???) , or CC386 compiler (has "minimal" FASM support) Smile
Post 16 Mar 2008, 00:22
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo 17 Mar 2008, 18:21
"tcc -S myfile.c" should produce assembly, and it should work with ArrowASM (although you might have to change ".186" to ".286p" or whatever). Or use NASM or LZASM (but need manual conversion in that case). But Turbo C (and TC++) for DOS are old, old, old! Granted, they're still fast, small, light, and useful, but they don't optimize well enough for modern processors (anything past 186, apparently!).

OpenWatcom is better code generation, and it supports 16-bit. It, of course, uses OBJ/OMF also (which FASM doesn't support), but at least it has its own assembler (WASM) and good docs ("whelp cguide") among tons of other goodies. (Of course, it outputs directly to .OBJ, so you have to manually use WDIS else use "owcc -S myfile.c" GCC compiler driver clone instead of "wcl"). Or, try Agner's OBJCONV (but I haven't tested it, so it may not support 16-bit).

In short, Turbo C + ArrowASM ("tcc -G -O -a -Easm.exe myfile.asm") works.

EDIT: Corrected cmdline of TC.


Last edited by rugxulo on 03 May 2008, 06:49; edited 1 time in total
Post 17 Mar 2008, 18:21
View user's profile Send private message Visit poster's website Reply with quote
Kenneth Zheng



Joined: 30 Apr 2008
Posts: 14
Location: Shanghai, China
Kenneth Zheng 02 May 2008, 15:03
We can download open watcom source code and binary files from this web link: http://www.openwatcom.org/index.php/Main_Page.

Thanks,

Kenneth Zheng
Post 02 May 2008, 15:03
View user's profile Send private message MSN Messenger Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1905
DOS386 02 May 2008, 18:30
> We can download open watcom source code and binary files from this web link: http://www.openwatcom.org/...

YES, but not really new, and the packages are not very great / DOS-friendly Sad

Also we can download JWASM, supporting 16-bit OMF and usable with 16-bit C ... but supports MA$M syntax only.

_________________
Bug Nr.: 12345

Title: Hello World program compiles to 100 KB !!!

Status: Closed: NOT a Bug
Post 02 May 2008, 18:30
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo 03 May 2008, 06:48
For the record, Turbo C isn't anywhere near as good at optimizing as OpenWatcom. Plus, it ain't FOSS. Wink But anyways, no you don't have to download the 65 MB .EXE installer / .ZIP sfx behemoth anymore, thanks to Arkady B! You can get only what parts you need in separate smaller .ZIPs (a la OW 1.3).

http://www.openwatcom.org/index.php/Alternative_Open_Watcom_distribution
Post 03 May 2008, 06:48
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo 03 May 2008, 06:56
Okay, just to prove it works, here's the output of a simple "Hello, world!" application (from free TC 2.01).

Build it via "tcc.exe -G -O -mt -lt -Easm.exe hello.asm".

Code:
   ifndef  ??version
?debug     macro
       endm
        endif
       ?debug  S "hello.c"
_TEXT  segment byte public 'CODE'
DGROUP  group   _DATA,_BSS
  assume  cs:_TEXT,ds:DGROUP,ss:DGROUP
_TEXT       ends
_DATA   segment word public 'DATA'
d@      label   byte
d@w     label   word
_DATA   ends
_BSS    segment word public 'BSS'
b@       label   byte
b@w     label   word
        ?debug  C E9A70EA3380768656C6C6F2E63
        ?debug  C E92010AB121E433A5C41524D534C5552505C54435C494E434C5544+
   ?debug  C 455C737464696F2E68
        ?debug  C E92010AB121F433A5C41524D534C5552505C54435C494E434C5544+
   ?debug  C 455C7374646172672E68
_BSS  ends
_DATA   segment word public 'DATA'
_DATA   ends
_TEXT   segment byte public 'CODE'
;       ?debug  L 3
_main    proc    near
        push    bp
  mov     bp,sp
;      ?debug  L 5
 mov     ax,offset DGROUP:s@
     push    ax
  call    near ptr _printf
    pop     cx
; ?debug  L 7
 xor     ax,ax
;      ?debug  L 8
 pop     bp
  ret     
_main       endp
_TEXT   ends
        ?debug  C E9
_DATA   segment word public 'DATA'
s@      label   byte
        db      10
  db      72
  db      101
 db      108
 db      108
 db      111
 db      44
  db      32
  db      70
  db      65
  db      83
  db      77
  db      101
 db      114
 db      115
 db      33
  db      10
  db      0
_DATA      ends
_TEXT   segment byte public 'CODE'
        extrn   _printf:near
_TEXT       ends
        public  _main
       end
    
Post 03 May 2008, 06:56
View user's profile Send private message Visit poster's website 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.