Discussion:
Using Open Watcom as a cross compiler
(too old to reply)
Scott
2006-01-19 05:00:36 UTC
Permalink
I was wondering what it would take to make Open Watcom a cross
compiler. How difficult would it be and and idea where to change code
to do this?
Thanks!
Michal Necasek
2006-01-19 05:00:36 UTC
Permalink
Post by Scott
I was wondering what it would take to make Open Watcom a cross
compiler. How difficult would it be and and idea where to change code
to do this?
I don't understand the question. What do you mean by "cross compiler"?
Do you mean the situation where the host and target operating system is
different? OW can cross compile between, say, DOS, Windows, and OS/2
right now.

Or do you mean cross compilation between different CPU architectures?
There is no official support, but a lot of code is there. A very long
time ago, the C and F77 compilers supported IBM System/370. Around 1998,
Watcom/Sybase had an almost complete port of their compilers to Windows
NT on Alpha AXP. Earlier, there were efforts to support Windows NT and
OS/2 for PowerPC. All those projects were aborted because the platform
went away before the product was finished.

How difficult it is to support a new platform depends entirely on how
experienced programmer you are. I would estimate that an experienced
programmer should be able to port the codegen, C compiler and C runtime
to a new 32-bit Unix (or Win32) platform in 2-4 weeks.


Michal
Rod Pemberton
2006-01-19 05:00:36 UTC
Permalink
Post by Michal Necasek
Post by Scott
I was wondering what it would take to make Open Watcom a cross
compiler. How difficult would it be and and idea where to change code
to do this?
I don't understand the question. What do you mean by "cross compiler"?
Funny!
Post by Michal Necasek
Do you mean the situation where the host and target operating system is
different? OW can cross compile between, say, DOS, Windows, and OS/2
right now.
Or do you mean cross compilation between different CPU architectures?
There is no official support, but a lot of code is there. A very long
time ago, the C and F77 compilers supported IBM System/370. Around 1998,
Watcom/Sybase had an almost complete port of their compilers to Windows
NT on Alpha AXP. Earlier, there were efforts to support Windows NT and
OS/2 for PowerPC. All those projects were aborted because the platform
went away before the product was finished.
How about both...
Post by Michal Necasek
How difficult it is to support a new platform depends entirely on how
experienced programmer you are. I would estimate that an experienced
programmer should be able to port the codegen, C compiler and C runtime
to a new 32-bit Unix (or Win32) platform in 2-4 weeks.
What about the C libraries?

2-4 weeks? Michal are you
1) joking
2) delusional
3) extremely competitve
4) ignorant of OpenWATCOM's mountain of hard coded assembly which must be
ported...

For reference:
OpenWATCOM uses (for DOS), about 100 DOS, BIOS, DPMI, etc. calls.
LINUX uses requires about 200 syscalls (POSIX.1).
DJGPP uses about 170 DOS, BIOS, DPMI, etc. calls.
FORTH kernel, typically 132 to 147 required primitives for fig-FORTH,
FORTH-79, FORTH-83 standards.
GCC's libc, minimal set needed to get libc to link: 18

(_exit,close,environ,execve,fork,fstat,getpid,isatty,kill,link,lseek,read,sb
rk,stat,times,unlink,wait,write)

Despite the fact that (DOS) OpenWATCOM is built on a small core of
functions, it has many hardcoded routines. It doesn't generate
intermediate assembly. It'd be easier for him, I think, to rework a
compiler doesn't use so much hardcode and is built upon a small number of
standardized tools which compile everywhere easily, such as GCC and
Binutils.


Good Luck Porting!,

Rod Pemberton
Michal Necasek
2006-01-19 05:00:37 UTC
Permalink
Post by Rod Pemberton
What about the C libraries?
2-4 weeks? Michal are you
1) joking
2) delusional
3) extremely competitve
4) ignorant of OpenWATCOM's mountain of hard coded assembly which must be
ported...
Unlike you (I assume) I have already ported the runtime to other
platforms. Porting a subset of the runtime lib plus the math lib to
Linux on PowerPC (using GCC) took me a week at most. Porting the runtime
to AMD64 Linux took a few days, mostly related to tweaking the code to
be 64-bit clean. Porting the runtime later to MIPS Linux took hardly any
time at all, just a few #ifdefs here and there.
Post by Rod Pemberton
Despite the fact that (DOS) OpenWATCOM is built on a small core of
functions, it has many hardcoded routines.
You think? When the core runtime already supports DOS, OS/2, Windows,
Netware, Linux, and used to support QNX? How do you think Watcom did it
when they ported the Win32 version of the runtime to Alpha?
Post by Rod Pemberton
It doesn't generate intermediate assembly.
Of course not. Generating assembly and then running it through
external tool is a silly idea. It is easy to spit out the object code
directly, especially on orthogonal RISC architectures.

I am certainly not joking. I wouldn't say I'm delusional. I don't know
if I'm "extremely competitive". The estimates I gave are based on my own
experience. I've already ported the runtime before so I know what I'm
talking about - unlike you, apparently. The "mountain of hard coded
assembly which must be ported" exists only in your imagination.


Michal
Michal Necasek
2006-01-19 05:00:39 UTC
Permalink
Sybase never released WATCOM C/C++ for the Alpha, Mips, and PPC.
Correct. WATCOM/Sybase never did any work on MIPS support. They did do
some work on PowerPC support in the 1995-1996 timeframe right before
both IBM and Microsoft killed the PowerPC ports of their x86 operating
systems. The Watcom Alpha compiler was about to go alpha (no pun
intended) when Microsoft announced they were going to drop support for
the Alpha platform.
I don't
believe WATCOM C/C++ ever generated native instructions for the Alpha, Mips,
and PowerPC.
What you believe or not is, fortunately, entirely irrelevant. I don't
know why I'm even wasting time trying to talk to you because I'm
obviously not getting through.
I believe it generated i486 instructions which were then emulated.
I'm so sorry to say that you believe wrong.
Since there is no information on this, I no other choice but to
believe this.
Oh, right. There is no information. Sorry, I forgot. The Open Watcom
source code has never been released. There is no directory called
bld/risc/axp (and neither is there bld/risc/ppc or bld/risc/mps). It's
not possible to build a compiler called wccaxp, and even if it was, it
certainly wouldn't generate Alpha AXP object code, let alone cross
compile from a x86 box! Needless to say, there's no support for 64-bit
registers in the debugger and it's impossible to cross debug from x86 to
NT on AXP. There are zero instances of #ifdef __AXP__ in the OW source
code because no one ever tried to port anything to Alpha. I also did not
take this screenshot:

Loading Image...

Instead I sat down with a bitmap editor and invented a few
instructions that might look like the Alpha instruction set and made it
*look* as if I had the Watcom GUI tools (text editor, resource editor,
Dr. Watcom) running on NT 4/SP6 on an old Alpha box.

Scott, I'll let you decide if you want to trust Mr. Pemberton or me :)
Silly. No. Inefficient. Yes. Portable. Yes. Useful. Yes.
Portable? Generating platform specific assembly is portable? I don't
think so.
What RISC architecture?
I haven't seen one that OpenWATCOM supports natively, yet. (see above
comments)
May I suggest that that could be because you weren't looking?
If he wants OpenWATCOM to run on something other than an Intel instruction
set CPU, then yes, I think he has much porting to do... That is, until you
manage to prove to me otherwise.
I respect your right to remain ignorant! I would certainly *hate* to
burst your bubble. It's quite well preserved.


Michal
Rod Pemberton
2006-01-19 05:00:44 UTC
Permalink
Post by Michal Necasek
Sybase never released WATCOM C/C++ for the Alpha, Mips, and PPC.
Correct. WATCOM/Sybase never did any work on MIPS support. They did do
some work on PowerPC support in the 1995-1996 timeframe right before
both IBM and Microsoft killed the PowerPC ports of their x86 operating
systems. The Watcom Alpha compiler was about to go alpha (no pun
intended) when Microsoft announced they were going to drop support for
the Alpha platform.
I don't
believe WATCOM C/C++ ever generated native instructions for the Alpha, Mips,
and PowerPC.
What you believe or not is, fortunately, entirely irrelevant. I don't
know why I'm even wasting time trying to talk to you because I'm
obviously not getting through.
I believe it generated i486 instructions which were then emulated.
I'm so sorry to say that you believe wrong.
Nothing proving me wrong in the version of OW1.3 I've got. Perhaps I need
to upgrade?
Post by Michal Necasek
Since there is no information on this, I no other choice but to
believe this.
Oh, right. There is no information. Sorry, I forgot. The Open Watcom
source code has never been released. There is no directory called
bld/risc/axp (and neither is there bld/risc/ppc or bld/risc/mps). It's
not possible to build a compiler called wccaxp, and even if it was, it
certainly wouldn't generate Alpha AXP object code, let alone cross
compile from a x86 box! Needless to say, there's no support for 64-bit
registers in the debugger and it's impossible to cross debug from x86 to
NT on AXP. There are zero instances of #ifdef __AXP__ in the OW source
code because no one ever tried to port anything to Alpha. I also did not
http://www.openwatcom.org/ftp/devel/ntaxp.gif
Actually, there are no directories called bld/risc/axp, bld/risc/mps, or
bld/risc/ppc for the version of OW1.3 that I'm using. There are no files
with mps in the name. There are a bunch of empty stubs sprinkled around
with ppc in the name. To be fair, there is partial code which appears
incomplete bld/cg/risc/axp. Perhaps OW1.1 didn't get overwritten properly
or something was wrong with the OW1.3 installer. Or, perhaps I am correct,
and those files where written, added, or released to a later version of OW.

(Wow. Two posts later, you actually answered part of the OP's original
question in your rant to me... That's a first. )
Post by Michal Necasek
Instead I sat down with a bitmap editor and invented a few
instructions that might look like the Alpha instruction set and made it
*look* as if I had the Watcom GUI tools (text editor, resource editor,
Dr. Watcom) running on NT 4/SP6 on an old Alpha box.
Scott, I'll let you decide if you want to trust Mr. Pemberton or me :)
Silly. No. Inefficient. Yes. Portable. Yes. Useful. Yes.
Portable? Generating platform specific assembly is portable? I don't
think so.
I didn't say that. Neither platform specific assembly nor binaries are
portable. But, the generic C that the GAS assembler backend is written in
is highly portable and easily fixable.
Post by Michal Necasek
What RISC architecture?
I haven't seen one that OpenWATCOM supports natively, yet. (see above
comments)
May I suggest that that could be because you weren't looking?
No. I was. It isn't here.
Post by Michal Necasek
If he wants OpenWATCOM to run on something other than an Intel instruction
set CPU, then yes, I think he has much porting to do... That is, until you
manage to prove to me otherwise.
I respect your right to remain ignorant! I would certainly *hate* to
burst your bubble. It's quite well preserved.
Well, I'll accept that you proved me wrong, although I can't completely
confirm it... The version of OW1.3 I have doesn't contain the code you say
exists, but your gif shows something working...


Rod Pemberton
Vesa Jääskeläinen
2006-01-19 05:00:45 UTC
Permalink
Post by Rod Pemberton
Well, I'll accept that you proved me wrong, although I can't completely
confirm it... The version of OW1.3 I have doesn't contain the code you say
exists, but your gif shows something working...
Why not use most recent version of the Open Watcom :)... version 1.4 was
quite silently released ;)
Michal Necasek
2006-01-19 05:00:46 UTC
Permalink
Post by Rod Pemberton
Nothing proving me wrong in the version of OW1.3 I've got.
The non-x86 compilers aren't part of the binary distribution.
Post by Rod Pemberton
Actually, there are no directories called bld/risc/axp, bld/risc/mps, or
bld/risc/ppc for the version of OW1.3 that I'm using.
My mistake. It's bld/cg/risc, not bld/risc.


Michal
Roald Ribe
2006-01-19 05:00:40 UTC
Permalink
On Mon, 09 Jan 2006 09:04:03 +0100, Rod Pemberton =
Sybase never released WATCOM C/C++ for the Alpha, Mips, and PPC. I do=
n't
believe WATCOM C/C++ ever generated native instructions for the Alpha,=
=
Mips, and PowerPC.
That something was not released, does not mean it was never made...
I believe it generated i486 instructions which werethen emulated. =
Microsoft's NT 4.0 for RISC (Alpha, Mips, and PPC) used WX86.EXE for =
i486 instruction emulation. Also, Digital's FX!32 for the Alpha
emulated x86 instructions. Also, Centaur Technologies had an x86 emula=
tor
for MIPS. I suspect that this emulation under a virtual machine was =
a
factor in why they where never released. Since there is no informati=
on =
on this, I no other choice but to believe this.
This is totally besides the point. You speak about what was released
as executables in a commercial product years ago, the discussion is
about what is in the Open Watcom project source tree.
I am certainly not joking. I wouldn't say I'm delusional. I don't k=
now
if I'm "extremely competitive". The estimates I gave are based on my =
own
experience. I've already ported the runtime before so I know what I'm=
talking about - unlike you, apparently. The "mountain of hard coded
assembly which must be ported" exists only in your imagination.
If he wants OpenWATCOM to run on something other than an Intel =
instruction set CPU, then yes, I think he has much porting to do... Th=
at =
is, until you manage to prove to me otherwise.
How about trying to build Open Watcom from the current source and see
what you get, rather than twiddle your thumbs and challenge others to
prove something to you? Last time I built, wcc386.exe, wccaxp.exe,
wccppc.exe appeared in binnt. I can not prove it to you obviously,
but if you think wccppc.exe generates i486 instructions, you are
seriously deluded...

Stop making claims about stuff you obviously have no insight into,
since your postings may serve to confuse new readers of this group.

Roald
Rod Pemberton
2006-01-19 05:00:44 UTC
Permalink
"Roald Ribe" <***@pogostick.net> wrote in message news:***@rrnt2k...
On Mon, 09 Jan 2006 09:04:03 +0100, Rod Pemberton
Post by Rod Pemberton
Sybase never released WATCOM C/C++ for the Alpha, Mips, and PPC. I don't
believe WATCOM C/C++ ever generated native instructions for the Alpha,
Mips, and PowerPC.
That something was not released, does not mean it was never made...
Post by Rod Pemberton
I believe it generated i486 instructions which werethen emulated.
Microsoft's NT 4.0 for RISC (Alpha, Mips, and PPC) used WX86.EXE for
i486 instruction emulation. Also, Digital's FX!32 for the Alpha
emulated x86 instructions. Also, Centaur Technologies had an x86 emulator
for MIPS. I suspect that this emulation under a virtual machine was a
factor in why they where never released. Since there is no information
on this, I no other choice but to believe this.
This is totally besides the point. You speak about what was released
as executables in a commercial product years ago, the discussion is
about what is in the Open Watcom project source tree.
Post by Rod Pemberton
Post by Michal Necasek
I am certainly not joking. I wouldn't say I'm delusional. I don't know
if I'm "extremely competitive". The estimates I gave are based on my own
experience. I've already ported the runtime before so I know what I'm
talking about - unlike you, apparently. The "mountain of hard coded
assembly which must be ported" exists only in your imagination.
If he wants OpenWATCOM to run on something other than an Intel
instruction set CPU, then yes, I think he has much porting to do... That
is, until you manage to prove to me otherwise.
How about trying to build Open Watcom from the current source and see
what you get, rather than twiddle your thumbs and challenge others to
prove something to you? Last time I built, wcc386.exe, wccaxp.exe,
wccppc.exe appeared in binnt. I can not prove it to you obviously,
but if you think wccppc.exe generates i486 instructions, you are
seriously deluded...

Stop making claims about stuff you obviously have no insight into,
since your postings may serve to confuse new readers of this group.

Roald
Rod Pemberton
2006-01-19 05:00:44 UTC
Permalink
Eh, sorry, no reply in prior post.
Post by Roald Ribe
On Mon, 09 Jan 2006 09:04:03 +0100, Rod Pemberton
Post by Rod Pemberton
Sybase never released WATCOM C/C++ for the Alpha, Mips, and PPC. I don't
believe WATCOM C/C++ ever generated native instructions for the Alpha,
Mips, and PowerPC.
That something was not released, does not mean it was never made...
You don't read very well do you? What does "ever generated native
instructions" mean to you?
Does it mean working but no native instruction (correct)? Or, does it mean
not ever made (incorrect)?
Post by Roald Ribe
Post by Rod Pemberton
I believe it generated i486 instructions which werethen emulated.
Microsoft's NT 4.0 for RISC (Alpha, Mips, and PPC) used WX86.EXE for
i486 instruction emulation. Also, Digital's FX!32 for the Alpha
emulated x86 instructions. Also, Centaur Technologies had an x86 emulator
for MIPS. I suspect that this emulation under a virtual machine was a
factor in why they where never released. Since there is no information
on this, I no other choice but to believe this.
This is totally besides the point. You speak about what was released
as executables in a commercial product years ago, the discussion is
about what is in the Open Watcom project source tree.
No. It's not beside the point. You've taken the point out of context with
the rest of my prior statement...
Post by Roald Ribe
Post by Rod Pemberton
Post by Michal Necasek
I am certainly not joking. I wouldn't say I'm delusional. I don't know
if I'm "extremely competitive". The estimates I gave are based on my own
experience. I've already ported the runtime before so I know what I'm
talking about - unlike you, apparently. The "mountain of hard coded
assembly which must be ported" exists only in your imagination.
If he wants OpenWATCOM to run on something other than an Intel
instruction set CPU, then yes, I think he has much porting to do... That
is, until you manage to prove to me otherwise.
How about trying to build Open Watcom from the current source and see
what you get, rather than twiddle your thumbs and challenge others to
prove something to you? Last time I built, wcc386.exe, wccaxp.exe,
wccppc.exe appeared in binnt. I can not prove it to you obviously,
but if you think wccppc.exe generates i486 instructions, you are
seriously deluded...
The code doesn't exist in the version I've got. It will not build.
Post by Roald Ribe
Stop making claims about stuff you obviously have no insight into,
since your postings may serve to confuse new readers of this group.
Perhaps you shouldn't jump to conclusions and take more time to comprehend
what you read.


Rod Pemberton
Rod Pemberton
2006-01-19 05:00:39 UTC
Permalink
Post by Michal Necasek
Post by Rod Pemberton
What about the C libraries?
2-4 weeks? Michal are you
1) joking
2) delusional
3) extremely competitve
4) ignorant of OpenWATCOM's mountain of hard coded assembly which must be
ported...
Unlike you (I assume) I have already ported the runtime to other
platforms. Porting a subset of the runtime lib plus the math lib to
Linux on PowerPC (using GCC) took me a week at most. Porting the runtime
to AMD64 Linux took a few days, mostly related to tweaking the code to
be 64-bit clean. Porting the runtime later to MIPS Linux took hardly any
time at all, just a few #ifdefs here and there.
Post by Rod Pemberton
Despite the fact that (DOS) OpenWATCOM is built on a small core of
functions, it has many hardcoded routines.
You think? When the core runtime already supports DOS, OS/2, Windows,
Netware, Linux, and used to support QNX? How do you think Watcom did it
when they ported the Win32 version of the runtime to Alpha?
Sybase never released WATCOM C/C++ for the Alpha, Mips, and PPC. I don't
believe WATCOM C/C++ ever generated native instructions for the Alpha, Mips,
and PowerPC. I believe it generated i486 instructions which were then
emulated. Microsoft's NT 4.0 for RISC (Alpha, Mips, and PPC) used WX86.EXE
for i486 instruction emulation. Also, Digital's FX!32 for the Alpha
emulated x86 instructions. Also, Centaur Technologies had an x86 emulator
for MIPS. I suspect that this emulation under a virtual machine was a
factor in why they where never released. Since there is no information on
this, I no other choice but to believe this.
Post by Michal Necasek
Post by Rod Pemberton
It doesn't generate intermediate assembly.
Of course not. Generating assembly and then running it through
external tool is a silly idea. It is easy to spit out the object code
directly, especially on orthogonal RISC architectures.
Silly. No. Inefficient. Yes. Portable. Yes. Useful. Yes.
There are many small pieces of information that can be obtained from
assembly that can't be obtained from dissassembly. What RISC architecture?
I haven't seen one that OpenWATCOM supports natively, yet. (see above
comments)
Post by Michal Necasek
I am certainly not joking. I wouldn't say I'm delusional. I don't know
if I'm "extremely competitive". The estimates I gave are based on my own
experience. I've already ported the runtime before so I know what I'm
talking about - unlike you, apparently. The "mountain of hard coded
assembly which must be ported" exists only in your imagination.
If he wants OpenWATCOM to run on something other than an Intel instruction
set CPU, then yes, I think he has much porting to do... That is, until you
manage to prove to me otherwise.


Rod Pemberton
Mat Nieuwenhoven
2006-01-19 05:00:41 UTC
Permalink
On Mon, 9 Jan 2006 03:04:03 -0500, Rod Pemberton wrote:

<snip>
Post by Michal Necasek
I don't
believe WATCOM C/C++ ever generated native instructions for the Alpha, Mips,
and PowerPC. I believe it generated i486 instructions which were then
emulated.
You are obviously not a programmer, and have never looked at OW building.
It isn't difficult to determine that there can be executables built to
produce Alpha, Mips and Ppc code.

Mat Nieuwenhoven
Rod Pemberton
2006-01-19 05:00:45 UTC
Permalink
Post by Mat Nieuwenhoven
<snip>
Post by Michal Necasek
I don't
believe WATCOM C/C++ ever generated native instructions for the Alpha, Mips,
and PowerPC. I believe it generated i486 instructions which were then
emulated.
You are obviously not a programmer, and have never looked at OW building.
It isn't difficult to determine that there can be executables built to
produce Alpha, Mips and Ppc code.
Mat Nieuwenhoven
Ah, Mat,

I know you meant that as a harsh insult. Normally, I would take
offense. The code doesn't exist in the version of OW1.3 I've got. But, I'm
honestly and genuinely happy you said that I'm not a programmer. You are
partly and doubly correct. I am no longer a programmer, but was one. My
background is actually Electrical Engineering. Of the hundreds of degreed
programmers I've known, there was only one other programmer who was not
borderline incompetent. My professional programming experience was
developing and maintaining a real-time online transaction processing stock
trading program for a major brokerage. $. $. $. The department I was in
had three programmers. Most of the other major brokerages used about 60
programmers for the same function. Prior to that, I worked for a number of
years as an electronic technician solving "unsolvable" problems with analog
audio and DSP circuitry problems for an electronics firm. "Unsolvable"
meaning: the engineers who designed the circuits, couldn't find the problems
even with their perfect reference boards, schematics, and in-depth knowledge
of how the circuit worked. I no longer have to work, but I would like, and
perhaps need to longer term, to get back into programming. With the money
I've earned, I've been thinking about purchasing a small company or perhaps
initiating my own.


How's your life?

Rod Pemberton
Mat Nieuwenhoven
2006-01-19 05:00:46 UTC
Permalink
On Mon, 9 Jan 2006 16:15:05 -0500, Rod Pemberton wrote:

<snip>
Post by Rod Pemberton
Post by Mat Nieuwenhoven
You are obviously not a programmer, and have never looked at OW building.
It isn't difficult to determine that there can be executables built to
produce Alpha, Mips and Ppc code.
Mat Nieuwenhoven
Ah, Mat,
I know you meant that as a harsh insult.
I very rarely insult people. It was meant sarcastically. I remain
astonished that you build a whole argument on basis of a single false
assumption, that is easily verified as such. A simple groups google with
'watcom ppc' would have shown you that.

Normally, I would take
Post by Rod Pemberton
offense. The code doesn't exist in the version of OW1.3 I've got.
As far as I can remember, it existed right from the beginning. If you
download the oldest OW source files, and look in for instance the bld\as
dir, you'll see there are a number of non-X86 assemblers (start with the
lang.ctl file). Or the same file in bld\clib, you'll see that the non-X86
code isn't built by default. Why don't you get the source, build all of the
normal stuff, then e.g. some of the ppc stuff for you so you can try it
with PearPC if you don't have PPC hardware?

Mat Nieuwenhoven
Scott
2006-01-19 05:00:37 UTC
Permalink
Post by Michal Necasek
Post by Scott
I was wondering what it would take to make Open Watcom a cross
compiler. How difficult would it be and and idea where to change code
to do this?
I don't understand the question. What do you mean by "cross compiler"?
Do you mean the situation where the host and target operating system is
different? OW can cross compile between, say, DOS, Windows, and OS/2
right now.
Yes, the host and target OS's would be different.
Post by Michal Necasek
Or do you mean cross compilation between different CPU architectures?
There is no official support, but a lot of code is there. A very long
time ago, the C and F77 compilers supported IBM System/370. Around 1998,
Watcom/Sybase had an almost complete port of their compilers to Windows
NT on Alpha AXP. Earlier, there were efforts to support Windows NT and
OS/2 for PowerPC. All those projects were aborted because the platform
went away before the product was finished.
And between different architectures. Unfortunately they didn't keep
the code in the compiler to support the IBM operating systems.
Post by Michal Necasek
How difficult it is to support a new platform depends entirely on how
experienced programmer you are. I would estimate that an experienced
programmer should be able to port the codegen, C compiler and C runtime
to a new 32-bit Unix (or Win32) platform in 2-4 weeks.
I would think I am somewhat experienced.
Post by Michal Necasek
Michal
Michal Necasek
2006-01-19 05:00:38 UTC
Permalink
Post by Scott
And between different architectures. Unfortunately they didn't keep
the code in the compiler to support the IBM operating systems.
Not sure what you mean. The Watcom S/370 codegen still exists, but
probably suffers from severe bit rot. There's not much to do on the C
front end side really, and at least some of the code is still there as
well. Finding the hardware to run it on might be the hardest part.
Post by Scott
I would think I am somewhat experienced.
Then take a look at the code...


Michal
Mat Nieuwenhoven
2006-01-19 05:00:38 UTC
Permalink
Post by Michal Necasek
Post by Scott
And between different architectures. Unfortunately they didn't keep
the code in the compiler to support the IBM operating systems.
Not sure what you mean. The Watcom S/370 codegen still exists, but
probably suffers from severe bit rot. There's not much to do on the C
front end side really, and at least some of the code is still there as
well. Finding the hardware to run it on might be the hardest part.
There's an IBM mainframe emulator called Hercules
(http://www.conmicro.cx/hercules/ ).

Mat Nieuwenhoven
Wilton Helm
2006-01-19 05:00:42 UTC
Permalink
I cross-compile on OW every day. Not radically, but definitely cross
compile. My development system is XP, my target is various 186 CPUs with no
OS. I had to create a couple of debug traps for the target hardware and
modified copies of the startup file, fprtf.c and puts.c.

Because I needed an OS independent executable (ROM) I made some extensions
to the linker that are included in 1.4.

I'm not as proficient as Michal and started out learning the OW environment
at the same time, but I had usable executables in 3 - 4 weeks using a 3rd
party locate utility. The linker effort took longer, because it was more
involved. The first debug kernel probably took me 4 weeks, and the second
one 2 weeks.

You may be using more diverse hardware and operating systems, but that it
may already be supported. It sounds like you are using an OS, so you may
not have to deal with some of the messy details I had to for embedded work.

Wilton
Bernd Mueller
2006-01-19 05:00:47 UTC
Permalink
On Mon, 9 Jan 2006 11:56:58 -0700, "Wilton Helm"
Post by Wilton Helm
I cross-compile on OW every day. Not radically, but definitely cross
compile. My development system is XP, my target is various 186 CPUs with no
OS. I had to create a couple of debug traps for the target hardware and
modified copies of the startup file, fprtf.c and puts.c.
Because I needed an OS independent executable (ROM) I made some extensions
to the linker that are included in 1.4.
does the linker produce now relocated code, which can be loaded at any
address in ROM?
could you please give me an example, how to call the linker to produce
a 16-Bit (real mode) romable binary?

I am working with X86 CPUs (NEC V25, 386EX real mode). I use a self
written locator to produce Turbo Pascal and Delphi 1 romable files. I
would like to program in C without OS.

Thank you and best regards,
Bernd Mueller.
Mat Nieuwenhoven
2006-01-19 05:00:49 UTC
Permalink
Post by Bernd Mueller
On Mon, 9 Jan 2006 11:56:58 -0700, "Wilton Helm"
Post by Wilton Helm
I cross-compile on OW every day. Not radically, but definitely cross
compile. My development system is XP, my target is various 186 CPUs with no
OS. I had to create a couple of debug traps for the target hardware and
modified copies of the startup file, fprtf.c and puts.c.
Because I needed an OS independent executable (ROM) I made some extensions
to the linker that are included in 1.4.
does the linker produce now relocated code, which can be loaded at any
address in ROM?
could you please give me an example, how to call the linker to produce
a 16-Bit (real mode) romable binary?
There's an example in the linker guide, under the directive 'ORDER' . Maybe
this is sufficient as a starter?

Mat Nieuwenhoven
Wilton Helm
2006-01-19 05:00:50 UTC
Permalink
Yes, that's exactly what I use OW for myself. My preferred CPU at the
moment is the Lantronix DSTni LX (and EX) distributed by Grid Connect, and I
also use the AM186ER quite a bit. I have debugger ports for the former
using RS-232, and the latter using Emutec PROMJet. If/when I get funding, I
will build a JTAG debugger HW and SW for the DSTni CPUs.

At the moment, I haven't checked in the debugger stuff into the source tree
because the make process isn't up to OW standards, but I could hare it with
you if it was useful.

The linker stuff is all in place and documented (in OW 1.4) for 16 bit x86.
It also works for some 32 bit applications, although it hasn't been tested
for all. I also could share a sample startup file and my changes to printf
if those are valuable to you. My approach is to run I/O through a global
variable driven switch to putchar()/getchar() style drivers for serial
ports, LCD, etc.

Wilton
Bernd Mueller
2006-01-19 05:00:55 UTC
Permalink
On Tue, 10 Jan 2006 12:11:40 -0700, "Wilton Helm"
Post by Wilton Helm
Yes, that's exactly what I use OW for myself. My preferred CPU at the
moment is the Lantronix DSTni LX (and EX) distributed by Grid Connect, and I
also use the AM186ER quite a bit. I have debugger ports for the former
using RS-232, and the latter using Emutec PROMJet. If/when I get funding, I
will build a JTAG debugger HW and SW for the DSTni CPUs.
I will have a closer look to the Lantronix DSTni chips. 5 or 6 years
ago, I designed a controller board around the AM188ES, but AMD
discontinued all their embedded X86 stuff.
I have now 512 KB SRAM and 512 KB FLASH ROM in my 386EX board and due
to a rudimentary (self written) BIOS I can run FreeDos but it consumes
too much memory and the startup time is slow, compared to an
application which can run direct out of FLASH ROM.
Post by Wilton Helm
At the moment, I haven't checked in the debugger stuff into the source tree
because the make process isn't up to OW standards, but I could hare it with
you if it was useful.
Thank you for your offer. I will contact you later. First I have to
get a little familiar with the OW compiler and linker.
Post by Wilton Helm
The linker stuff is all in place and documented (in OW 1.4) for 16 bit x86.
It also works for some 32 bit applications, although it hasn't been tested
for all. I also could share a sample startup file and my changes to printf
if those are valuable to you. My approach is to run I/O through a global
variable driven switch to putchar()/getchar() style drivers for serial
ports, LCD, etc.
Thanks again. I had a quick look to the startup code and found 4
different int 21h calls. I am going to extend my BIOS to handle these
DOS calls. If this will not work, I will contact you for the startup
file.

Regards, Bernd Mueller.
Wilton Helm
2006-01-19 05:00:58 UTC
Permalink
. . .I designed a controller board around the AM188ES, but AMD
discontinued all their embedded X86 stuff.
Not entirely true. The ES went away, although a third party makes a pin
compatible drop in replacement. They tried to kill the ER, but IBM was
using it in a router or something, so they farmed it out to a 3rd party fab
line (one of the reasons for trying to kill it was either that the fab it
was running on had problems, or was needed for something that was a higher
priority). Anyway the ER is still an active part, and I still design it in
and use it. They also had the CC, CU, etc. I don't know if those are still
active.

Do check out the DSTni stuff, though. 100 MHz 16 bit real mode with single
cycle memory access, and most instructions executing in 2 or 3 clocks is a
real shot in the arm, and built in serial ports, Ethernet, etc., etc. is
nice.
I had a quick look to the startup code and found 4
different int 21h calls. I am going to extend my BIOS to handle these
DOS calls.
That is one way to go. I found little in DOS or bios of interest to me, so
I rewrote the startup code (and debugger trap file) to be free of any INT21
dependencies, and made it do what I wanted right out of the reset vector.
If you need a file system, or are particularly attached to a DOS based
driver for something, then the DOS/BIOS approach makes sense. Otherwise I
just see it as a ball and chain to drag a project down.

One feature in OW that is either a major asset, or a major pain, depending
on your needs is multibyte chars and wide chars. There is an INT21 call in
the library to get the translation table for that under DOS. I just created
a static table in the function that says everything is single byte.
Rod Pemberton
2006-01-19 05:00:47 UTC
Permalink
"Michal Necasek" <***@prodigy.net> wrote in message news:dpve2d$ien$***@www-1.scitechsoft.com...

Not sure that I'll need it. But the other guy might.

Thank You, Saved It.

RP
Michal Necasek
2006-01-19 05:00:46 UTC
Permalink
To expand on what I said earlier, I have a suggestion for the sequence
of steps for any port to a new platform.

1) Write a disassembler. For RISC platforms with orthogonal
instruction sets, this is pretty easy (about a day to get decent
disassembly). If the object format is not supported (ie. not 32-bit
ELF/COFF or OMF), it might take significantly longer.

2) Port the debugger. You'll be glad you did. If the platform is Linux
based, it should be real easy. If it's some other Unix, it still
shouldn't be too hard. If it's something altogether different, it could
take a while. If the debug format isn't supported (ie. not DWARF, that
will take additional time). The debugger will reuse the disassembler you
did earlier.

At this point, you should be able to remotely debug to your target
platform, and if it's Unix, it shouldn't be too hard to port the entire
debugger front end to it using the platform's native compiler. If the
only other debugging alternative is gdb, porting wd will save you tons
of time later on. These first two steps may be quite useful on their own.

3) Port the assembler. Again if it's a RISC platform, and if it
doesn't have a "smart" assembler like MIPS for instance (with tons of
pseudo-instructions), that's not such a huge amount of work. Again if
the object format is unsupported (not 32-bit ELF/COFF), expect
additional effort. The assembler doesn't have to be complete, but it
should be good enough to generate the few assembly routines for clib
(things like longjmp aren't really doable in C). The inline assembler
will be reused later by the C/C++ compiler, which may make interfacing
with system calls very easy (see bld/clib/linux/h/sysmips.h for an example).

4) Port the C front end. This should not be too difficult; the biggest
platform specific thing to worry about will be functions with variable
arguments, and it's almost a given those will cause headaches. The C
compiler will be an empty shell at this point, but you'll need it to
exercise the codegen.

5) Now comes the really hard part, the codegen. You'll reuse what you
learned earlier when porting the assembler. If the target is an
orthogonal RISC platform, you will be able to clone one of the existing
RISC codegens. If it's something weird or, god forbid, something as
awful as x86, you really have your work cut out for you. This part is by
far the most difficult because it requires understanding of how the
codegen works. Taking a quick look at bld/cg/doc/mipsnotes.txt may be a
good idea. Every CPU architecture seems to have its quirks (delay slots,
not so orthogonal instruction sets, alignment and/or operand size
restrictions, and who knows what sorts of other weirdness) and there are
no generic solutions. Note that vast swathes of the codegen won't
require any changes whatsoever as they're completely generic; the code
that translates intermediate code (sort of pseudo-assembly) is where the
effort will be concentrated.

6) Port the clib. Again if the target is a Linux or Unix platform,
it's probably not going to be terribly difficult. If it's something
oddball that doesn't even remotely resemble POSIX, expect trouble. This
step will probably overlap with the codegen port. Getting as far as
puts()-based hello world is not *that* difficult, but the fun starts
with printf(), and math stuff is guaranteed to be "interesting".

7) Port the linker. Same thing as earlier - if the object and
executable format is supported (ELF, PE, etc. etc.), most of the work's
done already. If it's something else, there's no telling how much effort
exactly it'll take.

By now you should be able to generate basic executables, at first
using syscalls directly and later using the clib. Now's where you will
really appreciate the debugger because the cg will be buggy and the
programs are going to die a lot.

8) Run (and pass) tests. At the end of this step, the compiler should
be able to pass the tests in bld/ctest/regress and - quite possibly with
extra tweaking - the tests in bld/clib/qa.

It may also be instructive to start cross compiling some utilities for
the target platform - disassembler, linker, etc. Once the port is solid
enough, it should be able to generate a functioning compiler. By the
time that compiler is good enough to compile itself and still work, you
should have a pretty solid codegen plus tools and basic runtime library
support.

9) Optionally continue with the C++ and perhaps F77 compiler and other
tools. The profiler is especially good candidate, and if you have a
debugger, you're almost done with the profiler. Most of the command line
tools are pretty easy to port, but the GUI tools are entirely different
kettle of fish. Porting all the GUI tools might conceivably require as
much effort as porting the compiler itself.

A lot of these steps can be done in parallel, for instance #1 and #3
are independent of each other. There are also two completely different
porting strategies: Either port the OW tools to the target platform
first, using the native compiler, or cross compile from a supported
platform. I'd recommend the latter, but it's a question of personal
preference. The host tools should be definitely solid, because otherwise
you'll be juggling way too many balls at the same time. Porting the
codegen/clib/linker/etc. all at the same time is hard enough. It is
recommended to use the target platform's tools at least in the initial
stages - eg. generate your own object files but use the existing linker.
This work in the other direction as well - it's possible to port eg. the
linker first and use existing tools to generate object files.

Needless to say, the above assumes that the target platform runs an
actual OS. If it's some kind of restricted embedded system, the work
will be in some ways easier (perhaps no need to port clib) and in other
ways much harder (far more difficult to test what you've done).

I should probably put this stuff in wiki at some point...


Michal
Peter C. Chapin
2006-01-19 05:00:48 UTC
Permalink
Post by Michal Necasek
I should probably put this stuff in wiki at some point...
Yes, even if you just drop your last posting in as-is... it would make a
great developer's tutorial.

Peter
Scott
2007-11-09 22:50:40 UTC
Permalink
Post by Michal Necasek
To expand on what I said earlier, I have a suggestion for the sequence
of steps for any port to a new platform.
1) Write a disassembler. For RISC platforms with orthogonal instruction
sets, this is pretty easy (about a day to get decent disassembly). If
the object format is not supported (ie. not 32-bit ELF/COFF or OMF), it
might take significantly longer.
2) Port the debugger. You'll be glad you did. If the platform is Linux
based, it should be real easy. If it's some other Unix, it still
shouldn't be too hard. If it's something altogether different, it could
take a while. If the debug format isn't supported (ie. not DWARF, that
will take additional time). The debugger will reuse the disassembler you
did earlier.
At this point, you should be able to remotely debug to your target
platform, and if it's Unix, it shouldn't be too hard to port the entire
debugger front end to it using the platform's native compiler. If the
only other debugging alternative is gdb, porting wd will save you tons
of time later on. These first two steps may be quite useful on their own.
3) Port the assembler. Again if it's a RISC platform, and if it doesn't
have a "smart" assembler like MIPS for instance (with tons of
pseudo-instructions), that's not such a huge amount of work. Again if
the object format is unsupported (not 32-bit ELF/COFF), expect
additional effort. The assembler doesn't have to be complete, but it
should be good enough to generate the few assembly routines for clib
(things like longjmp aren't really doable in C). The inline assembler
will be reused later by the C/C++ compiler, which may make interfacing
with system calls very easy (see bld/clib/linux/h/sysmips.h for an example).
4) Port the C front end. This should not be too difficult; the biggest
platform specific thing to worry about will be functions with variable
arguments, and it's almost a given those will cause headaches. The C
compiler will be an empty shell at this point, but you'll need it to
exercise the codegen.
5) Now comes the really hard part, the codegen. You'll reuse what you
learned earlier when porting the assembler. If the target is an
orthogonal RISC platform, you will be able to clone one of the existing
RISC codegens. If it's something weird or, god forbid, something as
awful as x86, you really have your work cut out for you. This part is by
far the most difficult because it requires understanding of how the
codegen works. Taking a quick look at bld/cg/doc/mipsnotes.txt may be a
good idea. Every CPU architecture seems to have its quirks (delay slots,
not so orthogonal instruction sets, alignment and/or operand size
restrictions, and who knows what sorts of other weirdness) and there are
no generic solutions. Note that vast swathes of the codegen won't
require any changes whatsoever as they're completely generic; the code
that translates intermediate code (sort of pseudo-assembly) is where the
effort will be concentrated.
6) Port the clib. Again if the target is a Linux or Unix platform, it's
probably not going to be terribly difficult. If it's something oddball
that doesn't even remotely resemble POSIX, expect trouble. This step
will probably overlap with the codegen port. Getting as far as
puts()-based hello world is not *that* difficult, but the fun starts
with printf(), and math stuff is guaranteed to be "interesting".
7) Port the linker. Same thing as earlier - if the object and
executable format is supported (ELF, PE, etc. etc.), most of the work's
done already. If it's something else, there's no telling how much effort
exactly it'll take.
By now you should be able to generate basic executables, at first using
syscalls directly and later using the clib. Now's where you will really
appreciate the debugger because the cg will be buggy and the programs
are going to die a lot.
8) Run (and pass) tests. At the end of this step, the compiler should
be able to pass the tests in bld/ctest/regress and - quite possibly with
extra tweaking - the tests in bld/clib/qa.
It may also be instructive to start cross compiling some utilities for
the target platform - disassembler, linker, etc. Once the port is solid
enough, it should be able to generate a functioning compiler. By the
time that compiler is good enough to compile itself and still work, you
should have a pretty solid codegen plus tools and basic runtime library
support.
9) Optionally continue with the C++ and perhaps F77 compiler and other
tools. The profiler is especially good candidate, and if you have a
debugger, you're almost done with the profiler. Most of the command line
tools are pretty easy to port, but the GUI tools are entirely different
kettle of fish. Porting all the GUI tools might conceivably require as
much effort as porting the compiler itself.
A lot of these steps can be done in parallel, for instance #1 and #3
are independent of each other. There are also two completely different
porting strategies: Either port the OW tools to the target platform
first, using the native compiler, or cross compile from a supported
platform. I'd recommend the latter, but it's a question of personal
preference. The host tools should be definitely solid, because otherwise
you'll be juggling way too many balls at the same time. Porting the
codegen/clib/linker/etc. all at the same time is hard enough. It is
recommended to use the target platform's tools at least in the initial
stages - eg. generate your own object files but use the existing linker.
This work in the other direction as well - it's possible to port eg. the
linker first and use existing tools to generate object files.
Needless to say, the above assumes that the target platform runs an
actual OS. If it's some kind of restricted embedded system, the work
will be in some ways easier (perhaps no need to port clib) and in other
ways much harder (far more difficult to test what you've done).
I should probably put this stuff in wiki at some point...
Michal
Sorry for being off the list for so long. As to why I won't get into.
What I would like to do is get the Watcom back to being able to
support the IBM mainframe architecture.

So with that I will get back reading this tread as well as others.
Michal Necasek
2007-11-09 22:57:04 UTC
Permalink
Post by Scott
Sorry for being off the list for so long. As to why I won't get into.
What I would like to do is get the Watcom back to being able to
support the IBM mainframe architecture.
That should be relatively simpler task as the S/370 codegen is still
there (bld/cg/s37), only not maintained for 20 years or so. Still, it
should be much easier to fix the existing code than write it from scratch.


Michal

Loading...