Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

MS-DOS & CP/M-Compatible Binaries

55 views
Skip to first unread message

WWheco1

unread,
Feb 17, 1999, 3:00:00 AM2/17/99
to
Okay, this might be off the wall. I don't lurk here often enough, so I did
make the effort to check the FAQ and search Deja News...

About 12 years ago, I came up with a process for creating *.COM files that
would run without modification on CP/M (8080, Z80) and MS-DOS (8088+) systems.
To my knowledge, there's no practical purpose for such a thing other than
intellectual curiosity.

I'd almost forgotten about it until I came across the article I'd written about
it and decided to publish it on the Web. The URL is:

http://members.aol.com/wwheco1/commscpm.htm

Has something like this been discussed before? If so, does it work
consistently and have a practical use?

--Bill

--
Bill Wilkinson
email: wxw...@aol.com
Heathkit Page: http://members.aol.com/wwheco1/index.htm

Cory Seligman

unread,
Feb 17, 1999, 3:00:00 AM2/17/99
to
wwh...@aol.com (WWheco1) writes:

>About 12 years ago, I came up with a process for creating *.COM files that
>would run without modification on CP/M (8080, Z80) and MS-DOS (8088+) systems.
>To my knowledge, there's no practical purpose for such a thing other than
>intellectual curiosity.

i came up with the same idea myself about 8 years ago. i'm sure that it isnt a
new idea, and i'm also fairly sure that it isnt very useful.

>http://members.aol.com/wwheco1/commscpm.htm

interesting. i never went so far as to write anything down about it, but i did
once work out some IBM-PC and AMIGA instructions that had a similar effect. On
the amiga, i think it did some pointless maths, and on the IBM it jumped a
small code distance. kind of pointless too, but i had the vague idea that it
would make a really cool boot disk that would work in both formats. as usual,
i never got around to doing anything with it.

>Has something like this been discussed before? If so, does it work
>consistently and have a practical use?

yes, it would work consistantly, i suppose, but as you say yourself in your
article, it requires twice as much code. it would be much easier for everyone
to just write it in C once and recompile for any number of platforms.

cheers,
cory


Richard Drushel

unread,
Feb 17, 1999, 3:00:00 AM2/17/99
to
WWheco1 (wwh...@aol.com) spake unto the ether::

: About 12 years ago, I came up with a process for creating *.COM files that


: would run without modification on CP/M (8080, Z80) and MS-DOS (8088+)
: systems.

[...]

: Has something like this been discussed before? If so, does it work


: consistently and have a practical use?

IIRC, the Z80ASM+ assembler from SLR (Z80ASMP.COM) would print a
nice error message on the console if you ran it under MS-DOS. I presume
it had some CPU-detect code which branched to a bit of x86 code to call
INT 21H for the error message display.

The idea sounds like the Macintosh "fat binary" (the same app in
both 68K and PPC code, with CPU-detect code at the beginning). Since on
the CP/M side you're limited by TPA, you have rather less than 64K total
to work with (MS-DOS .COM files put the stack pointer at the top of the
64K address space, so stack-parsimonious programs could have nearly 64K
code).

Isn't x86 code at least twice as big (opcode byte-wise) than Z80
code? This might be a further, more serious limitation on the kind of
"practical" programs you could package into a "fat .COM" file.

*Rich*
--
Richard F. Drushel, Ph.D. | "Aplysia californica" is your taxonomic
Department of Biology, Slug Division | nomenclature. / A slug, by any other
Case Western Reserve University | name, is still a slug by nature.
Cleveland, Ohio 44106-7080 U.S.A. | -- apologies to Data, "Ode to Spot"

Jonathan Graham Harston

unread,
Feb 17, 1999, 3:00:00 AM2/17/99
to
WWheco1 wrote:
> About 12 years ago, I came up with a process for creating *.COM files
> that would run without modification on CP/M (8080, Z80) and MS-DOS (8088+)
> systems. To my knowledge, there's no practical purpose for such a thing
> other than intellectual curiosity.
>
> Has something like this been discussed before? If so, does it work
> consistently and have a practical use?

I've done this quite a lot with joint Z80/6502 code. Basically, the first
few bytes look like (I can't remember the bytes exactly, but the opcodes
are more-or-less correct):

6502:
18 CLC
20 nn BCC dest65

Z80:
18 20 JR dest80
xx DEFB &xx

With a bit of thought, an executable header can be written to be runnable by
any CPU.

--
J.G.Harston (JGH BBC PD Library) 70 Camm Street, Walkley, SHEFFIELD S6 3TR
BBC+Master / Z80+6502 / CoPro+Tubes / Econet+SJ / Devolution / Transport /
Planning / Highways -- j...@arcade.demon.co.uk -- Message files <20k please

John Elliott

unread,
Feb 17, 1999, 3:00:00 AM2/17/99
to
wwh...@aol.com (WWheco1) wrote:
>About 12 years ago, I came up with a process for creating *.COM files that
>would run without modification on CP/M (8080, Z80) and MS-DOS (8088+) systems.
>To my knowledge, there's no practical purpose for such a thing other than
>intellectual curiosity.

Ah, but there is. MSODBALL is a program that converts 720k CP/M discs
to/from a DOS format; so when I did a DOS port, I combined the two files
into a "fat binary".
The tools I wrote to do it can be found at
<http://www.seasip.demon.co.uk/Cpm/software/fatbnsea.com>.

>I'd almost forgotten about it until I came across the article I'd written about
>it and decided to publish it on the Web. The URL is:
>
>http://members.aol.com/wwheco1/commscpm.htm
>

>Has something like this been discussed before? If so, does it work
>consistently and have a practical use?

I don't know about _discussed_; I've done it, if that's what you mean.
It certainly does have a use; apart from the program above, I've also used
it for:

* Self-extract PMA archives that extract under CP/M and DOS. See
<http://www.seasip.demon.co.uk/Cpm/software/pmsfx21x.com>
* Stopping CP/M .COM files being run under DOS. The most elegant programs
of this type are Simeon Cran's MYZ80 utilities, where the instruction
sequence (EB 44 EB) doesn't affect any CPU registers. My own programs
tend to use EB 04 EB, which affects the B register but makes the code more
understandable.

My normal prelude to a CP/M program is:

DEFB 0EBh,04h ;DOS protection... JMPS LABE
EX DE,HL
JP MAIN
DEFB 0B4h,09h ;DOS protection... LABE: MOV AH,9
DEFB 0BAh
DEFW BVMES ;DOS protection... MOV DX,OFFSET BVMES
DEFB 0CDh,021h ;DOS protection... INT 21h.
DEFB 0CDh,020h ;DOS protection... INT 20h.

------------- http://www.seasip.demon.co.uk/index.html --------------------
John Elliott |BLOODNOK: "But why have you got such a long face?"
|SEAGOON: "Heavy dentures, Sir!" - The Goon Show
:-------------------------------------------------------------------------)

0 new messages