I would like to have some more information about EXE and COM executables
files under DOS. I read that for all ths executable format, my
compiler/linker when genearating LE files let room a the begining of the
binary code for the PSP. PSP is mostly a structure pad by DOS (some kind of
parameters use by executable (?) and by DOS itself). But does my binary code
refer to it when I work with my assembler ? In fact does in the process of
assembling/linking, assembler/linker modify my code to refer to some
parameters to finaly giving me my binary executable.
Refering to all those questions, what make EXE2BIN ? And what is the
difference between a COM and a SYS file. In the coding sheme I know that for
making a SYS file, I must specify that my code is based on ORG 0 at the
oposite of a COM file base on ORG 100h. Finally a SYS file is mostly a COM
file by the fact that they use only one SEGMENT for Code and Data. Does to
obtain a SYS file you just have to scratch the 100h first binary bytes of
the final COM file ? Or does some references built by the compiler/linker
inside a COM files won't allow me to use this technic ? Why EXE2BIN only
work with an EXE file in input and not a COM file ? Does EXE2BIN will allow
me to have a BIN file (so a SYS file) with an EXE based on Medium memory
Model or Large ( with EXE with more than 1 total segment ).
Finally does with MASM or TASM there is a way to gain a BIN/SYS file
directly without having to use EXE2BIN. Does an another Assembler (with
Intel syntax) have this ability ?
Sure a lot of questions, but even if I don't obtain for all a respons, any
shorts respons will be appreciate
THX
Thierry DELHAISE
Hello Thierry,
> I would like to have some more information about EXE and COM
> executables files under DOS. I read that for all ths executable
> format, my compiler/linker when genearating LE files let room
> a the begining of the binary code for the PSP. PSP is mostly
> a structure pad by DOS (some kind of parameters use by
> executable (?) and by DOS itself).
Yep. The old INT 21h vector is stored into it. The segment where your
Environment-variables are is at (IIRC) 002Ch. A INT 20h (terminate) is
placed at 0000h. And ofcourse the Command-line string at 0080h.
> But does my binary code refer to it when I work with my assembler ?
Yes.
> In fact does in the process of assembling/linking, assembler/linker
> modify my code to refer to some parameters to finaly giving me my
> binary executable.
No.
> Refering to all those questions, what make EXE2BIN ?
EXE2BIN converts (as the name implies) an EXE-style file (all segments
overlapped !) to a Binary file. That Binary file has an ORG of 0000h (just
like the .SYS-file ....)
> And what is the difference between a COM and a SYS file. In the
> coding scheme I know that for making a SYS file, I must specify
> that my code is based on ORG 0 at the oposite of a COM file
> base on ORG 100h.
There is your answer. A SYS-file does not get a PSP prepended to it when
it get's "executed".
> Finally a SYS file is mostly a COM file by the fact that they use only
> one SEGMENT for Code and Data.
BOTH files use only one segement for code & data ! Although a SYS-file has
(mostly) no own Stack-segment...
> Does to obtain a SYS file you just have to scratch the 100h first
> binary bytes of the final COM file ? Or does some references
> built by the compiler/linker inside a COM files won't allow me to
> use this technic ?
You can't just "scratch" some bytes off a file to convert it to some other
type !
You will have to create a file with the ORG 000h (an EXE-type of file ! ),
and convert that to a Binary (and afterwards rename it to .SYS).
> Why EXE2BIN only work with an EXE file in input and not a COM
> file ?
Because Binary-files *must* have an offset of 0000h, and you can't generate
a COM-file with that org.
> Will EXE2BIN allow me to have a BIN file (so a SYS file) with an EXE
> based on Medium memory Model or Large ( with EXE with more than
> 1 total segment ).
Nope ! An .EXE file has got a Relocation-table stuck in front of it to
recalculate (for example) segement-adresses to wherever the program get's
loaded. A Binary file (like the .COM-style file) has got no such
mechanism.
> Finally does with MASM or TASM there is a way to gain a BIN/SYS file
> directly without having to use EXE2BIN.
Not that I know of. You could ofcourse write a Batch-file to do the work ?
> Does an another Assembler (with Intel syntax) have this ability ?
Yes some Linkers can. But most of them can't generate EXE-style files ...
Regards,
Rudy Wieser
>
>Thierry DELHAISE <thierry....@delhaise.com> schreef in artikel
><stn9b5s...@corp.supernews.com>...
[snip]
>> Will EXE2BIN allow me to have a BIN file (so a SYS file) with an EXE
>> based on Medium memory Model or Large ( with EXE with more than
>> 1 total segment ).
>
>Nope ! An .EXE file has got a Relocation-table stuck in front of it to
>recalculate (for example) segement-adresses to wherever the program get's
>loaded. A Binary file (like the .COM-style file) has got no such
>mechanism.
Ok, but it's not entirely clear what Thierry is asking for here. I got
the impression that he is trying to figure out how to create a SYS & EXE
combo, e.g. like SETVER.EXE and EMM386.EXE, which are both device
drivers (loadable in CONFIG.SYS) and DOS executables. But of course
EXE2BIN cannot be used to create such combos.
>
>> Finally does with MASM or TASM there is a way to gain a BIN/SYS file
>> directly without having to use EXE2BIN.
>
>Not that I know of. You could ofcourse write a Batch-file to do the work ?
This is (largely) incorrect. MASM 5.1 could not create .COM or .SYS
files without the help of EXE2BIN or some similar utility, but MASM 6.11
certainly can. TASM & TLINK (all versions) can also create .COM and .SYS
files without using additional tools. Suppose you have a source file
TEST.ASM for a .COM program, then just do:
TASM /M TEST
TLINK /T TEST
On the other hand, if the source file TEST.ASM is for a device driver
(org 0), then TLINK will issue an error message if you try to run TLINK
/T TEST, because a .COM program is supposed to start at offset 100h.
However, you can overcome this difficulty if you explicitly specify the
output file:
TLINK /T TEST, TEST.SYS
>
>> Does an another Assembler (with Intel syntax) have this ability ?
>
>Yes some Linkers can. But most of them can't generate EXE-style files ...
>
Incorrect. I know of no DOS linker which can create .COM programs but
cannot create .EXE programs. Incidentally, NASM can create both .COM
programs and DOS device drivers without additional tools. But of course
this is an assembler, not a linker.
Haye van den Oever
Ahhh ... I did not see that one ! Well, if that's the case, you don't
need to convert the combined SYS/EXE file with EXE2BIN. A device-driver
can have a .EXE extention, and still being loaded as where it a .SYS-type
of file. Just take care that the image that makes up the device-driver is
at ORG 0000h .
> >> Finally does with MASM or TASM there is a way to gain a BIN/SYS file
> >> directly without having to use EXE2BIN.
> >
> >Not that I know of. You could ofcourse write a Batch-file to do the
work ?
>
> This is (largely) incorrect. MASM 5.1 could not create .COM or .SYS
> files without the help of EXE2BIN or some similar utility, but MASM 6.11
> certainly can. TASM & TLINK (all versions) can also create .COM and .SYS
> files without using additional tools. Suppose you have a source file
> TEST.ASM for a .COM program, then just do:
>
> TASM /M TEST
> TLINK /T TEST
>
> On the other hand, if the source file TEST.ASM is for a device driver
> (org 0), then TLINK will issue an error message if you try to run TLINK
> /T TEST, because a .COM program is supposed to start at offset 100h.
> However, you can overcome this difficulty if you explicitly specify the
> output file:
>
> TLINK /T TEST, TEST.SYS
So you see, you get to learn something new every day. Thank's ! I did not
know that one. (I'm still using TASM 1.01 and TLINK 2.0)
> >> Does an another Assembler (with Intel syntax) have this ability ?
> >
> >Yes some Linkers can. But most of them can't generate EXE-style files
..
> Incorrect. I know of no DOS linker which can create .COM programs but
> cannot create .EXE programs. Incidentally, NASM can create both .COM
> programs and DOS device drivers without additional tools. But of course
> this is an assembler, not a linker.
Ahh, I made a mistake in my answer. I ment to say that there are
*Assemblers* that can create .COM-style files (without the help of a
Linker, mind you), but I do not know of such a program that can create
EXE-type of files too.
My combination of TASM 1.01 & TLINK 2.0 (*very* old) can create .COM & .EXE
type of files. I could not find any switches that would enable me to
create other types, but as Haye showed me, there is a possibility to force
it.
Regards,
Rudy Wieser
> > >> Does an another Assembler (with Intel syntax) have this ability ?
> > >
> > >Yes some Linkers can. But most of them can't generate EXE-style files
> ..
>
> > Incorrect. I know of no DOS linker which can create .COM programs but
> > cannot create .EXE programs. Incidentally, NASM can create both .COM
> > programs and DOS device drivers without additional tools. But of course
> > this is an assembler, not a linker.
>
> Ahh, I made a mistake in my answer. I ment to say that there are
> *Assemblers* that can create .COM-style files (without the help of a
> Linker, mind you), but I do not know of such a program that can create
> EXE-type of files too.
Nasm will generate .COM and .SYS files, and if you don't consider some
macros cheating, will generate .EXE files directly, too. This isn't a
.COM file just re-named "exe" - it's a real MZ executable. A set of
macros exist to do this for elf executables, and I've seen a Nasm
program that generated the "world's smallest windows program" - a real
PE executable with a stub and everything - using the same technique.
;--------------------------------------------
; nasm -f bin -o hello.exe hello.asm
%include "exebin.mac" ; find this in the "misc"
; directory - might have
EXE_begin ; to download the source
; to get it.
section .text
mov ah,9
mov dx,msg
int 21h
mov ah,4Ch
int 21h
section .data
msg db 'hello, world$'
EXE_end
;-----------------------------------------
I doubt if this trickery gives the full flexibility of a "real" .EXE
made with a linker, but it works on simple stuff. I don't know what's
required for a "combo" .SYS / .EXE file, but I imagine Nasm could be
persuaded to do it.
Best,
Frank
Thanks, bye!!!