Discussion:
microsoft vs linux
(too old to reply)
muta...@gmail.com
2021-06-30 02:23:01 UTC
Permalink
Win32 executables, at least normal ones, do not have
environmental dependencies like particular segment
registers being set to certain values, or certain interrupt
vectors being set to certain values.

That means that an unprivileged program can set up
the necessary environment to satisfy the Win32
executable.

Linux programs on the other hand do INT 80H calls,
just as MSDOS programs do INT 21H calls. This
means the calling environment needs sufficient
privilege to set up at least one interrupt vector.

Sounds to me like Microsoft has the right approach,
giving maximum flexibility.

Perhaps it would have been EVEN better if Windows
executables accepted the "environment" (callbacks)
via a parameter on the stack, similar to UEFI, and
somewhat similar to AmigaOS, rather than the use of
DLLs.

Any thoughts?

BFN. Paul.
Branimir Maksimovic
2021-06-30 02:42:01 UTC
Permalink
Post by ***@gmail.com
Win32 executables, at least normal ones, do not have
environmental dependencies like particular segment
registers being set to certain values, or certain interrupt
vectors being set to certain values.
That means that an unprivileged program can set up
the necessary environment to satisfy the Win32
executable.
Linux programs on the other hand do INT 80H calls,
just as MSDOS programs do INT 21H calls. This
means the calling environment needs sufficient
privilege to set up at least one interrupt vector.
Linux has vsyscall and int 80h, for 32 bit programs.
one discovers vsyscall address at vector after envp.
OTOH in 64 bit environment it uses syscall instruction
on x86.
Post by ***@gmail.com
BFN. Paul.
muta...@gmail.com
2021-06-30 04:33:15 UTC
Permalink
Post by Branimir Maksimovic
Linux has vsyscall and int 80h, for 32 bit programs.
one discovers vsyscall address at vector after envp.
Ok, great, thanks.
Post by Branimir Maksimovic
OTOH in 64 bit environment it uses syscall instruction
on x86.
I didn't understand this. Can you explain please?

Thanks. Paul.
Branimir Maksimovic
2021-07-01 00:49:19 UTC
Permalink
Post by ***@gmail.com
Post by Branimir Maksimovic
OTOH in 64 bit environment it uses syscall instruction
on x86.
I didn't understand this. Can you explain please?
you have syscall instruction on x64_64
Post by ***@gmail.com
Thanks. Paul.
Scott Lurndal
2021-06-30 13:22:49 UTC
Permalink
Post by ***@gmail.com
Linux programs on the other hand do INT 80H calls,
No, they don't. Linux doesn't ever use the BIOS for anything.

The SYSCALL or SYSENTER instructions are used on modern x86 processors
by applications (or libraries, e.g. libc) that require services
from the operating system.

Linux hasn't used INT for over a decade.
James Harris
2021-06-30 16:19:48 UTC
Permalink
Post by Scott Lurndal
Post by ***@gmail.com
Linux programs on the other hand do INT 80H calls,
No, they don't. Linux doesn't ever use the BIOS for anything.
The Linux int 0x80 call is nothing to do with the BIOS.
--
James Harris
Frank Kotler
2021-06-30 22:58:03 UTC
Permalink
Post by Scott Lurndal
Post by ***@gmail.com
Linux programs on the other hand do INT 80H calls,
No, they don't. Linux doesn't ever use the BIOS for anything.
Hi Scott,
I feel really weird disagreeing with you! int 80h us not a BIOS
interrupt. It does still work in 32-bit programs - I use it all the time...

(to Paul)
"syscall" is an instruction... just like "int"...

Best,
Frank
muta...@gmail.com
2021-07-01 04:40:39 UTC
Permalink
Post by Frank Kotler
(to Paul)
"syscall" is an instruction... just like "int"...
Ok, thanks. Which means the caller needs to be privileged
enough to set up some table, right?

Something Win32 executables don't need to be able to do.

Does the Linux 80386 parameter after envp require the
caller to have ensured special tables be set up?

Thanks. Paul.
Frank Kotler
2021-07-01 05:21:05 UTC
Permalink
Post by ***@gmail.com
Post by Frank Kotler
(to Paul)
"syscall" is an instruction... just like "int"...
Ok, thanks. Which means the caller needs to be privileged
enough to set up some table, right?
No... I don't think so.
Post by ***@gmail.com
Something Win32 executables don't need to be able to do.
Does the Linux 80386 parameter after envp require the
caller to have ensured special tables be set up?
No, I don't think so.

I'm not sure, Paul, but I think your original premise may not be
correct. I do not think that Windows makes it any "easier" for an
executable than Linux. I haven't run Windows since win98, so I may not
be up-to-date... Does fs not point to "thread local storage"? (a
non-flat descriptor)? Does not Windows use an interrupt... int 0xE2 ???
" behind the scenes"?

I'm not certain, but I think you may be off-base here... interesting
question, in any case.

Best,
Frank
muta...@gmail.com
2021-07-01 08:03:26 UTC
Permalink
Post by Frank Kotler
I'm not sure, Paul, but I think your original premise may not be
correct. I do not think that Windows makes it any "easier" for an
Maybe my premise needs to be refined. Let's start with
a non-multitasking "hello world" program. Everything I
write is a glorified "hello world" (C90-compliant).
Post by Frank Kotler
executable than Linux. I haven't run Windows since win98, so I may not
be up-to-date... Does fs not point to "thread local storage"? (a
non-flat descriptor)?
It may be, but I am certain there is no manipulation or use
of "fs" in the Win32 executables I produce, because I know
what goes into every byte of code, which is how I know it
is all public domain, so my executables are totally public
domain.
Post by Frank Kotler
Does not Windows use an interrupt... int 0xE2 ???
" behind the scenes"?
I don't care if there are 50 billion INT calls and syscalls
and manipulation of hardware and segment register
manipulation so long as it happens OUTSIDE my
executable.

At least when I'm wearing my application programmer's hat,
which I am at the moment, looking for clean executables.

BFN. Paul.
Frank Kotler
2021-07-02 04:32:20 UTC
Permalink
On 07/01/2021 04:03 AM, ***@gmail.com wrote:
...
Post by ***@gmail.com
It may be, but I am certain there is no manipulation or use
of "fs" in the Win32 executables I produce, because I know
what goes into every byte of code,
Excellent!
...
Post by ***@gmail.com
I don't care if there are 50 billion INT calls and syscalls
and manipulation of hardware and segment register
manipulation so long as it happens OUTSIDE my
executable.
Okay. I can assure you that there is no "crap" in an ordinary Linux
executable. The int 80h vector, ect. are set up by the OS. well outside
of out executable. No special permissions.

We can discuss it further, but I don't think we need to...

I don't usually post here, but sometimes read the group.. "Hi" to all my
friends...

Best,
Frank
muta...@gmail.com
2021-07-02 06:14:26 UTC
Permalink
Post by Frank Kotler
Post by ***@gmail.com
It may be, but I am certain there is no manipulation or use
of "fs" in the Win32 executables I produce, because I know
what goes into every byte of code,
Excellent!
...
Post by ***@gmail.com
I don't care if there are 50 billion INT calls and syscalls
and manipulation of hardware and segment register
manipulation so long as it happens OUTSIDE my
executable.
Okay. I can assure you that there is no "crap" in an ordinary Linux
executable. The int 80h vector, ect. are set up by the OS. well outside
of out executable. No special permissions.
No, you don't get my point. "int 80h" inside my executable
*is* "crap". It requires the *caller* to have special
permissions (they need to ensure an interrupt vector
table exists).

It may not exist.

I want to run Linux executables from PDOS/386, running
as an unprivileged program running under Windows 10.
I don't have access to INT 80H so the executable will
fail (unless I was to somehow scan the executable and
zap them all into callbacks).

Whereas if I run Windows executables from PDOS/386,
running as an unprivileged program running under Linux,
I do not have this problem. Because the Win32 executables
(at least mine) that follow the kernel32/msvcrt rules, have
address stubs that are filled in at load time.

I can easily get PDOS/386 to load the Win32 executable,
redirect those stubs to myself, and it doesn't matter that
there is no kernel32, no msvcrt, no Windows, and Linux
has no clue whatsoever about anything that is happening.
No interrupt table is involved either, although PDOS/386
will (nominally *) call INT 80H to get access to Linux services.

BFN. Paul.


(*) Then we get to making PDOS clean by offloading BIOS
calls to another abstraction layer, and then it is only at
the BIOS level that INT 80H is (nominally **) done.


(**) Then we get to the next abstraction layer where the
BIOS is implemented by calling the functions provided
by the parameter after envp, rather than mandating an
interrupt table. Then Linux itself can be running
unauthorized, under perhaps MacOS.
Rod Pemberton
2021-07-02 10:07:15 UTC
Permalink
On Thu, 1 Jul 2021 23:14:26 -0700 (PDT)
Post by ***@gmail.com
Post by Frank Kotler
Post by ***@gmail.com
It may be, but I am certain there is no manipulation or use
of "fs" in the Win32 executables I produce, because I know
what goes into every byte of code,
Excellent!
...
Post by ***@gmail.com
I don't care if there are 50 billion INT calls and syscalls
and manipulation of hardware and segment register
manipulation so long as it happens OUTSIDE my
executable.
Okay. I can assure you that there is no "crap" in an ordinary Linux
executable. The int 80h vector, ect. are set up by the OS. well
outside of out executable. No special permissions.
No, you don't get my point. "int 80h" inside my executable
*is* "crap". It requires the *caller* to have special
permissions (they need to ensure an interrupt vector
table exists).
It may not exist.
...
Post by ***@gmail.com
I want to run Linux executables from PDOS/386, running
as an unprivileged program running under Windows 10.
I don't have access to INT 80H so the executable will
fail (unless I was to somehow scan the executable and
zap them all into callbacks).
You may wish to look at this old project. It directly runs Linux
executables under Windows. An old post of mine says it has an "int
0x80 syscall interface, DLL loader, and no POSIX layer".

LINE is not an emulator
https://sourceforge.net/projects/line/
--
What is hidden in the ground, when found, is hidden there again?
muta...@gmail.com
2021-07-02 10:15:35 UTC
Permalink
Post by ***@gmail.com
I want to run Linux executables from PDOS/386, running
as an unprivileged program running under Windows 10.
I don't have access to INT 80H so the executable will
fail (unless I was to somehow scan the executable and
zap them all into callbacks).
Note that that "desire" was for illustration purposes only.
I couldn't give a shit about crap like Linux.

What interests me is Win32-like S/370 executables
running under PDOS-generic (using FAT) running
under the current PDOS/3X0 (using CKD).

With all executables running at native speed on real
S/3X0 hardware.

That's largely embryonic. I'm not 100% sure what a
Win32-like S/370 executable is, and I don't have a
linker to produce the theoretical executable.

There is a S/370 assembler and linker written in
Python, about 30,000 lines, and I've made an attempt
at turning Python 3.3 into a C90-compliant executable,
a pre-requisite to working on either PDOS/386 or
PDOS/3X0. I have an executable built, but it produces
an internal error, likely due to one of the shortcuts I
took to get a build at all.

Someone else on the mainframe interested in Python
said he would take a look, and then went quiet.

I have a lot of paths open at any one time. But some
of them do indeed close. I have a Windows C compiler
with source (gccwin, 3.2.3) not dependent on Cygwin
crap, buildable from source. And in fact, the only
compiler that has been ported to PDOS/386. It only
became available in a form that passed my integrity
checks about 23 hours and 15 minutes ago, with a
lot of updates to pdos.org during the process.

There is method to the madness. Or there is madness.
Take your pick.
You may wish to look at this old project. It directly runs Linux
executables under Windows. An old post of mine says it has an "int
0x80 syscall interface, DLL loader, and no POSIX layer".
LINE is not an emulator
https://sourceforge.net/projects/line/
I checked out the link and stopped here:

LINE Is Not an Emulator. LINE executes unmodified Linux applications on Windows by intercepting Linux system calls.


Intercepting Linux system calls, presumably by inserting
something into the INT 80H vector, requires privilege, the
thing I was illustrating I wanted to avoid.

BFN. Paul.
Scott Lurndal
2021-07-02 15:42:49 UTC
Permalink
Post by ***@gmail.com
Post by ***@gmail.com
I want to run Linux executables from PDOS/386, running
as an unprivileged program running under Windows 10.
I don't have access to INT 80H so the executable will
fail (unless I was to somehow scan the executable and
zap them all into callbacks).
Note that that "desire" was for illustration purposes only.
I couldn't give a shit about crap like Linux.
And the rest of us don't give a shit about useless crap like PDOS,
FAT, BIOS or S/370.
Rod Pemberton
2021-07-03 02:26:43 UTC
Permalink
On Fri, 02 Jul 2021 15:42:49 GMT
Post by Scott Lurndal
Post by ***@gmail.com
Post by ***@gmail.com
I want to run Linux executables from PDOS/386, running
as an unprivileged program running under Windows 10.
I don't have access to INT 80H so the executable will
fail (unless I was to somehow scan the executable and
zap them all into callbacks).
Note that that "desire" was for illustration purposes only.
I couldn't give a shit about crap like Linux.
And the rest of us don't give a shit
Honestly, I don't think that Paul's comments were intended to be as
harsh as you've apparently been taking them. He's downunder.
Post by Scott Lurndal
And the rest of us don't give a shit about useless crap like PDOS,
FAT, BIOS or S/370.
So, Scott, are you working on your own OS? I apparently missed
your mention of it. So, what are you planning to do? You're here for
a good reason, right?


Personally, I'm in the world of EXT4 and BIOS and 64-bit (Linux).
Although, I'm still in the world of FAT and BIOS and 32-bit (MS-DOS).
No UEFI, yet though, which will be a total mess if there is no BIOS
support anymore via CSM. I'd doubt that most others here have moved to
UEFI, as you're about the only one who mentions it. As for S/370, I
have no idea what that is, other than it's IBM. As for PDOS, I know
it's a DOS-like OS that Paul has been working on for a long time,
off-and-on again. Nothing wrong with that, IMO. It's a personal and
intellectual challenge. Other people have golf.


I do understand your perspective. Tool did say in their song A-Enema
(AEnema), "Yeah, f--k retro anything," ... as well as wishing that the
"hopeless f--king hole" called Los Angeles would be flushed out (via an
implicit enema) into the Arizona Bay (the sea water offshore of Arizona
once California sinks) via an AEnima (with 'i' not 'e') event which is
an apocalyptic event of sinking underwater like Atlantis, and also the
name of their album.


We - the rest of us, the 49% of America not dumb enough to put an
incompetent vegetable and radical Muslim terrorist into the White House
- can solidly say the same, "flush it all away", but about the whole of
California, and it's radically politically biased socialist government
and it's overbearing paternalistic censorial suppressive tech
companies, can't we? They don't represent America or it's values, just
a very, very limited subset of American values, but act as if everyone
else should obey them and their misguided beliefs ... Bigots.
--
What is hidden in the ground, when found, is hidden there again?
Scott Lurndal
2021-07-03 15:07:52 UTC
Permalink
Post by Rod Pemberton
On Fri, 02 Jul 2021 15:42:49 GMT
Post by Scott Lurndal
Post by ***@gmail.com
Post by ***@gmail.com
I want to run Linux executables from PDOS/386, running
as an unprivileged program running under Windows 10.
I don't have access to INT 80H so the executable will
fail (unless I was to somehow scan the executable and
zap them all into callbacks).
Note that that "desire" was for illustration purposes only.
I couldn't give a shit about crap like Linux.
And the rest of us don't give a shit
Honestly, I don't think that Paul's comments were intended to be as
harsh as you've apparently been taking them. He's downunder.
Perhaps, but I think his hatred for linux has been made clear over
the past years.
Post by Rod Pemberton
Post by Scott Lurndal
And the rest of us don't give a shit about useless crap like PDOS,
FAT, BIOS or S/370.
Perhaps a bit tongue in cheek.
Post by Rod Pemberton
So, Scott, are you working on your own OS? I apparently missed
your mention of it. So, what are you planning to do? You're here for
a good reason, right?
I've worked on five new operating systems over the last forty
years. They've all been for state of the art hardware (and
state of the art software, I wrote an early pre-vmware hypervisor
in the late 90's, for example). Most were for very large systems
(mainframes in the 80's, massively parallel distributed systems
in the 90's, linux in the 2000s and a distributed shared memory
hypervisor in the late 2000s).
Post by Rod Pemberton
Personally, I'm in the world of EXT4 and BIOS and 64-bit (Linux).
Although, I'm still in the world of FAT and BIOS and 32-bit (MS-DOS).
No UEFI, yet though, which will be a total mess if there is no BIOS
support anymore via CSM.
The product I currently work on is 64-bit (ARMv9) with UEFI and/or
UBOOT (depending on customer) and we provide the firmware. Our most
recent product is a large DPU with more 24 cores, 100Gb ethernet,
dozens of hardware coprocessors (including machine learning), a
security coprocessor and a management coprocessor.

It generally runs Linux (DPDK is the primary application).
Post by Rod Pemberton
I'd doubt that most others here have moved to
UEFI, as you're about the only one who mentions it.
I get the impression that most here are more interested in
legacy systems from the 1970s/1980's - i.e. systems they
grew up on.

I'd much rather develop operating systems for state-of-the-art
hardware (which is why I always worked for system manufacturers
or processor design companies).

I have a nice simulator for Burroughs mainframes (for which I
wrote parts of the operating system - including the code that
took the system from power-off to idle) that I play
with for a hobby, but these days, I'd much rather go walking
on the beach.
Post by Rod Pemberton
I do understand your perspective. Tool did say in their song A-Enema
(AEnema), "Yeah, f--k retro anything," ... as well as wishing that the
"hopeless f--king hole" called Los Angeles would be flushed out (via an
implicit enema) into the Arizona Bay (the sea water offshore of Arizona
once California sinks) via an AEnima (with 'i' not 'e') event which is
an apocalyptic event of sinking underwater like Atlantis, and also the
name of their album.
A common misconception (The Burroughs plant was in Pasadena at the
time). The land moves laterally along the fault.
Post by Rod Pemberton
We - the rest of us, the 49% of America not dumb enough to put an
incompetent vegetable and radical Muslim terrorist into the White House
- can solidly say the same, "flush it all away", but about the whole of
California, and it's radically politically biased socialist government
and it's overbearing paternalistic censorial suppressive tech
companies, can't we? They don't represent America or it's values,
So you digress into a ridiculous political diatribe.

So much for rational thought.
Rod Pemberton
2021-07-04 07:16:40 UTC
Permalink
On Sat, 03 Jul 2021 15:07:52 GMT
Post by Scott Lurndal
So you digress into a ridiculous political diatribe.
So much for rational thought.
Are you saying political discourse is irrational or just off-topic? ;-)


BTW, with that resume, you're likely to have the most and best success
of anyone here with developing an OS. IIRC, wolfgang is the only one
with a commercially successful OS. Most of the people who've come and
gone from here over the past 15 years have never reached the point of
open source OS or a commercial product.

Paul has recently returned after about a 10 year hiatus.
--
What is hidden in the ground, when found, is hidden there again?
wolfgang kern
2021-07-03 12:22:53 UTC
Permalink
On 02.07.2021 17:42, Scott Lurndal wrote:
...
Post by Scott Lurndal
Post by ***@gmail.com
Note that that "desire" was for illustration purposes only.
I couldn't give a shit about crap like Linux.
And the rest of us don't give a shit about useless crap like PDOS,
FAT, BIOS or S/370.
Amen.
__
wolfgang
Joe Monk
2021-07-03 13:43:12 UTC
Permalink
Post by Scott Lurndal
And the rest of us don't give a shit about useless crap like PDOS,
FAT, BIOS or S/370.
You forgot EBCDIC ANSI.

Joe
Rod Pemberton
2021-07-03 01:43:42 UTC
Permalink
On Fri, 2 Jul 2021 03:15:35 -0700 (PDT)
Post by ***@gmail.com
You may wish to look at this old project. It directly runs Linux
executables under Windows. An old post of mine says it has an "int
0x80 syscall interface, DLL loader, and no POSIX layer".
LINE is not an emulator
https://sourceforge.net/projects/line/
LINE Is Not an Emulator. LINE executes unmodified Linux applications
on Windows by intercepting Linux system calls.
Intercepting Linux system calls, presumably by inserting
something into the INT 80H vector, requires privilege, the
thing I was illustrating I wanted to avoid.
Look, I'm not entirely sure of the mechanism, but I think LINE is a
user space app, i.e., it wouldn't have the necessary privilege to
intercept INT 80H. Hence, I thought it might be worth a look at their
technique. Maybe, Windows has some function that is being used.
--
What is hidden in the ground, when found, is hidden there again?
muta...@gmail.com
2021-07-03 01:07:17 UTC
Permalink
Post by Rod Pemberton
Look, I'm not entirely sure of the mechanism, but I think LINE is a
user space app, i.e., it wouldn't have the necessary privilege to
intercept INT 80H. Hence, I thought it might be worth a look at their
technique. Maybe, Windows has some function that is being used.
Ok, good point. If Windows is willing to (at its whim) allow
an app to set INT 80H, then that would indeed work.

PDOS/386 also allows apps to trash interrupt vectors.

But ideally, an executable should not be relying on the grace
of the calling environment to give it access to an interrupt
(and there may be conflicts with interrupt numbers too).

It is better if the executable just quietly executes callbacks,
in one form or another, so that no-one with any authority
has any idea whatsoever what is happening.

THAT is my definition of a "clean executable", and Win32
console mode programs, at least the ones I produce, fit
that description, even though they are not *necessarily*
my preferred design.

Rumor has it that Linux supports the same thing via the
parameter after envp, which is great, and *possibly* even
superior to Win32, so I'll put that on my "to do" list for
changes to PDPCLIB to remove the INT 80H in the Linux target.

BFN. Paul.
Rod Pemberton
2021-07-01 09:47:43 UTC
Permalink
On Thu, 1 Jul 2021 01:21:05 -0400
Post by Frank Kotler
Post by ***@gmail.com
Post by Frank Kotler
(to Paul)
"syscall" is an instruction... just like "int"...
Ok, thanks. Which means the caller needs to be privileged
enough to set up some table, right?
No... I don't think so.
For x86, LIDT, LGDT are unprivileged instructions only in real-mode.
LIDT, LGDT are privileged instructions in protected-mode. You must be
in Ring-0 to use LIDT, LGDT in protected-mode.

I.e., if you're executing under Windows or Linux etc, then, "Yes" you
need privilege to set up an interrupt table via LIDT. In other words,
you can't set up your own interrupt table if you "wish to run PDOS as an
unprivileged kernel" under Linux or Windows etc.
--
What is hidden in the ground, when found, is hidden there again?
Rod Pemberton
2021-07-01 09:53:33 UTC
Permalink
On Thu, 1 Jul 2021 04:47:43 -0500
Post by Rod Pemberton
On Thu, 1 Jul 2021 01:21:05 -0400
Post by Frank Kotler
Post by ***@gmail.com
Post by Frank Kotler
(to Paul)
"syscall" is an instruction... just like "int"...
Ok, thanks. Which means the caller needs to be privileged
enough to set up some table, right?
No... I don't think so.
For x86, LIDT, LGDT are unprivileged instructions only in real-mode.
LIDT, LGDT are privileged instructions in protected-mode. You must be
in Ring-0 to use LIDT, LGDT in protected-mode.
...
Post by Rod Pemberton
I.e., if you're executing under Windows or Linux etc, then, "Yes" you
need privilege to set up an interrupt table via LIDT. In other words,
you can't set up your own interrupt table if you "wish to run PDOS as
an unprivileged kernel" under Linux or Windows etc.
Replied to Frank but was talking to Paul here. Sorry.
--
What is hidden in the ground, when found, is hidden there again?
Branimir Maksimovic
2021-07-01 08:54:11 UTC
Permalink
Post by ***@gmail.com
Post by Frank Kotler
(to Paul)
"syscall" is an instruction... just like "int"...
Ok, thanks. Which means the caller needs to be privileged
enough to set up some table, right?
Nope, no privileges needed.
Post by ***@gmail.com
Something Win32 executables don't need to be able to do.
Does the Linux 80386 parameter after envp require the
caller to have ensured special tables be set up?
no.
Post by ***@gmail.com
Thanks. Paul.
Scott Lurndal
2021-07-01 18:22:44 UTC
Permalink
Post by Frank Kotler
Post by Scott Lurndal
Post by ***@gmail.com
Linux programs on the other hand do INT 80H calls,
No, they don't. Linux doesn't ever use the BIOS for anything.
Hi Scott,
I feel really weird disagreeing with you! int 80h us not a BIOS
interrupt. It does still work in 32-bit programs - I use it all the time...
Good point, It's been over a decade since I used any 32-bit linux system
or application.
James Harris
2021-06-30 16:25:39 UTC
Permalink
Post by ***@gmail.com
Win32 executables, at least normal ones, do not have
environmental dependencies like particular segment
registers being set to certain values, or certain interrupt
vectors being set to certain values.
That means that an unprivileged program can set up
the necessary environment to satisfy the Win32
executable.
Linux programs on the other hand do INT 80H calls,
just as MSDOS programs do INT 21H calls. This
means the calling environment needs sufficient
privilege to set up at least one interrupt vector.
It's not the calling environment which sets up the interrupt vector. The
kernel does that.

As others have said, the Linux kernel can be called in different ways.
Int 0x80 is just one of them. These days sysenter and syscall
instructions are normally used as they are faster. That said, ABI
compatibility is generally maintained so you should be able to call the
Linux kernel with the int if you wish.

It looks as though



would explain more.
--
James Harris
muta...@gmail.com
2021-06-30 21:48:17 UTC
Permalink
Post by James Harris
Post by ***@gmail.com
Linux programs on the other hand do INT 80H calls,
just as MSDOS programs do INT 21H calls. This
means the calling environment needs sufficient
privilege to set up at least one interrupt vector.
It's not the calling environment which sets up the interrupt vector. The
kernel does that.
I wish to run PDOS as an unprivileged kernel. You can
see proof of concept here:

https://sourceforge.net/p/pdos/gitcode/ci/master/tree/bios/bios.c

Any application that does any interrupt won't work.

Win32 executables should work, although I haven't
definitively proven that DLLs can be handled.

BFN. Paul.
James Harris
2021-07-01 06:45:45 UTC
Permalink
Post by ***@gmail.com
Post by James Harris
Post by ***@gmail.com
Linux programs on the other hand do INT 80H calls,
just as MSDOS programs do INT 21H calls. This
means the calling environment needs sufficient
privilege to set up at least one interrupt vector.
It's not the calling environment which sets up the interrupt vector. The
kernel does that.
I wish to run PDOS as an unprivileged kernel. You can
https://sourceforge.net/p/pdos/gitcode/ci/master/tree/bios/bios.c
I am not sure what's happening in that - and I've not been following the
details of what you are doing - but in principle if you have the calling
sequence as

app --> yourcode --> something privileged

then (unless the privileged code will reflect invocations to yourcode)
those apps could not use software interrupts to get to yourcode but you
could have libraries which the apps can call. Ideally, the app would say
something like

pdos_write(chan, "Hello", 5)

where pdos_write would be in a library you've supplied which will, if
necessary, go on to invoke the relevant routine in yourcode.

Ideally, IMO, pdos_write would be dynamically linked so it would not
have to be part of the app binary.
Post by ***@gmail.com
Any application that does any interrupt won't work.
Win32 executables should work, although I haven't
definitively proven that DLLs can be handled.
The bottom line is that, AISI, apps should only have to include standard
calls (no ints, no sysenters etc), and it is the OS or library which
should supply the code which they call. That's not unusual. I think it's
how OSes normally make their service routines available.
--
James Harris
muta...@gmail.com
2021-07-01 08:09:38 UTC
Permalink
Post by James Harris
app --> yourcode --> something privileged
then (unless the privileged code will reflect invocations to yourcode)
those apps could not use software interrupts to get to yourcode but you
could have libraries which the apps can call. Ideally, the app would say
something like
pdos_write(chan, "Hello", 5)
where pdos_write would be in a library you've supplied which will, if
necessary, go on to invoke the relevant routine in yourcode.
Ideally, IMO, pdos_write would be dynamically linked so it would not
have to be part of the app binary.
Yes, this is exactly what I want - so long as pdos_write is
in a dynamic library (or probably even better, a UEFI-like
library provided at program entry), all is fine.

It's only when pdos_write is statically linked that the
executable suddenly gets an INT hardwired into it,
and suddenly the caller needs to have ensured that
an appropriate interrupt vector exists. Which may
be impossible, because the caller may be an
unprivileged version of PDOS.
Post by James Harris
Post by ***@gmail.com
Any application that does any interrupt won't work.
Win32 executables should work, although I haven't
definitively proven that DLLs can be handled.
The bottom line is that, AISI, apps should only have to include standard
calls (no ints, no sysenters etc), and it is the OS or library which
should supply the code which they call. That's not unusual. I think it's
how OSes normally make their service routines available.
Sure, that is not in dispute. It's whether the library is
statically linked and contains an interrupt, or in the case
of AmigaOS, an expectation of address 4 being set to
something special. Or directly manipulating hardware.
Or setting or inspecting segment registers.

BFN. Paul.
James Harris
2021-07-03 08:03:21 UTC
Permalink
Post by ***@gmail.com
Post by James Harris
app --> yourcode --> something privileged
then (unless the privileged code will reflect invocations to yourcode)
those apps could not use software interrupts to get to yourcode but you
could have libraries which the apps can call. Ideally, the app would say
something like
pdos_write(chan, "Hello", 5)
where pdos_write would be in a library you've supplied which will, if
necessary, go on to invoke the relevant routine in yourcode.
Ideally, IMO, pdos_write would be dynamically linked so it would not
have to be part of the app binary.
Yes, this is exactly what I want - so long as pdos_write is
in a dynamic library
Then I cannot see the problem. If you produce pdos_write you can have it
invoke whatever OS functions are needed - including invoking code in
your own OS - in whatever ways are needed so there would be no need for
a software interrupt.
Post by ***@gmail.com
(or probably even better, a UEFI-like
library provided at program entry), all is fine.
It's best to avoid reliance on both BIOS and UEFI as neither is
universally available. You will have less dependence on certain hardware
if you can decouple your OS from both of them.

If possible, just use them to get your OS started.
Post by ***@gmail.com
It's only when pdos_write is statically linked that the
executable suddenly gets an INT hardwired into it,
and suddenly the caller needs to have ensured that
an appropriate interrupt vector exists. Which may
be impossible, because the caller may be an
unprivileged version of PDOS.
Post by James Harris
Post by ***@gmail.com
Any application that does any interrupt won't work.
Win32 executables should work, although I haven't
definitively proven that DLLs can be handled.
The bottom line is that, AISI, apps should only have to include standard
calls (no ints, no sysenters etc), and it is the OS or library which
should supply the code which they call. That's not unusual. I think it's
how OSes normally make their service routines available.
Sure, that is not in dispute. It's whether the library is
statically linked and contains an interrupt, or in the case
of AmigaOS, an expectation of address 4 being set to
something special. Or directly manipulating hardware.
Or setting or inspecting segment registers.
Perhaps pdos_write should not include an INT instruction. The call flow
could be

app --> pdos_write --> write handler

where the write handler is called, if necessary, by pdos_write in order
to do whatever is needed to effect a write. What it would do would
depend on the facilities of the machine, and you'd have a write handler
for BIOS, a write handler for Windows, a write handler for Linux, a
write handler for Amiga, etc. Then your pdos_write - and hence any app
which uses it - would work on any of them, though you'd need to supply
the different write handlers.
--
James Harris
muta...@gmail.com
2021-07-03 09:14:58 UTC
Permalink
Post by James Harris
Then I cannot see the problem. If you produce pdos_write you can have it
invoke whatever OS functions are needed - including invoking code in
your own OS - in whatever ways are needed so there would be no need for
a software interrupt.
Correct. There is no problem. I was just highlighting the
same thing you highlighted with your own code - for
some reason both of us ended up with Windows
executables that were totally clean, no INT instructions,
and both of us ended up with dirty Linux executables,
that contain INT instructions.

Now that I know that it is apparently possible to move
the INT instructions out of a Linux executable, I know
that Linux can be made clean too.

I'm not sure your choice of write() is correct though.
That is a library function which may be statically linked.
What is important is whether write() calls __syscall_write()
or whatever that is vectored in from the parameter after
envp rather than doing an INT 80H.
Post by James Harris
Post by ***@gmail.com
(or probably even better, a UEFI-like
library provided at program entry), all is fine.
It's best to avoid reliance on both BIOS and UEFI as neither is
universally available. You will have less dependence on certain hardware
if you can decouple your OS from both of them.
You missed my point above. My point was that UEFI
provides a parameter to the executable at startup
rather than using INT instructions like the BIOS, or
Windows-style DLLs.

Putting that aside, I agree that a bios-equivalent
layer should exist between the hardware and the
OS and it shouldn't be exactly bios or exactly UEFI.

In fact, I believe it should simply be a C90 library!
If you're going to have an API anyway, why not make
it use identical function names to C90? There is
still adjustment required because you won't be doing
printf() directly, it would be nonbios->printf() etc.
I have proof of concept of that already in PDOS in
the "bios" directory.
Post by James Harris
If possible, just use them to get your OS started.
Ok, I disagree with this. The BIOS/UEFI exists to give
you the hardware independence. I don't think an OS
should directly access the hardware, and I don't think
MSDOS does. So the nonbios layer above should still
call one of bios/uefi.

Is that a problem?

If it is a problem, then I think the proper solution is to
buy a computer that can have SeaBIOS flashed, and
make any required adjustments to SeaBIOS rather than
compensating for manufacturing deficiencies in the
OS.

At least, I think we, and Apple, have this luxury. Microsoft
probably needs to compensate for BIOS deficiencies, as
the manufacturer is relying on that in some sort of
symbiotic relationship. That's just speculation though.
Post by James Harris
Perhaps pdos_write should not include an INT instruction. The call flow
could be
app --> pdos_write --> write handler
where the write handler is called, if necessary, by pdos_write in order
to do whatever is needed to effect a write. What it would do would
depend on the facilities of the machine, and you'd have a write handler
for BIOS, a write handler for Windows, a write handler for Linux, a
write handler for Amiga, etc. Then your pdos_write - and hence any app
which uses it - would work on any of them, though you'd need to supply
the different write handlers.
It is my intention that with the C90-like non-bios I mentioned
above, that the non-bios would simply translate a nonbios->printf
into an actual printf provided by whatever C compiler/library was
being used on some arbitrary host like AmigaOS.

Note that with AmigaOS in particular there is not any real
option of replacing AmigaOS. I have to run PDOS
(which will be Amiga-PDOS) under it. There is no problem
presenting a C:\ prompt to the user, but the C drive will
simply be a flat file up to 2 GiB that is accessed by the
standard non-bios Amiga OS C program.

There is also no problem providing a FAT file system (on
that emulated disk), and no problem calling my executables
fred.exe or whatever.

But fred.exe would be an almost-standard AmigaOS C program.

I say almost-standard because I can only run programs that
are aware of the D7 extension that provides an override to
address 4. Because AmigaPDOS will not have access to
address 4. That is owned by AmigaOS.

All PDPCLIB-based programs are D7-extension-aware.

But as usual, currently I believe ONLY PDPCLIB-based
programs are D7-extension-aware. :-)

The D7 extension was thrashed out with people over on
an Amiga forum. They weren't particularly impressed, but
they did help me select a register and explain why that
one was most appropriate for what I was trying to do.

BTW, it was only over on the Amiga forum where someone
explained to me that the BIOS exists to abstract the
hardware. And it was only there that I learnt about address
4 on the Amiga, and a different way of obtaining OS
services. Before that it was always INT/SVC/trap for me.

I did know about z/OS Unix having pointers in the CVT,
but for some reason that didn't have the required impact
on me.

It is the Amiga that got me to come up with PDOS-generic
and nearly abandon PDOS/386. I literally did abandon
PDOS/386 - I told a Slovakian that he could do whatever
he wanted in "src" - I had lost interest in it. But later I
realized that there was no harm continuing it until
conclusion before refocusing on PDOS-generic.

PDOS-generic should run under PDOS/3X0 and
PDOS/386 (and Windows and Linux) while waiting
for a more sophisticated non-bios to be loaded as
part of the PDOS/386 boot sequence on real
hardware.

BFN. Paul.
Rod Pemberton
2021-07-01 09:46:50 UTC
Permalink
On Thu, 1 Jul 2021 07:45:45 +0100
Post by James Harris
Post by ***@gmail.com
Any application that does any interrupt won't work.
Win32 executables should work, although I haven't
definitively proven that DLLs can be handled.
The bottom line is that, AISI, apps should only have to include
standard calls (no ints, no sysenters etc), and it is the OS or
library which should supply the code which they call. That's not
unusual. I think it's how OSes normally make their service routines
available.
If the OS provided the OS API via function calls instead of interrupts,
then he could possibly call them directly, depending on OS privileges,
and if desired, he could definitely emulate them. Interrupts act as a
barrier to those functions as privilege is required to set up an
interrupt table, or or OS control is required.

So, with a Win32 executable, he suspects he call provide the OS
functions, if they're unavailable for his host environment, since a
Win32 executable apparently calls functions directly instead of using
software interrupts.
--
What is hidden in the ground, when found, is hidden there again?
Rod Pemberton
2021-07-01 09:51:17 UTC
Permalink
On Thu, 1 Jul 2021 04:46:50 -0500
Post by Rod Pemberton
On Thu, 1 Jul 2021 07:45:45 +0100
Post by James Harris
Post by ***@gmail.com
Any application that does any interrupt won't work.
Win32 executables should work, although I haven't
definitively proven that DLLs can be handled.
The bottom line is that, AISI, apps should only have to include
standard calls (no ints, no sysenters etc), and it is the OS or
library which should supply the code which they call. That's not
unusual. I think it's how OSes normally make their service routines
available.
If the OS provided the OS API via function calls instead of
interrupts, then he could possibly call them directly, depending on
OS privileges, and if desired, he could definitely emulate them.
Interrupts act as a barrier to those functions as privilege is
required to set up an interrupt table, or or OS control is required.
So, with a Win32 executable, he suspects he call provide the OS
functions, if they're unavailable for his host environment, since a
Win32 executable apparently calls functions directly instead of using
software interrupts.
... he suspects he can call the provided OS ...
--
What is hidden in the ground, when found, is hidden there again?
James Harris
2021-07-03 08:23:41 UTC
Permalink
Post by Rod Pemberton
On Thu, 1 Jul 2021 07:45:45 +0100
Post by James Harris
Post by ***@gmail.com
Any application that does any interrupt won't work.
Win32 executables should work, although I haven't
definitively proven that DLLs can be handled.
The bottom line is that, AISI, apps should only have to include
standard calls (no ints, no sysenters etc), and it is the OS or
library which should supply the code which they call. That's not
unusual. I think it's how OSes normally make their service routines
available.
If the OS provided the OS API via function calls instead of interrupts,
then he could possibly call them directly, depending on OS privileges,
and if desired, he could definitely emulate them. Interrupts act as a
barrier to those functions as privilege is required to set up an
interrupt table, or or OS control is required.
You and I may be of the same opinion on this. I've not been following
everything that Paul is trying to do but ISTM sensible for an OS to
provide functions for an app to call to invoke any the OS's services.
Then those functions can invoke the OS proper in whatever way is needed.

In addition, I'd personally prefer such functions to be linked
dynamically so that the application binary will work in different
environments.
Post by Rod Pemberton
So, with a Win32 executable, he suspects he call provide the OS
functions, if they're unavailable for his host environment, since a
Win32 executable apparently calls functions directly instead of using
software interrupts.
I was a bit puzzled by that but then I looked back at some primer code I
wrote years ago when I was trying to find out how to call Linux and
Windows. Whatever I based the code on did, indeed, recommend calling
Linux using an INT instruction.

Here's the Linux code and you can see the INT call within it.

http://codejar.pldev.org/aen/linux_stdout.nasm

By contrast, here's the Windows code and you can see that it invokes the
OS using a normal call instruction.

http://codejar.pldev.org/aen/windows_stdout.nasm

The latter code takes a better approach. It is more flexible, leaves the
app binary holding only app code, and means that the app can invoke OS
functions simply with normal function calls.

As a bonus it even specifies which DLL to get each entry point from.

That said, if I was writing the Linux code now I would look into how to
invoke the write system call via the write syscall function

https://man7.org/linux/man-pages/man2/write.2.html

and how to get it to be pulled in by dynamic linking.
--
James Harris
Scott Lurndal
2021-07-03 17:32:45 UTC
Permalink
Post by James Harris
Post by Rod Pemberton
On Thu, 1 Jul 2021 07:45:45 +0100
Post by James Harris
Post by ***@gmail.com
Any application that does any interrupt won't work.
Win32 executables should work, although I haven't
definitively proven that DLLs can be handled.
The bottom line is that, AISI, apps should only have to include
standard calls (no ints, no sysenters etc), and it is the OS or
library which should supply the code which they call. That's not
unusual. I think it's how OSes normally make their service routines
available.
If the OS provided the OS API via function calls instead of interrupts,
then he could possibly call them directly, depending on OS privileges,
and if desired, he could definitely emulate them. Interrupts act as a
barrier to those functions as privilege is required to set up an
interrupt table, or or OS control is required.
You and I may be of the same opinion on this. I've not been following
everything that Paul is trying to do but ISTM sensible for an OS to
provide functions for an app to call to invoke any the OS's services.
Then those functions can invoke the OS proper in whatever way is needed.
In addition, I'd personally prefer such functions to be linked
dynamically so that the application binary will work in different
environments.
Post by Rod Pemberton
So, with a Win32 executable, he suspects he call provide the OS
functions, if they're unavailable for his host environment, since a
Win32 executable apparently calls functions directly instead of using
software interrupts.
I was a bit puzzled by that but then I looked back at some primer code I
wrote years ago when I was trying to find out how to call Linux and
Windows. Whatever I based the code on did, indeed, recommend calling
Linux using an INT instruction.
Here's the Linux code and you can see the INT call within it.
http://codejar.pldev.org/aen/linux_stdout.nasm
Modern Linux applications almost _never_ have INT instructions.(or SYSCALL
or SYSENTER isntructions) in them. Even 32-bit applications.

The INT/SYSCALL instructions are in the libc shared object, the applications
simply call indirectly through a global pointer table into libc. LIBC will
take care of any interactions with the operating system isolating the
application from the operating system.

Therefore, to run a linux application on a foreign operating system
simply requires a version of libc that uses the foreign operating system
interface instructions (INT, Call Gate, SYSENTER or SYSCALL).

The above is true for dynamically linked applications. Statically linked
applications (which are rather rare) will include the required libc
function code in the ELF executable itself and thus may not be portable
to operating systems with different methods of communicating with the
operating system (or any higher privileged ring of execution).
Post by James Harris
https://man7.org/linux/man-pages/man2/write.2.html
and how to get it to be pulled in by dynamic linking.
That's exactly what happens. The application includes
the proper header file and codes a call to the write
function and links against libc. When executed,
it will call through a vector of APIs
into the system C library (libc) which then communicates
to the operating system, if required.
muta...@gmail.com
2021-07-04 01:26:05 UTC
Permalink
Post by Scott Lurndal
The INT/SYSCALL instructions are in the libc shared object, the applications
simply call indirectly through a global pointer table into libc.
And the global pointer is accessed via the parameter
after envp?

And other languages (Fortran etc) (can) make use of that
same pointer?

If so, that's exactly what I want.

And then I want PDPCLIB to be converted into a replacement
for libc, in the same way that Alica turned PDPCLIB into a
replacement for msvcrt.dll.

BFN. Paul.
Scott Lurndal
2021-07-05 15:29:05 UTC
Permalink
Post by ***@gmail.com
Post by Scott Lurndal
The INT/SYSCALL instructions are in the libc shared object, the applications
simply call indirectly through a global pointer table into libc.
And the global pointer is accessed via the parameter
after envp?
The application is encapsulated in a ELF (Extensible Linkage Format)
file. The ELF file includes two memory-resident data structures
called the PLT (Procedure Linkage Table) and the GOT (Global Offset Table).

The PLT is a vector of function pointers that the application uses to
access the shared library functions.

The GOT is a vector of data pointers to global data provided by the
shared object.

When a dynamically linked ELF executable is executed, a special shim
library (called the run-time loader - RTLD) is first loaded. It then
loads the appropriate sections (text/data/bss) from the ELF into memory
and locates the dynamic section in the ELF file. The dynamic section lists
all the dynamic dependencies (e.g. shared objects) that are required
to satisfy the external dependencies of the applications (e.g. POSIX
interfaces such as read, write, lseek, et alia).

While loading the shared objects on behalf of the application, the RTLD
will fill in the GOT and PLT tables with the virtual addresses that the
shared objects are loaded at (they can be different from run to run
and each application will load the shared objects at different virtual
addresses in the application).

The application then branches through the PLT to get to 'write', 'read',
'open', 'fopen', 'fclose', 'printf' etc.

Accesses to global data provided by the shared objects (e.g. certain
external global variables supported by the API supplied by the shared
object) is indirectly provided via the GOT.
Post by ***@gmail.com
And other languages (Fortran etc) (can) make use of that
same pointer?
Yes, the ELF files and run-time linking capabilities are independent
of the source language.
Scott Lurndal
2021-07-05 19:01:53 UTC
Permalink
Post by Scott Lurndal
Post by ***@gmail.com
Post by Scott Lurndal
The INT/SYSCALL instructions are in the libc shared object, the applications
simply call indirectly through a global pointer table into libc.
And the global pointer is accessed via the parameter
after envp?
The application is encapsulated in a ELF (Extensible Linkage Format)
file. The ELF file includes two memory-resident data structures
called the PLT (Procedure Linkage Table) and the GOT (Global Offset Table).
The PLT is a vector of function pointers that the application uses to
access the shared library functions.
The GOT is a vector of data pointers to global data provided by the
shared object.
When a dynamically linked ELF executable is executed, a special shim
library (called the run-time loader - RTLD) is first loaded. It then
loads the appropriate sections (text/data/bss) from the ELF into memory
and locates the dynamic section in the ELF file. The dynamic section lists
all the dynamic dependencies (e.g. shared objects) that are required
to satisfy the external dependencies of the applications (e.g. POSIX
interfaces such as read, write, lseek, et alia).
While loading the shared objects on behalf of the application, the RTLD
will fill in the GOT and PLT tables with the virtual addresses that the
shared objects are loaded at (they can be different from run to run
and each application will load the shared objects at different virtual
addresses in the application).
I should point out that the PLT entries can either be bound at
startup or can be lazily bound. In the later case, the PLT entry initially
branches to a function that will lookup the symbol and update the
PLT entry the first time the function is called.
muta...@gmail.com
2021-07-05 22:13:33 UTC
Permalink
Post by Scott Lurndal
While loading the shared objects on behalf of the application, the RTLD
will fill in the GOT and PLT tables with the virtual addresses that the
shared objects are loaded at (they can be different from run to run
and each application will load the shared objects at different virtual
addresses in the application).
The application then branches through the PLT to get to 'write', 'read',
'open', 'fopen', 'fclose', 'printf' etc.
This sounds exactly like Windows.

And that is very different from UEFI, which passes a pointer
of callable functions, right?

Which one is better in your opinion - UEFI or Linux?

And UEFI actually takes 2 parameters, not one. Are
two necessary/desirable?

And under what circumstances should the parameter
after envp be used?

Thanks. Paul.
Joe Monk
2021-07-05 23:03:20 UTC
Permalink
Post by ***@gmail.com
Which one is better in your opinion - UEFI or Linux?
Linux runs on top of UEFI.

Joe
muta...@gmail.com
2021-07-05 23:25:50 UTC
Permalink
Post by Joe Monk
Post by ***@gmail.com
Which one is better in your opinion - UEFI or Linux?
Linux runs on top of UEFI.
That is not my question.

Linux executables rely on the caller filling in external references.

UEFI executables rely on the caller passing 2 pararameters.

Which is better, and why?

And is 2 parameters better than 1?

Thanks. Paul.
muta...@gmail.com
2021-07-05 23:28:57 UTC
Permalink
Post by ***@gmail.com
Linux executables rely on the caller filling in external references.
UEFI executables rely on the caller passing 2 pararameters.
caller = loader
Scott Lurndal
2021-07-06 00:30:27 UTC
Permalink
Post by Joe Monk
Post by ***@gmail.com
Which one is better in your opinion - UEFI or Linux?
Linux runs on top of UEFI.
I believe it more accurate to state that Linux runs alongside of UEFI,
in the sense that UEFI lives in memory marked reserved in the memory map
it provides to the operating system (Windows, VMware, Linux, Wind River, etc).

The operating system may then request services from the UEFI code dealing
with low-level hardware-specific interfaces (such as firmware updates,
sensor management, performance monitoring).
Branimir Maksimovic
2021-07-05 23:50:45 UTC
Permalink
Post by ***@gmail.com
And under what circumstances should the parameter
after envp be used?
At the beginning of program you obtain pointer and use it instead of int 80h.
Benefit is it was faster on older hardwer, now not worth a fuss...
Post by ***@gmail.com
Thanks. Paul.
muta...@gmail.com
2021-07-06 00:05:20 UTC
Permalink
Post by Branimir Maksimovic
Post by ***@gmail.com
And under what circumstances should the parameter
after envp be used?
At the beginning of program you obtain pointer and use it instead of int 80h.
Benefit is it was faster on older hardwer, now not worth a fuss...
Not worth a fuss because what?

I'm not concerned about speed on older hardware,
but if it is the cleanest way of removing *all* traces
of "INT 80H" from an executable then I am interested.

Thanks. Paul.
muta...@gmail.com
2021-07-06 01:28:02 UTC
Permalink
Post by ***@gmail.com
I'm not concerned about speed on older hardware,
but if it is the cleanest way of removing *all* traces
of "INT 80H" from an executable then I am interested.
You know what - with a Windows program I can
statically-link PDPCLIB so that the only dependency
is on kernel32.dll. I currently don't have the equivalent
of that in Linux, but the parameter after envp sounds
like it will give me that.

So an alternative to being dependent on libc.

There's probably not a lot of point in that unless you
don't like the fact that libc doesn't interpret "C:\" or
open COM1 or something like that, where you need
control of the C library.

So, I'm interested, unless I'm missing something.

Then there is a separate exercise of replacing libc
(the equivalent of msvcrt.dll) itself, as part of
having a Linux clone.

Both sound like equivalents to me, and both are
clean.

Except for the fact that Unix executables put
unreasonable demands on the caller. ie the caller
needs to be able to manipulate the stack in an
unusual way to supply parameters, and a specific
weird requirement for malloc() and not sure if
system() can be implemented, at least traditionally,
without a fork() being present - another weird
requirement.

When I was faced with these issues in PDPCLIB
and PDOS, I just said "fuck Unix - Windows, MSDOS,
OS/2, AmigaOS (with D7 extension) are much cleaner".

BFN. Paul.
Branimir Maksimovic
2021-07-06 02:51:48 UTC
Permalink
Post by ***@gmail.com
Post by Branimir Maksimovic
Post by ***@gmail.com
And under what circumstances should the parameter
after envp be used?
At the beginning of program you obtain pointer and use it instead of int 80h.
Benefit is it was faster on older hardwer, now not worth a fuss...
Not worth a fuss because what?
I'm not concerned about speed on older hardware,
but if it is the cleanest way of removing *all* traces
of "INT 80H" from an executable then I am interested.
Why you are bothered with int 80h? Why don't you use glibc
then you don't need syscalls directly?
Yes with vsyscall you don't need int 80h if that suits you...
Post by ***@gmail.com
Thanks. Paul.
muta...@gmail.com
2021-07-06 03:21:07 UTC
Permalink
Post by Branimir Maksimovic
Post by ***@gmail.com
I'm not concerned about speed on older hardware,
but if it is the cleanest way of removing *all* traces
of "INT 80H" from an executable then I am interested.
Why you are bothered with int 80h? Why don't you use glibc
then you don't need syscalls directly?
I have my own competing C library. The easiest thing
to do is statically-link it to produce an executable that
has no dependencies on glibc. The main problem is
the embedded "INT 80H" instructions. I now consider
that to be unclean, because it mandates the existence
of an interrupt table.
Post by Branimir Maksimovic
Yes with vsyscall you don't need int 80h if that suits you...
Yes, switching to vsyscall sounds like what I want in
order to produce clean executables.

BFN. Paul.
muta...@gmail.com
2021-07-06 04:03:44 UTC
Permalink
Post by ***@gmail.com
Post by Branimir Maksimovic
Yes with vsyscall you don't need int 80h if that suits you...
Yes, switching to vsyscall sounds like what I want in
order to produce clean executables.
I've done some initial investigation of this. The Linux
startup code is interesting - there is no return address.

I have seen that what I need is some global variable,
called e.g. __vsyscall and then it is a simple matter
of replacing:

int $0x80

with

call *__vsyscall

So the challenge is to set __vsyscall.

This is all 32-bit so I can just define the actual variable as:

.long __vsyscall

I believe.

But to set this global variable I would be using C code.

Here is what I currently have:

/* We can get away with a minimal startup code, plus make it
a C program. There is no return address. Instead, on the
stack is a count, followed by all the parameters as pointers */

int _start(char *p)
{
int rc;

rc = __start(*(int *)(&p - 1), &p);
__exita(rc);
return (rc);
}


So, before calling __start, I need to set __vsyscall.

Is it a simple matter of jumping the number of parameters
provided in argc, which will put me at envp, and then
continue scanning until a NULL. And then the next value
will be the value I need to copy into __vsyscall?

Does this work even for non-ELF?

Thanks. Paul.
Branimir Maksimovic
2021-07-06 07:14:30 UTC
Permalink
Post by ***@gmail.com
Post by ***@gmail.com
Post by Branimir Maksimovic
Yes with vsyscall you don't need int 80h if that suits you...
Yes, switching to vsyscall sounds like what I want in
order to produce clean executables.
I've done some initial investigation of this. The Linux
startup code is interesting - there is no return address.
I have seen that what I need is some global variable,
called e.g. __vsyscall and then it is a simple matter
int $0x80
with
call *__vsyscall
So the challenge is to set __vsyscall.
.long __vsyscall
I believe.
But to set this global variable I would be using C code.
/* We can get away with a minimal startup code, plus make it
a C program. There is no return address. Instead, on the
stack is a count, followed by all the parameters as pointers */
int _start(char *p)
{
int rc;
rc = __start(*(int *)(&p - 1), &p);
__exita(rc);
return (rc);
}
So, before calling __start, I need to set __vsyscall.
Is it a simple matter of jumping the number of parameters
provided in argc, which will put me at envp, and then
continue scanning until a NULL. And then the next value
will be the value I need to copy into __vsyscall?
Does this work even for non-ELF?
Thanks. Paul.
Here is example in fasm:

format ELF executable

AT_NULL equ 0 ;/* End of vector */
AT_IGNORE equ 1 ;/* Entry should be ignored */
AT_EXECFD equ 2 ;/* File descriptor of program */
AT_PHDR equ 3 ;/* Program headers for program */
AT_PHENT equ 4 ;/* Size of program header entry */
AT_PHNUM equ 5 ;/* Number of program headers */
AT_PAGESZ equ 6 ;/* System page size */
AT_BASE equ 7 ;/* Base address of interpreter */
AT_FLAGS equ 8 ;/* Flags */
AT_ENTRY equ 9 ;/* Entry point of program */
AT_NOTELF equ 10 ;/* Program is not ELF */
AT_UID equ 11 ;/* Real uid */
AT_EUID equ 12 ;/* Effective uid */
AT_GID equ 13 ;/* Real gid */
AT_EGID equ 14 ;/* Effective gid */
AT_CLKTCK equ 17 ;/* Frequency of times() */
;/* Pointer to the global system page used for system calls and other nice
; * things. */
AT_SYSINFO equ 32
AT_SYSINFO_EHDR equ 33

segment readable executable

entry $
mov eax,[esp] ; argc -> eax
lea eax,[esp+eax*4+8] ; envp -> eax

@@:
cmp dword[eax],0
jz @f
add eax,4
jmp @b

@@:
add eax,4

virtual at eax
a_type dd ?
a_val dd ?
end virtual

@@:
cmp [a_type],AT_NULL
jz .L1
cmp [a_type],AT_SYSINFO
jz .L0
add eax,4
jmp @b

.L0:
mov eax,[a_val]
mov [vsyscall],eax

mov eax,4
mov ebx,1
mov ecx,msg
mov edx,szmsg
call [vsyscall]

mov eax,1
mov ebx,0
call [vsyscall]

.L1: ; no vsyscall found
mov eax,4
mov ebx,1
mov ecx,nmsg
mov edx,sznmsg
int 0x80
mov eax,1
mov ebx,1
int 0x80

segment readable writeable

vsyscall dd 0

msg db 'Hello vsyscall!',0xa,0
szmsg = $-msg
nmsg db 'Hello vsyscall not found!',0xa,0
sznmsg = $-nmsg
--
something dumb
Rod Pemberton
2021-07-04 07:24:28 UTC
Permalink
On Sat, 03 Jul 2021 17:32:45 GMT
Post by Scott Lurndal
The INT/SYSCALL instructions are in the libc shared object, the
applications simply call indirectly through a global pointer table
into libc. LIBC will take care of any interactions with the
operating system isolating the application from the operating system.
He's creating a standalone OS, which he is executing under a hosted OS.

So, in general, his operating system (OS) application mustn't call the
host OS' functions, since it should work as a freestanding OS too.

So, he really has only a few development paths:

a) his OS app -> libc -> host OS functions -> trap & replace
b) his OS app -> no libc
c) his OS app -> custom libc for his OS
d) his OS app -> only libc functions independent of the host OS

So, let's review those options.


Option a):

Option a) is what Paul is struggling with.


Option b):

Option b) is doable but isn't quick nor easy.


Option c):

Option c) is the path chosen by most of the hobby OSes I sampled on the
Internet circa 2007, i.e., path of least resistance. This option is not
that difficult as an OS only needs a few library functions, and most C
libraries are built-up from just a handful of OS functions, e.g.,
Plauger's "The Standard C Library" book and Redhat's newlib use just 18
to 20 host OS calls. Ritchie and Thompson used 11 functions for
PDP-7/11. Early Linux had 40 syscalls, whereas 2.6.17 kernel has 290.

Paul can look a a list of those functions here in this post of mine:
https://groups.google.com/g/alt.os.development/c/ZakDSkdPyS4/m/jLzIpSzMHhMJ


Option d):

Option d) is in regards to which parts of the C library can be host
independent and therefore usable. So, this is from an old post of
mine:

"Some C library functions, such as character functions (is*, to*),
memory functions (mem*), string functions (str*), sprintf() scanf() etc
are likely to NOT be dependent on your OS, due to simplicity and simple
use of memory. Things like argc, argv, exit, stdio, stdin, stderr are
OS dependent on the OS to app interface. File I/O is clearly OS
dependent on at least six to eight OS functions at a minimum. Memory
allocation is OS dependent. File I/O is likely dependent on memory
allocation too. The initial stack used by most compiled C code may be
dependent on memory allocation. This depends. It may use alloca() or
another method, perhaps set up in assembly. The library is dependent
on the OS."


With the GCC compiler, there are compiler options like -ffreestanding
and linker options like -nostdlib for producing freestanding or
standalone apps. -nostdlib enables -nodefaultlibs and -nostartfiles.

According to this webpage, if he's using GCC, he'll still have to
provide some functions like memcpy(), memmove(), memset(), and memcmp()
for freestanding GCC apps.
http://cs107e.github.io/guides/gcc/

If he's not using GCC, he'll have to search the compiler documentation,
or even modify the compiler, e.g., Small C or Smaller C etc.
Post by Scott Lurndal
Therefore, to run a linux application on a foreign operating system
simply requires a version of libc that uses the foreign operating
system interface instructions (INT, Call Gate, SYSENTER or SYSCALL).
The above is true for dynamically linked applications. Statically
linked applications (which are rather rare) will include the required
libc function code in the ELF executable itself and thus may not be
portable to operating systems with different methods of communicating
with the operating system (or any higher privileged ring of
execution).
Bingo.

That static code if not compiled with special compiler options such as
those mentioned for GCC above results in calling the host OS' internal
functions, which his OS app shouldn't be calling if he wants it to be
standalone or freestanding.
--
What is hidden in the ground, when found, is hidden there again?
muta...@gmail.com
2021-07-04 08:26:01 UTC
Permalink
Post by Rod Pemberton
a) his OS app -> libc -> host OS functions -> trap & replace
Option a) is what Paul is struggling with.
I'm not 100% sure I understand your summary, but
the apps I am mainly interested in (such as gccwin),
are Win32 programs that are dependent on nothing
more than msvcrt.dll. ie not even kernel32.dll.

So I wish to run gccwin under PDOS-generic
(essentially the same as PDOS/386 but with the
BIOS decoupled and encapsulated in PDPCLIB,
and FAT encapsulated in PDPCLIB).

PDOS-generic will load gccwin etc, and when filling
in all the printf etc function calls (supposedly pointing
to msvcrt.dll) with some sort of callback that doesn't
necessarily even involve any real file called msvcrt.dll.

PDOS-generic in turn will not do any actual INT calls
itself, but, very similar to the apps, will simply do
callbacks to the BIOS layer.

The BIOS layer may or may not be a simple Windows
program written using Borland's C compiler running
under Windows 10 or anything at all really.

The BIOS layer may or may not INSTEAD be called
BOOTX32.EFI or whatever 32-bit UEFI is.

The BIOS layer may or may not INSTEAD be called
BOOTX64.EFI and switching from 32 to 16 to 64
to 16 to 32.

If the BIOS layer is a simple Windows program running
under some PDOS-generic like OS, the layers can go
up and up forever until you find someone who does an
actual INT instruction or manipulates the hardware.

BFN. Paul.
Joe Monk
2021-07-04 12:04:47 UTC
Permalink
Post by ***@gmail.com
I'm not 100% sure I understand your summary, but
the apps I am mainly interested in (such as gccwin),
are Win32 programs that are dependent on nothing
more than msvcrt.dll. ie not even kernel32.dll.
So I wish to run gccwin under PDOS-generic
(essentially the same as PDOS/386 but with the
BIOS decoupled and encapsulated in PDPCLIB,
and FAT encapsulated in PDPCLIB).
Well ... gccwin has dependencies on either: CYGWIN or MINGW or MINGW-X64, depending on the version of Windows.

Joe
muta...@gmail.com
2021-07-04 13:09:32 UTC
Permalink
Post by Joe Monk
Post by ***@gmail.com
I'm not 100% sure I understand your summary, but
the apps I am mainly interested in (such as gccwin),
are Win32 programs that are dependent on nothing
more than msvcrt.dll. ie not even kernel32.dll.
So I wish to run gccwin under PDOS-generic
(essentially the same as PDOS/386 but with the
BIOS decoupled and encapsulated in PDPCLIB,
and FAT encapsulated in PDPCLIB).
Well ... gccwin has dependencies on either: CYGWIN or MINGW or MINGW-X64, depending on the version of Windows.
Welcome to 2021. Specifically about 1 week ago in 2021.
We now have a gccwin that is C90-compliant and only
dependent on the C90 subset of msvcrt.dll that is also
present in the PDPCLIB version of msvcrt.dll.

It is actually the C compiler I recommend for general use.
Can be compiled from source using just a C compiler,
including itself. Doesn't need bash or cygwin. The makefile
doesn't use tabs and can be processed by pdmake.

I use it myself for a reason.

BFN. Paul.
Joe Monk
2021-07-04 13:39:09 UTC
Permalink
Post by ***@gmail.com
Welcome to 2021. Specifically about 1 week ago in 2021.
We now have a gccwin that is C90-compliant ...
Then its not gccwin.

https://gcc.gnu.org/install/specific.html#windows

I don't see a non mingw or cygwin version for windows in that list anywhere.

Joe
muta...@gmail.com
2021-07-04 13:50:51 UTC
Permalink
Post by Joe Monk
Post by ***@gmail.com
Welcome to 2021. Specifically about 1 week ago in 2021.
We now have a gccwin that is C90-compliant ...
Then its not gccwin.
https://gcc.gnu.org/install/specific.html#windows
I don't see a non mingw or cygwin version for windows in that list anywhere.
I did a search for "gccwin" on that link and found 0 hits.

I did a search for "gccwin" at http://pdos.org and found 2 hits.

Maybe you need to update your bookmarks.

Incidentally, I was wrong about the 1 week ago. The technology
was only signed off on 1st July 2021 when I walked a
non-programmer through the installation process of gccwin
(which consists of nothing more than unzipping the binaries
into a directory in your PATH), and it all worked without a
single hitch. Although it did eventuate in a number of updates
to the above link to clarify things.

And if you want to be pedantic, I have asked the non-programmer
(who is basically now a programmer) to create a document
explaining the steps. So depending on your skill level, you
may need to wait for that document for the technology to be
signed off to the level you require.

And if you want to be extra pedantic, and see evidence that
the non-programmer-now-programmer has the ability to
recompile the gccwin source using nothing more than the
gccwin.exe they have already installed (plus the source
code), then that will probably take another week or two,
unless you are happy to accept the evidence of a
Vietnamese programmer-who-was-a-programmer-already,
although only a recent graduate from a Vietnamese
university.

BFN. Paul.
Joe Monk
2021-07-04 16:06:20 UTC
Permalink
Post by ***@gmail.com
I did a search for "gccwin" on that link and found 0 hits.
I did a search for "gccwin" at http://pdos.org and found 2 hits.
Maybe you need to update your bookmarks.
Maybe you shouldnt name your products the same as others already out there in order to avoid confusion!

A quick google search shows plenty of hits on gccwin.

Joe
muta...@gmail.com
2021-07-04 22:05:24 UTC
Permalink
Post by Joe Monk
Maybe you shouldnt name your products the same as others already out there in order to avoid confusion!
A quick google search shows plenty of hits on gccwin.
I have never seen an executable called gccwin, gcc386
or gccmvs, other than what I produced myself.

BFN. Paul.
Rod Pemberton
2021-07-05 10:25:28 UTC
Permalink
On Sun, 4 Jul 2021 01:26:01 -0700 (PDT)
Post by ***@gmail.com
Post by Rod Pemberton
a) his OS app -> libc -> host OS functions -> trap & replace
Option a) is what Paul is struggling with.
I'm not 100% sure I understand your summary,
E.g., if PDOS calls fseek() in the C library, and
the C library function calls the OS' function lseek(),
then you're attempting to trap and replace lseek() call
in the PDOS executable with something that works for your
OS, such as a BIOS function or UEFI call. You have to
replace lseek() because it's dependent upon your host
OS, e.g., Windows or Linux, and won't work with PDOS.
Correct?

The point is that Option a) is a very low-level place
at which to separate your OS from the host OS. You
can separate your code from the host OS code at some
other places, which may require less work or which may
present a cleaner break point. Most OS' coded in C
seem to write their own kernel C library, with basic
functions for text output, file I/O, etc. They may
be built upon the BIOS or they may directly program
the hardware, but most OS' directly program the hardware.
Post by ***@gmail.com
the apps I am mainly interested in (such as gccwin),
are Win32 programs that are dependent on nothing
more than msvcrt.dll. ie not even kernel32.dll.
I'm not familiar with M$ C library (msvcrt.dll), but
as I stated in another post, most C libraries are
usually built up from a handful of OS function calls.
I.e., IMO, it's very likely that msvcrt.dll is
dependent upon kernel32.dll or some other Windows dll.
Post by ***@gmail.com
So I wish to run gccwin under PDOS-generic
Joe brought up a point about "gccwin" ...

By "gccwin", I assumed - probably a decade ago - that
you were talking about a port of GCC to Windows. Is
that wrong? If so, which C compiler are you calling
"gccwin". E.g., Alexei Frounze's Smaller C? Is it
a port of GCC? Was the compiler called something else
originally? LCC? Cygwin? MinGW? OpenWatcom?
Post by ***@gmail.com
(essentially the same as PDOS/386 but with the
BIOS decoupled and encapsulated in PDPCLIB,
and FAT encapsulated in PDPCLIB).
"decoupled"
"encapsulated"

Ok. I didn't expect to see those two words. I've never
heard of them being used in computer programming. Both
are more reminiscent of Electrical Engineering than of
Computer Science.

So, "decoupled" is what you're calling a "freestanding"
or "standalone" OS. So, "decoupling" would be what I
was talking about in those four points. The tools
you're using are dependent on the host OS. You need
to decouple them at some point. I listed 4 methods
and places.

So, "encapsulated" is probably the same as the replacement
portion of what I called "trap and replace" of the host
OS functions. You've managed to trap them somehow, and
replaced them with alternate functions. Or, perhaps, you
mean that there is a "wrapper" around them, where you modify
the BIOS functions to work with PDOS.
Post by ***@gmail.com
PDOS-generic will load gccwin etc, and when filling
in all the printf etc function calls (supposedly pointing
to msvcrt.dll) with some sort of callback that doesn't
necessarily even involve any real file called msvcrt.dll.
Why wouldn't you use sprintf() to memory, and then use your
own text display routine directly writing to the hardware,
instead of calling printf()? ...

I.e., C's printf(), *printf() and *scanf() functions are
all file I/O dependent, e.g., <stdio.h>. In other words,
they'll all attempt to call the host OS' file I/O functions,
calls to which you must patch up in your executable or trap
at run-time, and then replace with something else suitable
for PDOS.

Also, puts() is much faster, as printf() has a huge routine
for formatting strings, but it's likely also file I/O
dependent too. (I didn't check ...)
Post by ***@gmail.com
PDOS-generic in turn will not do any actual INT calls
itself, but, very similar to the apps, will simply do
callbacks to the BIOS layer.
The BIOS layer may or may not be a simple Windows
program written using Borland's C compiler running
under Windows 10 or anything at all really.
Why do you need the BIOS layer?

I.e., this indicates dependence upon something, e.g.,
BIOS file I/O.

Your OS should be controlling, programming, and writing
directly to the hardware. Otherwise, it's not really an
OS, but a user-space application built upon an OS, e.g.,
the BIOS, such as for MS-DOS. (*)

(*) (I'm not saying there is anything wrong with that,
as I use MS-DOS, and I also have an OS-like application,
which could be the base for an OS similar to Windows
98/SE which starts up from DOS. But, my OS programs
the hardware directly. My OS is not executing on top
or beneath anything else. No BIOS.)

In other words, other than E820h or perhaps VESA, I
don't understand why you need the BIOS for that much,
or why I'm getting the strong impression PDOS is really
dependent upon the BIOS, especially for file I/O.
--
What is hidden in the ground, when found, is hidden there again?
muta...@gmail.com
2021-07-05 13:45:43 UTC
Permalink
Post by Rod Pemberton
Post by ***@gmail.com
Post by Rod Pemberton
a) his OS app -> libc -> host OS functions -> trap & replace
Option a) is what Paul is struggling with.
I'm not 100% sure I understand your summary,
E.g., if PDOS calls fseek() in the C library, and
the C library function calls the OS' function lseek(),
then you're attempting to trap and replace lseek() call
in the PDOS executable with something that works for your
OS, such as a BIOS function or UEFI call. You have to
replace lseek() because it's dependent upon your host
OS, e.g., Windows or Linux, and won't work with PDOS.
Correct?
As far as I can tell, we're miles from each other.

First, I have control of a C library. I will plug it in
whenever appropriate. I'm not dependent on
someone else's decision to call lseek.

But I do have this in the Linux version of PDPCLIB:

movl $19, %eax
int $0x80

(ie lseek)

This is statically-linked in to binaries I produce, which
makes them technically unsavory from my point of
view because there is an "INT" instruction embedded
inside the executable.

I can handle that in PDOS/386 running on real hardware,
but not as an unprivileged PDOS/386 running under
Windows.

If my Linux executables were dependent on an external
C library, then PDOS/386 would be able to gain control
and handle that, even running under Windows, without
any Windows knowledge. Unless it requires an INT 80H
to get access to the C library in the first place.

If my Linux executables are designed to accept a C
library, or a routine to get access to a C library, via a
pointer after envp, then I have everything I need.
PDOS/386 will just feed it something that points
right back to PDOS/386.

I already effectively have this with my Windows
executables.

I don't wish to "trap" anything, because I don't want
an INT instruction issued in the first place.
Post by Rod Pemberton
The point is that Option a) is a very low-level place
at which to separate your OS from the host OS. You
can separate your code from the host OS code at some
other places, which may require less work or which may
present a cleaner break point.
My OS will be separated from the host OS by what
I am calling a "BIOS layer".

You can see proof of concept here:

https://sourceforge.net/p/pdos/gitcode/ci/master/tree/bios/bios.c

That is a bog standard Windows executable, acting
as a BIOS. And not just any BIOS, but a C90-like BIOS.
Post by Rod Pemberton
Most OS' coded in C
seem to write their own kernel C library, with basic
functions for text output, file I/O, etc. They may
be built upon the BIOS or they may directly program
the hardware, but most OS' directly program the hardware.
Ok, currently PDOS/386 directly calls the BIOS,
by doing INT 13H instructions, directly linked in
to the PDOS.EXE. I wish to change that with
PDOS-generic to instead accept a caller (BIOS
layer) passing it a pointer. A pointer similar to
the one after envp in Linux I'm not familiar with,
or similar to the one in UEFI which I have seen.

If you look at my bios.c above, I used two pointers,
but I think one is sufficient.

With regard to a kernel C library, I currently have
functions called PosWriteFile etc that map to
MSDOS INT 21H equivalents, but there is no
reason for that to be the interface. My plan is for
kernel32.dll WriteFile() to instead do a
pdos->fwrite() call. ie at every point, things will
use the C90 name.
Post by Rod Pemberton
Post by ***@gmail.com
the apps I am mainly interested in (such as gccwin),
are Win32 programs that are dependent on nothing
more than msvcrt.dll. ie not even kernel32.dll.
I'm not familiar with M$ C library (msvcrt.dll), but
as I stated in another post, most C libraries are
usually built up from a handful of OS function calls.
I.e., IMO, it's very likely that msvcrt.dll is
dependent upon kernel32.dll or some other Windows dll.
Yes, it is *only* dependent on kernel32.dll.
Post by Rod Pemberton
Post by ***@gmail.com
So I wish to run gccwin under PDOS-generic
Joe brought up a point about "gccwin" ...
By "gccwin", I assumed - probably a decade ago - that
you were talking about a port of GCC to Windows. Is
that wrong?
No, that is correct.
Post by Rod Pemberton
If so, which C compiler are you calling
"gccwin".
A fork of GCC 3.2.3 to make it C90-compliant
and as a result, work with just PDPCLIB, which,
as a result, means it works on both Windows
and MVS.
Post by Rod Pemberton
E.g., Alexei Frounze's Smaller C? Is it
a port of GCC? Was the compiler called something else
originally? LCC? Cygwin? MinGW? OpenWatcom?
Nope. It is Joe who is being confusing, by suggesting
that gccwin is not related to gcc.
Post by Rod Pemberton
Post by ***@gmail.com
(essentially the same as PDOS/386 but with the
BIOS decoupled and encapsulated in PDPCLIB,
and FAT encapsulated in PDPCLIB).
"decoupled"
"encapsulated"
Ok. I didn't expect to see those two words. I've never
heard of them being used in computer programming. Both
are more reminiscent of Electrical Engineering than of
Computer Science.
I'm pretty sure "encapsulation" is used in computer
science. Not sure about decoupling.
Post by Rod Pemberton
So, "decoupled" is what you're calling a "freestanding"
or "standalone" OS.
I'm not sure that is my view.

I am talking about moving INT instructions out of
pdos.exe.
Post by Rod Pemberton
So, "encapsulated" is probably the same as the replacement
portion of what I called "trap and replace" of the host
OS functions. You've managed to trap them somehow, and
replaced them with alternate functions. Or, perhaps, you
mean that there is a "wrapper" around them, where you modify
the BIOS functions to work with PDOS.
I don't think I am doing any of those things.

Currently pdos.c does things like fatWriteFile().
I intend to change that to fwrite().

The flavor of PDPCLIB that is linked in to pdos.c for
internal use, will convert that fwrite into a call to
fatWriteFile(). It won't be visible in pdos.c.
Post by Rod Pemberton
Post by ***@gmail.com
PDOS-generic will load gccwin etc, and when filling
in all the printf etc function calls (supposedly pointing
to msvcrt.dll) with some sort of callback that doesn't
necessarily even involve any real file called msvcrt.dll.
Why wouldn't you use sprintf() to memory, and then use your
own text display routine directly writing to the hardware,
instead of calling printf()? ...
I.e., C's printf(), *printf() and *scanf() functions are
all file I/O dependent, e.g., <stdio.h>. In other words,
they'll all attempt to call the host OS' file I/O functions,
calls to which you must patch up in your executable or trap
at run-time, and then replace with something else suitable
for PDOS.
Also, puts() is much faster, as printf() has a huge routine
for formatting strings, but it's likely also file I/O
dependent too. (I didn't check ...)
Ok, this is all stuff internal to PDPCLIB, and the
msvcrt.dll build of PDPCLIB, or Microsoft's
version of the same thing, but printf() and puts()
will all (in my implementation anyway) devolve into
a call to fwrite() which in turn, at least for PDOS/386,
turns into a call to WriteFile() in kernel32.dll.
Post by Rod Pemberton
Post by ***@gmail.com
PDOS-generic in turn will not do any actual INT calls
itself, but, very similar to the apps, will simply do
callbacks to the BIOS layer.
The BIOS layer may or may not be a simple Windows
program written using Borland's C compiler running
under Windows 10 or anything at all really.
Why do you need the BIOS layer?
Cleanliness is next to Godliness.
Post by Rod Pemberton
I.e., this indicates dependence upon something, e.g.,
BIOS file I/O.
From the PDOS-generic point of view, it is beyond scope
what happens after control is passed to the BIOS layer.
It could go up another 57 layers, or it could directly
manipulate the hardware. PDOS-generic neither knows
nor cares.
Post by Rod Pemberton
Your OS should be controlling, programming, and writing
directly to the hardware.
I disagree on "should".
Post by Rod Pemberton
Otherwise, it's not really an
OS, but a user-space application built upon an OS, e.g.,
the BIOS, such as for MS-DOS. (*)
Surely whoever manages the file system and
memory on behalf of applications is an OS?

Regardless, if you want to call MSDOS and
PDOS/386 - both currently using the BIOS
non-OSes, that's a semantic debate. I'm happy
to call them whatever you want, but
"user-space application" is a bit of an odd term
for PDOS/386 and is likely to confuse people.
What do you call applications that run under
PDOS/386 as currently configured?
Post by Rod Pemberton
(*) (I'm not saying there is anything wrong with that,
as I use MS-DOS, and I also have an OS-like application,
which could be the base for an OS similar to Windows
98/SE which starts up from DOS. But, my OS programs
the hardware directly. My OS is not executing on top
or beneath anything else. No BIOS.)
The BIOS exists to provide hardware independence
for operating systems and I think it does its job
admirably.

I didn't actually understand that at the time, but just
had a "feeling" I should stay connected to the BIOS,
even if it meant constantly switching between PM32
and RM16. Now I "know" why that was the exact
right thing to do.
Post by Rod Pemberton
In other words, other than E820h or perhaps VESA, I
don't understand why you need the BIOS for that much,
or why I'm getting the strong impression PDOS is really
dependent upon the BIOS, especially for file I/O.
It's extremely dependent.

And now that I know that the BIOS even provides an
INT 14H, I'm a very happy camper, because my eyes
light up and I see "SeaBIOS and bluetooth!".

And I had another look at code you provided me too.
I never really liked the look of this bit:

https://sourceforge.net/p/pdos/gitcode/ci/master/tree/src/lldos.asm

mov ax, 02401h
int 015h

And I commented it out. But just in the last few days I
realized that this was the only place I actually manipulate
the hardware. I looked up the interrupt number you
provided. And it looks to me like if I use that interrupt,
I will be decoupled from all hardware other than the
CPU. Which sounds like a great place to be. In the same
way that the people who wrote the INT 14H spec had
never even heard of bluetooth.

BFN. Paul.
Rod Pemberton
2021-07-06 12:12:28 UTC
Permalink
On Mon, 5 Jul 2021 06:45:43 -0700 (PDT)
Post by ***@gmail.com
Post by Rod Pemberton
In other words, other than E820h or perhaps VESA, I
don't understand why you need the BIOS for that much,
or why I'm getting the strong impression PDOS is really
dependent upon the BIOS, especially for file I/O.
It's extremely dependent.
And now that I know that the BIOS even provides an
INT 14H, I'm a very happy camper, because my eyes
light up and I see "SeaBIOS and bluetooth!".
By Int 14h, you mean BIOS serial I/O? Just checking
because RBIL has lots of other stuff listed ...
Post by ***@gmail.com
And I had another look at code you provided me too.
https://sourceforge.net/p/pdos/gitcode/ci/master/tree/src/lldos.asm
mov ax, 02401h
int 015h
And I commented it out. But just in the last few days I
realized that this was the only place I actually manipulate
the hardware. I looked up the interrupt number you
provided. And it looks to me like if I use that interrupt,
I will be decoupled from all hardware other than the
CPU. Which sounds like a great place to be. In the same
way that the people who wrote the INT 14H spec had
never even heard of bluetooth.
...
Post by ***@gmail.com
I looked up the interrupt number you provided.
Which interrupt was that?

I think I mentioned three Int 15h's recently:
AH=87h (copy extended memory)
AH=89h (switch to PM)
AX=E820h (extended memory map)
Post by ***@gmail.com
And I commented it out. But just in the last few days I
realized that this was the only place I actually manipulate
the hardware.
Are you saying you intend to enable the A20
line via the BIOS Int 15h, AX=2401h call, so
as to make PDOS hardware independent? ...

I.e., it seems like you're saying you're
eliminating enabling A20 via port programming.

If so, then
a) that's a very bad idea, and
b) I didn't give you that int.

James and I found serious problems with the
BIOS A20 functions we tested, which mostly
failed for 10 motherboards. The keyboard
and PS/2 port enable methods work, except
one motherboard which pre-dated PS/2.

"Machine Characteristics - A20 Controls"
http://aodfaq.wikidot.com/mc-a20-controls

"Machine Characteristics"
http://aodfaq.wikidot.com/machine-characteristics
--
What is hidden in the ground, when found, is hidden there again?
muta...@gmail.com
2021-07-06 12:39:07 UTC
Permalink
Post by Rod Pemberton
Post by ***@gmail.com
And now that I know that the BIOS even provides an
INT 14H, I'm a very happy camper, because my eyes
light up and I see "SeaBIOS and bluetooth!".
By Int 14h, you mean BIOS serial I/O?
Correct. And at the level of INT 14H functions 1
and 2, there isn't even a concept of serial, is there?
They should have provided functions that take a
block as well, instead of individual bytes. But
nevermind.

INT 14H function 0 has echoes of RS232 but I
will relegate that to anyone who uses the
"MODE" command, which won't make sense for
a bluetooth connection. Basically when someone
opens COM1 it should be happy to inherit the
already-set setting.
Post by Rod Pemberton
Are you saying you intend to enable the A20
line via the BIOS Int 15h, AX=2401h call, so
as to make PDOS hardware independent? ...
Yep, exactly.
Post by Rod Pemberton
I.e., it seems like you're saying you're
eliminating enabling A20 via port programming.
Yes.
Post by Rod Pemberton
If so, then
a) that's a very bad idea, and
b) I didn't give you that int.
You're right. Sorry Rod, thanks Scott.

https://groups.google.com/g/alt.os.development/c/ehyG4KrMQgs/m/fvxdXa4lAgAJ

C:\devel\pdos\src>git show a1a0be61d1d613e39265234eeb1d683c6621d6af
commit a1a0be61d1d613e39265234eeb1d683c6621d6af
Author: Paul Edwards <***@gmail.com>
Date: Sat Jul 21 17:22:12 2018 +1000

additional method of switching on A20 line

diff --git a/src/lldos.asm b/src/lldos.asm
index e86bd6d..bf0e220 100644
--- a/src/lldos.asm
+++ b/src/lldos.asm
@@ -151,6 +151,8 @@ a20e_ii:
jnz a20e_ii
mov al, 0dfh
out 060h, al
+ mov ax, 02401h
+ int 015h
ret
a20e endp
Post by Rod Pemberton
James and I found serious problems with the
BIOS A20 functions we tested, which mostly
failed for 10 motherboards. The keyboard
and PS/2 port enable methods work, except
one motherboard which pre-dated PS/2.
Ok, given that I'm not actually selling PDOS/386
commercially, I have the ability to be "purist" now
that I know what I want.

So at some level I will just tell people to get a new
BIOS or change the code themselves.

But at another level, I like Scott's code. First he
checks to see if A20 is already enabled. Only then
does he do the next step, and the very first thing
he tries is the INT 15H. So it is only if that fails to
do the trick that he starts manipulating the
hardware.

So, we'll see what happens. Maybe I can provide a
byte offset for people to zap if they want to
continue on, and manipulate hardware. Or maybe a
zap for purists to switch off the hardware fallback.

At some level I'm just going to tell people to not buy
a computer unless it can have SeaBIOS flashed, at
least if they want to run PDOS/386.

And obviously, given that it's public domain, people are
free to find a better derivative than the one I'm providing.

I'm expecting commercially-minded people to produce a
commercial-quality product, not me (unless I decide at a
later date to be a commercially-minded person - but
quite frankly I think I'm more likely to become a serial killer -
my sister once said that computers were invented just in
the nick of time otherwise I would have been an axe
murderer).

http://www.ratman.biz/archive/young_ones/flood.html

Vyvyan: It's a potion I've invented where when the patient drinks it he turns into an axe-wielding, homicidal maniac! It's basically a cure. For not being an axe-wielding, homicidal maniac. The potential market's enormous!

BFN. Paul.
muta...@gmail.com
2021-07-06 13:35:44 UTC
Permalink
Post by ***@gmail.com
Post by Rod Pemberton
Are you saying you intend to enable the A20
line via the BIOS Int 15h, AX=2401h call, so
as to make PDOS hardware independent? ...
Yep, exactly.
BTW, does an OS being hardware-independent actually
open up any possibility?

It just "seems nice" to me that there isn't a skerrick of
hardware that is required other than the 80386 and
some memory.

But is there some hardware (or non-hardware?) where
such an OS design would be useful?

I know other people who state that the hardware is
more reliable than the BIOS, but what do you actually
find if you go the BIOS-only route? (Or use UEFI
exclusively). Is there some niche market opened up?

Thanks. Paul.
muta...@gmail.com
2021-07-07 01:50:30 UTC
Permalink
Post by ***@gmail.com
BTW, does an OS being hardware-independent actually
open up any possibility?
It occurred to me - with no manipulation of the hardware,
it means that no hardware virtualizer is required.

You only need the OS to allow you to install interrupt
handlers.

Although that won't help under Windows, because although
it will allow you to install interrupt handlers, it won't let you
switch to/from protected mode.

So the layer needs to exist. And once you have the layer
(that PDOS-generic would use), you can bypass the need
for interrupts too.

So not manipulating I/O ports probably doesn't buy you
anything.

BFN. Paul.
Rod Pemberton
2021-07-07 09:06:16 UTC
Permalink
On Tue, 6 Jul 2021 06:35:44 -0700 (PDT)
Post by ***@gmail.com
Post by ***@gmail.com
Post by Rod Pemberton
Are you saying you intend to enable the A20
line via the BIOS Int 15h, AX=2401h call, so
as to make PDOS hardware independent? ...
Yep, exactly.
BTW, does an OS being hardware-independent actually
open up any possibility?
It just "seems nice" to me that there isn't a skerrick of
hardware that is required other than the 80386 and
some memory.
Yes, it always "seems nice" to most programmers to
fully abstract away the hardware. This same innate
desire exists for those arguing about C on comp.lang.c.
I suspect that part of this may be because most
programmers don't have a strong background in
electronics, hence have some difficulty in programming
hardware devices.

In the case of C, it's bad (IMO) to abstract away the
underlying hardware, because C must be implemented
on real hardware, and the C machine model fits only
a few standard architectures really well, since it was
only designed to fit two. It was forced upon numerous
other architectures, particularly mainframes, which
were not suited to the language implementation, and
this resulted in much C behavior that isn't defined
or is implementation defined. Fortunately, byte
addressed, contiguous memory, pointer sizes matching
integer sizes, von Neumann architecture, micro-processors
work really well with C, which is what we have today.

In the case of an OS, it's still bad in IMO to abstract
away the hardware, as you must do what is necessary
for the OS to function correctly. So, you have to
deal with the cards that were dealt.
Post by ***@gmail.com
But is there some hardware (or non-hardware?) where
such an OS design would be useful?
There are all sorts of memory-mapped devices, e.g.,
LFB, and there were devices that could only be
accessed via BIOS, e.g., BIO32 directory, VESA.

Useful? ... That's somewhat arbitrary. That
depends on what people like or can tolerate or
can comprehend.

Personally, I think memory mapped devices work well
with Unix's "everything is a file" concept, which
was inherited by the C programming language via
file I/O functions and typedef'd structs (overlays).
And, I think interrupts (pre-emptive multi-tasking)
doesn't work well with C, because C has no built-in
mechanism to support interrupts. Yield based methods
(cooperative multi-tasking) works better. As for
port I/O, again, C has no mechanism, but non-primitive
C compilers easily support this either directly
or via inlined assembly.
Post by ***@gmail.com
I know other people who state that the hardware is
more reliable than the BIOS, but what do you actually
find if you go the BIOS-only route?
Not sure. DOS made BIOS work.

The BIOS was supposed to hide away or abstract
the specific details of programming hardware
which was unique to a particular motherboard
or chipset so the programmer didn't have to
deal with it.

The down side was that there was no guarantee
the BIOS function works correctly or consistently,
as there were many different implementations.

I think that is why most programmers, including
me, preferred directly programming hardware with
published standardized interfaces.
Post by ***@gmail.com
(Or use UEFI exclusively).
I'm not familiar with UEFI, other it seems there
is an option to disable it, once the OS takes
control, which I would likely enable.
Post by ***@gmail.com
Is there some niche market opened up?
No idea.
--
What is hidden in the ground, when found, is hidden there again?
muta...@gmail.com
2021-07-07 08:22:52 UTC
Permalink
Post by Rod Pemberton
Post by ***@gmail.com
It just "seems nice" to me that there isn't a skerrick of
hardware that is required other than the 80386 and
some memory.
Yes, it always "seems nice" to most programmers to
fully abstract away the hardware.
That's a good way of putting it.
Post by Rod Pemberton
This same innate
desire exists for those arguing about C on comp.lang.c.
And they're not necessarily wrong.
Post by Rod Pemberton
I suspect that part of this may be because most
programmers don't have a strong background in
electronics, hence have some difficulty in programming
hardware devices.
Or maybe they shouldn't be doing that in the first place.
Post by Rod Pemberton
In the case of C, it's bad (IMO) to abstract away the
underlying hardware, because C must be implemented
on real hardware, and the C machine model fits only
a few standard architectures really well, since it was
only designed to fit two. It was forced upon numerous
other architectures, particularly mainframes, which
were not suited to the language implementation, and
this resulted in much C behavior that isn't defined
or is implementation defined.
I've implemented a C library, a C compiler, and an
OS written in C on the mainframe, and I have no
idea what you are talking about.

C is a perfectly fine match for the S/3X0 hardware.

Perhaps you can show me the generated assembler
you don't like.
Post by Rod Pemberton
Fortunately, byte
addressed, contiguous memory, pointer sizes matching
integer sizes, von Neumann architecture, micro-processors
work really well with C, which is what we have today.
C works perfectly fine on the 8086 too.

Regardless, I do know of old machines, IBM 1041 or
something, where C can't really be implemented. Oh,
some Burroughs machine too.

So yes, it's only suitable for what the hardware eventually
coalesced on, and then C and the hardware feed each other.
Post by Rod Pemberton
And, I think interrupts (pre-emptive multi-tasking)
doesn't work well with C, because C has no built-in
mechanism to support interrupts. Yield based methods
(cooperative multi-tasking) works better. As for
Ok, I'm not attempting to do multitasking at the moment,
so my question is about single-tasking OSes like MSDOS.
Post by Rod Pemberton
Post by ***@gmail.com
I know other people who state that the hardware is
more reliable than the BIOS, but what do you actually
find if you go the BIOS-only route?
Not sure. DOS made BIOS work.
And I don't see anything wrong with following MSDOS,
at least in that respect. There are some things I would
change though. Such as giving huge memory model
programs a call to find out what the segment shift is.
Post by Rod Pemberton
The down side was that there was no guarantee
the BIOS function works correctly or consistently,
as there were many different implementations.
Surely that's true of C compilers and libraries too?
On different systems too. Each level is responsible
for doing their bit according to specs. It's probably
not the right solution to abandon the published
interface because someone doesn't follow the
specs. At least not by default. I have worked around
hardware in software myself (I paused 0.1 seconds
before starting a zmodem transfer, to stop a
double-sending bug in the Spirit modem). But it can
be compiled in or out.

BFN. Paul.
Joe Monk
2021-07-07 14:03:27 UTC
Permalink
Post by ***@gmail.com
I've implemented a C library, a C compiler, and an
OS written in C on the mainframe, and I have no
idea what you are talking about.
C is a perfectly fine match for the S/3X0 hardware.
Lets be real. You havent "implemented" anything on a mainframe. You've taken an *emulator*, bent it around to fit your definitions, and then written code to run on that.

Nobody in real life will implement your C compiler on an in production mainframe, first because they cant get it past the info security dept and second because GCC 3.2.3 is so old that it wont pass audit.

Joe
Scott Lurndal
2021-07-07 15:09:44 UTC
Permalink
Post by Joe Monk
Post by ***@gmail.com
I've implemented a C library, a C compiler, and an
OS written in C on the mainframe, and I have no
idea what you are talking about.
C is a perfectly fine match for the S/3X0 hardware.
Lets be real. You havent "implemented" anything on a mainframe. You've taken an *emulator*, bent it around to fit your definitions, and then written code to run on that.
Nobody in real life will implement your C compiler on an in production mainframe, first because they cant get it past the info security dept and second because GCC 3.2.3 is so old that it wont pass audit.
And third, because nobody is interested in single-user, single-application operating
environments for any form of real production work.
Rod Pemberton
2021-07-08 10:17:41 UTC
Permalink
On Wed, 07 Jul 2021 15:09:44 GMT
Post by Scott Lurndal
And third, because nobody is interested in single-user,
single-application operating environments for any form of real
production work.
You could be talking about mainframes here or you could be talking
about servers. Your statement is true for one and false for the other.

I agree that some companies use multi-user, multi-tasking,
fault-tolerant servers for heavy data processing and real-time online
transaction processing (RT OLTP), e.g., Stratus servers running Windows
Server w/ Hyper-V and VMware vSphere. (True for servers)

But, the paradigm of "Big Iron" multi-user IBM or Unix corporate
mainframe ended about twenty some years ago ... (False for mainframes)
The initial transition from fault-tolerant mainframes (Big Iron) to
clusters of high-availability Linux servers within the brokerage
industry started around 2002. (I know this for a fact because the
brokerage I where I worked at the time assigned me alone to do a
project where I was dealing directly with another brokerage whose
entire programming department of 200+ people was struggling to
implement a solution on their new Linux server cluster.)

Also, your belief in multi-user and multi-tasking also nullifies the
decades use of Windows on corporate desktops. Windows is a
"single-user, single-application operating environment" used for "real
production work". Perhaps, this is just not at the scale which you
didn't mention or specify, but simply referred to as "real production
work".
--
What is hidden in the ground, when found, is hidden there again?
muta...@gmail.com
2021-07-08 10:10:59 UTC
Permalink
Post by Rod Pemberton
Post by Scott Lurndal
And third, because nobody is interested in single-user,
single-application operating environments for any form of real
production work.
You could be talking about mainframes here or you could be talking
about servers. Your statement is true for one and false for the other.
I don't know what Scott's definition of "real production work"
is, but my real production work is building executables.

And I do that currently on MVS/380, and may switch to
PDOS/3X0 in the future.

I only need a single-tasking system to do this work. I
actually work from a Windows command prompt and
just type in "allmvs" and wait a bit.

Now maybe Scott's definition of real production work
is that you have to actually be paid for your work. So
if you cut a check for me of US$0.20, that nullifies that
argument. Same thing if my wife cuts the check.

Regardless, if you set some arbitrary amount of money
that needs to be forked over, and an arbitrary source of
that money, ie no relatives allowed, then that rules me
out.

Whether it rules out the rest of the planet I have no idea.
I'm not omniscient like a large number of people on
Usenet it seems.

BFN. Paul.
Scott Lurndal
2021-07-08 13:54:18 UTC
Permalink
Post by Rod Pemberton
On Wed, 07 Jul 2021 15:09:44 GMT
Windows is a
"single-user, single-application operating environment" used for "real
production work".
Windows For Workgroups was a single-application operating environment.

Since Windows NT (last millenium), that' hasn't been the case.

Have you actually looked to see how many background processes
are running on the typical windows box?
muta...@gmail.com
2021-07-07 23:35:55 UTC
Permalink
Post by Joe Monk
Post by ***@gmail.com
I've implemented a C library, a C compiler, and an
OS written in C on the mainframe, and I have no
idea what you are talking about.
C is a perfectly fine match for the S/3X0 hardware.
Lets be real. You havent "implemented" anything on a mainframe.
You've taken an *emulator*, bent it around to fit your definitions,
and then written code to run on that.
I have no idea what you are talking about. My C programs
work perfectly fine on everything from S/370 to z/OS.

Again, if C is not a good match for the mainframe, please
show me the generated code you are talking about.

Depending on your complaint, you can show me the
code generated by IBM C instead of GCCMVS if you
prefer.
Post by Joe Monk
Nobody in real life will implement your C compiler on an
in production mainframe, first because they cant get it
past the info security dept and second because GCC 3.2.3
is so old that it wont pass audit.
I have no idea whether that is true or not, because I'm not
familiar with every mainframe on the planet like you
apparently are.

But with GCCMVS I have shown what is technically possible,
not what you perceive about audits.

If Rod's complaint is about auditing, fine, I wasn't aware that
was what we were talking about. I'm happy to concede that,
because I neither know nor care. I'm interested in beautiful
S/370 assembler.

BFN. Paul.
Joe Monk
2021-07-08 09:00:44 UTC
Permalink
Post by ***@gmail.com
I have no idea whether that is true or not, because I'm not
familiar with every mainframe on the planet like you
apparently are.
I'm familiar with generally applicable shop standards, just like you are familiar with the C90 standard. So I speak from the experience of having been thru multiple code audits, reviews, SOX audits from outside auditors....
Post by ***@gmail.com
But with GCCMVS I have shown what is technically possible,
not what you perceive about audits.
Its not like you've reinvented the wheel. IBM C predates your work by at least two decades.... IBM has had C compilers running on the mainframe forever, and GCC had an I370 target and was running on the mainframe long before you did anything with it. IBM's C compiler actually handles records, and doesnt force people to play with files like they are arbitrary byte streams...

Im not here to attack you. Im just pointing out that your work is merely reproducing that which was already done.

Joe
muta...@gmail.com
2021-07-08 10:05:48 UTC
Permalink
Post by Joe Monk
Post by ***@gmail.com
I have no idea whether that is true or not, because I'm not
familiar with every mainframe on the planet like you
apparently are.
I'm familiar with generally applicable shop standards, just
like you are familiar with the C90 standard. So I speak from
the experience of having been thru multiple code audits,
reviews, SOX audits from outside auditors....
But you are claiming universality, not "generally applicable".

ie you know what practice is in Russia, Slovakia,
Africa. And within that, every single company.
Post by Joe Monk
Post by ***@gmail.com
But with GCCMVS I have shown what is technically possible,
not what you perceive about audits.
Its not like you've reinvented the wheel. IBM C predates your
work by at least two decades.... IBM has had C compilers
running on the mainframe forever,
Yes, they also proved what was technically possible.

What is your complaint about either? Show me the S/370
assembler that shows that C is not a good match for
the mainframe.

If your complaint is only applicable to one C compiler,
then switch to the other.
Post by Joe Monk
and GCC had an I370 target and was running on the
mainframe long before you did anything with it.
It was? What year was GCC running on the mainframe?
It was riddled with ASCII shit for a very long time. The
first thing that cleaned that up was a fork by Dave Pitts.
And that was still dependent on IBM C. GCC couldn't
compile itself. And was still riddled with bugs.

It did have an i370 target for long before that though.
I'm not sure how useful it was when it was so riddled
with bugs though. Do you know what it was used for?
Post by Joe Monk
IBM's C compiler actually handles records,
So what's your complaint about C not being a good
match for the mainframe then?
Post by Joe Monk
and doesnt force people to play with files like they are arbitrary byte streams...
And if someone has the opposite complaint, I have GCCMVS
(mainly PDPCLIB actually) waiting to answer that complaint.
Post by Joe Monk
Im not here to attack you. Im just pointing out that your work
is merely reproducing that which was already done.
It is not a reproduction. That is why some mainframers
have bitterly complained.

I have a different (in my opinion, better) model than IBM.

But if you, or Rod, gives me a specific complaint, that
doesn't involve an omniscient knowledge of auditors
on the entire planet, please let me know so that I can
*possibly* address the technical concern.

BFN. Paul.
Joe Monk
2021-07-08 18:53:16 UTC
Permalink
Post by ***@gmail.com
It is not a reproduction. That is why some mainframers
have bitterly complained.
C existed on the mainframe long before you started any of your work. Fact.

Anything you are doing with C on the mainframe is merely reproducing that which was already done. Fact.

Joe
muta...@gmail.com
2021-07-08 21:41:37 UTC
Permalink
Post by Joe Monk
Post by ***@gmail.com
It is not a reproduction. That is why some mainframers
have bitterly complained.
C existed on the mainframe long before you started any of your work. Fact.
I started work on PDPCLIB in 1994, so yes, there were
C implementations on the mainframe before I started.
Before IBM started too, in fact.
Post by Joe Monk
Anything you are doing with C on the mainframe is merely
reproducing that which was already done. Fact.
No, that is not a "fact". IBM with C/370 didn't merely reproduce
the various existing C compilers on MVS either. Nor did GCC.
Nor did PDPCLIB. All of these are unique implementations.

If you wish to state that the very first mainframe C compiler,
probably by Ritchie, was the only unique C compiler, and
everything else is merely a reproduction of that, BY DEFINITION,
then that is a semantic debate, and I am happy for you to
win that debate. And you may as well say that every
computer "merely" reproduced Babbage's work too. In fact,
you may as well say that everyone just reproduced Adam's
(of "Adam and Eve" fame) work. I mean, Adam farted
thousands of years ago, Babbage farted too, therefore
everything Babbage did his entire life was "merely" a
reproduction of what Adam did.

Is there a point to any of this? ie are you trying to point out
that life is pointless so we should all stop working and head
to Bondi?

BFN. Paul.
Joe Monk
2021-07-09 00:27:35 UTC
Permalink
Post by ***@gmail.com
If you wish to state that the very first mainframe C compiler,
probably by Ritchie, was the only unique C compiler...
Ritchie didnt write C on a mainframe. He wrote C on a PDP-7 machine. It is called C because it is a follow on of B, which was also developed on a PDP-7, both of which were running Unix.

The (much) better systems language for the mainframe is assembler.

Joe
muta...@gmail.com
2021-07-09 01:05:36 UTC
Permalink
Post by Joe Monk
Post by ***@gmail.com
If you wish to state that the very first mainframe C compiler,
probably by Ritchie, was the only unique C compiler...
Ritchie didnt write C on a mainframe. He wrote C on a PDP-7 machine.
It is called C because it is a follow on of B, which was also developed
on a PDP-7, both of which were running Unix.
Yes, and then he ported it to the mainframe I believe.
I think his port has been lost though.

My understanding, and point is that it took IBM a long
time to take any interest in C.
Post by Joe Monk
The (much) better systems language for the mainframe is assembler.
If you're talking about executing MVS system services, at
least traditionally, there is no debate about that. The OS
interface itself is given in assembler terms only.

If that's what this debate is about, then we are in agreement.
It's not that C is a poor match, it's that it doesn't work at all.
No language does except assembler.

But in some other mainframe OS, like Linux, where the OS
interface is given in C terms, there is no advantage of
assembler or any other language over C, as far as I am
aware.

Whoever is complaining needs to specify what they are
talking about.

BFN. Paul
Scott Lurndal
2021-07-09 14:16:30 UTC
Permalink
Post by ***@gmail.com
Post by Joe Monk
Post by ***@gmail.com
If you wish to state that the very first mainframe C compiler,
probably by Ritchie, was the only unique C compiler...
Ritchie didnt write C on a mainframe. He wrote C on a PDP-7 machine.
It is called C because it is a follow on of B, which was also developed
on a PDP-7, both of which were running Unix.
Yes, and then he ported it to the mainframe I believe.
No, he ported it to the Interdata 8/32.
muta...@gmail.com
2021-07-09 22:08:56 UTC
Permalink
Post by Scott Lurndal
Post by ***@gmail.com
Post by Joe Monk
Post by ***@gmail.com
If you wish to state that the very first mainframe C compiler,
probably by Ritchie, was the only unique C compiler...
Ritchie didnt write C on a mainframe. He wrote C on a PDP-7 machine.
It is called C because it is a follow on of B, which was also developed
on a PDP-7, both of which were running Unix.
Yes, and then he ported it to the mainframe I believe.
No, he ported it to the Interdata 8/32.
Well who did this:

http://csapp.cs.cmu.edu/3e/docs/chistory.html

By early 1973, the essentials of modern C were complete. The language and compiler were strong enough to permit us to rewrite the Unix kernel for the PDP-11 in C during the summer of that year. (Thompson had made a brief attempt to produce a system coded in an early version of C—before structures—in 1972, but gave up the effort.) Also during this period, the compiler was retargeted to other nearby machines, particularly the Honeywell 635 and IBM 360/370


Linked to from here:
https://en.wikipedia.org/wiki/C_(programming_language)#External_links

BFN. Paul.
Joe Monk
2021-07-09 23:55:13 UTC
Permalink
Post by ***@gmail.com
Also during this period, the compiler was retargeted to other nearby machines, particularly the Honeywell 635 and IBM 360/370
Here is a quote from an actual user of the compiler you talk about:

"So basically, the 370 C compiler on the PDP emitted 370 assembler language which we assembled and linked under VM/CMS."

https://akapugs.blog/2018/05/12/370unixpart2/

So, "retarget" in the quote above means it outputs assembler for that platform...

Joe
muta...@gmail.com
2021-07-10 00:24:59 UTC
Permalink
Post by Joe Monk
Post by ***@gmail.com
Also during this period, the compiler was retargeted to other nearby machines, particularly the Honeywell 635 and IBM 360/370
"So basically, the 370 C compiler on the PDP emitted 370 assembler language which we assembled and linked under VM/CMS."
https://akapugs.blog/2018/05/12/370unixpart2/
An interesting read, thanks.
Post by Joe Monk
So, "retarget" in the quote above means it outputs assembler for that platform...
Ok, and is that a problem?

Or is it only when the C compiler is actually hosted on the
platform that it starts to count?

And then there is yet another level - just because a compiler
can run on a platform doesn't mean that it is good enough
to compile itself. The compiler may not even be written in
the same language.

I wish to convert PDOS/86 into huge memory model (still
8086), and the only way I can do that is using Watcom C
running on a Windows-like environment, like Windows or
Freedos+HX, or Unix and cross-compiling.

It's possible that masm or zortech c etc can run on an 8086
and produce the correct huge memory model instructions.
I haven't seen their output. I've seen Borland output and it
is not suitable. Actually I think Watcom used to run on the
8086 too.

BFN. Paul.
Scott Lurndal
2021-07-10 15:48:16 UTC
Permalink
Post by Joe Monk
Post by ***@gmail.com
Also during this period, the compiler was retargeted to other nearby machines, particularly the Honeywell 635 and IBM 360/370
"So basically, the 370 C compiler on the PDP emitted 370 assembler language which we assembled and linked under VM/CMS."
https://akapugs.blog/2018/05/12/370unixpart2/
So, "retarget" in the quote above means it outputs assembler for that platform...
Basically, an early cross-compiler.

The Interdata 8/32 was native.
Joe Monk
2021-07-10 21:32:09 UTC
Permalink
Post by Scott Lurndal
The Interdata 8/32 was native.
Interesting thing about the Interdata 8/32. It was 360 compatible.

Joe
muta...@gmail.com
2021-07-10 22:49:45 UTC
Permalink
Post by Scott Lurndal
Post by Joe Monk
"So basically, the 370 C compiler on the PDP emitted 370 assembler language which we assembled and linked under VM/CMS."
https://akapugs.blog/2018/05/12/370unixpart2/
So, "retarget" in the quote above means it outputs assembler for that platform...
Basically, an early cross-compiler.
The Interdata 8/32 was native.
I'm guessing the C compiler running on the PDP was
written in C and could compile itself.

And it probably supported EBCDIC too.

Therefore the only thing preventing it from running on
the mainframe natively was the lack of a C runtime
library.

Has the source for this C compiler been lost? Maybe it
can be married up with PDPCLIB and be run natively.

BFN. Paul.

Scott Lurndal
2021-07-09 14:12:50 UTC
Permalink
Post by Joe Monk
Post by ***@gmail.com
If you wish to state that the very first mainframe C compiler,
probably by Ritchie, was the only unique C compiler...
Ritchie didnt write C on a mainframe. He wrote C on a PDP-7 machine. It is called C because it is a follow on of B, which was also developed on a PDP-7, both of which were running Unix.
The (much) better systems language for the mainframe is assembler.
Restated as:

The (much) better systems language for the *IBM* mainframe is assembler (BAL, et alia)

For other mainframe lines (e.g. Burroughs), the better systems language
was Algol (and derivitives) for the Burroughs Large systems and
BPL (Burroughs Programming Language) or SPRITE[*] for Burroughs Medium
systems. Large systems didn't have an assembler, and medium systems
stopped providing assemblers to customers in mid 1970s.

The HP-3000 (borderline mainframe) used SPL/3000 as the systems programming
language, and the VAX used Bliss-32 along with Macro-32 for VMS, although
VAX Pascal was in many ways a better systems programming language than
Bliss-32. Much more maintainable and readable.

[*] Modula-like language used to write the Operating System (MCP).
Rod Pemberton
2021-07-09 20:52:20 UTC
Permalink
On Thu, 8 Jul 2021 17:27:35 -0700 (PDT)
Post by Joe Monk
Post by ***@gmail.com
If you wish to state that the very first mainframe C compiler,
probably by Ritchie, was the only unique C compiler...
Ritchie didnt write C on a mainframe. He wrote C on a PDP-7 machine.
False. (That's a typical comp.lang.c myth.)

According to the article below by Dennis Ritchie, C was developed on the
PDP-11. Unix and the B language were ported from a PDP-7 to a PDP-11
three years prior (1970) to the development of C (1973).

"The Development of the C language" by Dennis M. Ritchie
https://www.bell-labs.com/usr/dmr/www/chist.html
Post by Joe Monk
It is called C because it is a follow on of B,
False. C is a follow on of NB which was a follow on of B. See article.
--
The Chinese have such difficulty with English ... The word is not
"reunification" but "revenge".
Joe Monk
2021-07-09 23:32:33 UTC
Permalink
False. C is a follow on of NB which was a follow on of B. See article.
Not False. C is not a follow on of NB .

"Thus the transition from B to C was contemporaneous with the creation of a compiler capable of producing programs fast and small enough to compete with assembly language. I called the slightly-extended language NB, for `new B.'"

Even Ritchie says "transition from B to C", not from "NB to C".

Joe
Rod Pemberton
2021-07-09 20:05:22 UTC
Permalink
On Thu, 8 Jul 2021 11:53:16 -0700 (PDT)
Post by Joe Monk
Post by ***@gmail.com
It is not a reproduction. That is why some mainframers
have bitterly complained.
C existed on the mainframe long before you started any of your work. Fact.
Anything you are doing with C on the mainframe is merely reproducing
that which was already done. Fact.
Not fact.

You meant: ... with a C compiler on ...

I.e., I'm sure people are still creating new programs in C,
hence not already done.

Even in regards to a C compiler, there is still plenty
of new developments in C. If there wasn't, there wouldn't
be any need for new C standards.
--
The Chinese have such difficulty with English ... The word is not
"reunification" but "revenge".
Joe Monk
2021-07-09 20:23:53 UTC
Permalink
Post by Rod Pemberton
Even in regards to a C compiler, there is still plenty
of new developments in C. If there wasn't, there wouldn't
be any need for new C standards.
C++ is merely viewed as an extension of C, so the standard is published as a "C" standard but applies to both C and C++.

Joe
Branimir Maksimovic
2021-07-09 21:25:18 UTC
Permalink
Post by Joe Monk
Even in regards to a C compiler, there is still plenty of new developments
in C. If there wasn't, there wouldn't be any need for new C standards.
C++ is merely viewed as an extension of C, so the standard is published as a
"C" standard but applies to both C and C++.
Joe
C++ was, perhaps in the beginning thought as extension to C, but now they diverged
in Completely different languages.
--
something dumb
Rod Pemberton
2021-07-08 10:04:00 UTC
Permalink
On Wed, 7 Jul 2021 07:03:27 -0700 (PDT)
Post by Joe Monk
Post by ***@gmail.com
I've implemented a C library, a C compiler, and an
OS written in C on the mainframe, and I have no
idea what you are talking about.
C is a perfectly fine match for the S/3X0 hardware.
Lets be real.
Ok.
Post by Joe Monk
You havent "implemented" anything on a mainframe.
You're wrong about that (two mainframes),
but I'm speaking of myself here, not Paul.

You simply don't know if Paul has had any
mainframe experience in the past. AFAICT,
you're guessing about his lack of experience,
unless you know him IRL or from somewhere else.
Post by Joe Monk
You've taken an *emulator*,
bent it around to fit your definitions,
and then written code to run on that.
That my be true, but it doesn't disqualify any
past mainframe experience Paul may have had.
I.e., he may be using the emulator now, because
he no longer has access to a mainframe he once
used, e.g., at work or school.
Post by Joe Monk
Nobody in real life will implement your C
compiler on an in production mainframe,
That may be true, but IMO not for the reasons
you cited below. Generally, mainframes have
their own compiler tool chain. I.e., they
don't use open source. However, sometimes
they do provide related open source tools.
So, everything is there, sometimes, to
compile GCC.
Post by Joe Monk
first because they cant get it past the info
security dept
I disagree.

If management has decided to use the project, the
programmers will be allowed to have access to the
code for it. You forget that the management at
most companies is usually hierarchical, and what the
"Bosses" say goes. Period. No exceptions. Get it
done. Now, the "info security dept" may take some
precautions here to CYA, like doing virus scans,
providing cleaned copies via media instead of direct
Internet access or such, or using isolated machines
for development, but the programmers will be provided
with the code base, once the management decision has
been made to use it. If the "info security dept"
refuses for some reason, they'll be forced to
deal management over the issue, which they don't
want to do. (BTDT)
Post by Joe Monk
and second because GCC 3.2.3 is so old that
it wont pass audit.
I disagree.

If someone in management decided to use Paul's
project on a mainframe, then it'll be used.

Their programmer underlings will have to start with
whatever he provided, including an obsolete version
of a C compiler. Then, if the requirement is to
"pass audit", they'll need to work their way
up through the various GCC versions, ensuring
correct compilation, in order to pass their quality
control audit process.

Also, dead code, such as an obsoleted compiler
version, is statistically safer to start develop
from, because the code base isn't being actively
modified, which introduces new and unknown bugs,
or more of them than what is within the dead code.
The bugs for dead code have frequently identified
and thoroughly documented by others.
Post by Joe Monk
(continuing reasons for non-use)
I think the real reason his OS won't be used is
that there is no real use or need for it, but that
can be said of every OS developer I've seen here,
except for wolfgang who sold his OS commercially.
Generally, people accept what they have and are
comfortable with, unless it's a larger leap forward,
e.g., paper to computer, cellphone to smartphone.
In other words, incremental advances or retro
technology won't be accepted widely. At best,
most of the people here are just demonstrating
different OS implementations.


So, Joe what OS development have you been doing?
--
What is hidden in the ground, when found, is hidden there again?
Rod Pemberton
2021-07-08 10:16:41 UTC
Permalink
On Wed, 7 Jul 2021 07:03:27 -0700 (PDT)
Post by Joe Monk
Post by ***@gmail.com
I've implemented a C library, a C compiler, and an
OS written in C on the mainframe, and I have no
idea what you are talking about.
C is a perfectly fine match for the S/3X0 hardware.
Lets be real.
Ok.
Post by Joe Monk
You havent "implemented" anything on a mainframe.
You're wrong about that (two mainframes),
but I'm speaking of myself here, not Paul.

You simply don't know if Paul has had any
mainframe experience in the past. AFAICT,
you're guessing about his lack of experience,
unless you know him IRL or from somewhere else.
Post by Joe Monk
You've taken an *emulator*,
bent it around to fit your definitions,
and then written code to run on that.
That my be true, but it doesn't disqualify any
past mainframe experience Paul may have had.
I.e., he may be using the emulator now, because
he no longer has access to a mainframe he once
used, e.g., at work or school.
Post by Joe Monk
Nobody in real life will implement your C
compiler on an in production mainframe,
That may be true, but IMO not for the reasons
you cited below. Generally, mainframes have
their own compiler tool chain. I.e., they
don't use open source. However, sometimes
they do provide related open source tools.
So, everything is there, sometimes, to
compile GCC.
Post by Joe Monk
first because they cant get it past the info
security dept
I disagree.

If management has decided to use the project, the
programmers will be allowed to have access to the
code for it. You forget that the management at
most companies is usually hierarchical, and what the
"Bosses" say goes. Period. No exceptions. Get it
done. Now, the "info security dept" may take some
precautions here to CYA, like doing virus scans,
providing cleaned copies via media instead of direct
Internet access or such, or using isolated machines
for development, but the programmers will be provided
with the code base, once the management decision has
been made to use it. If the "info security dept"
refuses for some reason, they'll be forced to
deal management over the issue, which they don't
want to do. (BTDT)
Post by Joe Monk
and second because GCC 3.2.3 is so old that
it wont pass audit.
I disagree.

If someone in management decided to use Paul's
project on a mainframe, then it'll be used.

Their programmer underlings will have to start with
whatever he provided, including an obsolete version
of a C compiler. Then, if the requirement is to
"pass audit", they'll need to work their way
up through the various GCC versions, ensuring
correct compilation and operation, in order to pass
their quality control audit process.

Also, dead code, such as an obsoleted compiler
version, is statistically safer to start
development from, because the code base isn't
being actively modified, which frequently
introduces new, unknown, or undetectable bugs,
which is typically more of them than what dead
code has. The bugs for dead code have frequently
identified and thoroughly documented, i.e., known.
You can always deal with a known entity, but not
an unknown one.
Post by Joe Monk
(continuing reasons for non-use)
I think the real reason his OS won't be used is
that there is no real use or need for it, but that
can be said of every OS developer I've seen here,
except for wolfgang who sold his OS commercially.
Generally, people accept what they have and are
comfortable with, unless it's a larger leap forward,
e.g., paper to computer, cellphone to smartphone.
In other words, incremental advances or retro
technology won't be accepted widely. At best,
most of the people here are just demonstrating
different OS implementations for their own
personal development, pride, etc.


So, Joe what OS development have you been doing?
--
What is hidden in the ground, when found, is hidden there again?
Rod Pemberton
2021-07-07 09:18:20 UTC
Permalink
On Tue, 6 Jul 2021 05:39:07 -0700 (PDT)
"***@gmail.com" <***@gmail.com> wrote:

<OT psychological issues ...>
Post by ***@gmail.com
quite frankly I think I'm more likely to
become a serial killer - my sister once
said that computers were invented just in
the nick of time otherwise I would have
been an axe murderer).
We know today that plenty of autistic individuals,
people with Asperger's, people with anti-social
personality (APD) disorder, people with
obsessive-compulsive disorders, and unemotional,
logical thinkers tend to become programmers. Thinkers
are usually mis-portrayed as unemotional or cold-blooded
serial killer types and villains in movies and books.
However, in real life, most killers including serial
killers are emotionally driven, except for hitman who
tend to be more logical, profit driven, loyalty driven,
and sociopaths. Unlike psychopaths, sociopaths can turn
their emotions on and off at will, which is why organized
crime groups impose rules and codes of conduct. They wish
to filter out psychopaths who go on a rampage which draws
in law enforcement, while keeping sociopaths around for
the dirty work since they can selectively control their
extreme actions, and can be good fathers and husbands when
around their families etc. Military snipers are frequently
sociopaths too, except they're driven by duty, not profit.

Many, many years ago, I met identical twin brothers, who
were much older than I was. One was a cop. One was a
crook. The only difference between the two was that one
responded to comments about money and the other responded
to comments about illegality. One was driven to steal
and the other was driven to punish. Same looks, voice,
haircut, style of clothes, interests, beliefs, ...
Imagine talking to a guy you think is a cop, but it's his
crook brother, or vice-versa.
--
What is hidden in the ground, when found, is hidden there again?
Rod Pemberton
2021-07-07 09:28:47 UTC
Permalink
On Tue, 6 Jul 2021 05:39:07 -0700 (PDT)
Post by ***@gmail.com
quite frankly I think I'm more likely to become a serial killer -
my sister once said that computers were invented just in
the nick of time otherwise I would have been an axe
murderer).
I guess if you ever "break bad", you could be the
next Paul Le Roux. No, I'm not recommending that path.

https://en.wikipedia.org/wiki/Paul_Le_Roux
--
What is hidden in the ground, when found, is hidden there again?
Branimir Maksimovic
2021-07-03 23:12:05 UTC
Permalink
Post by James Harris
Post by Rod Pemberton
On Thu, 1 Jul 2021 07:45:45 +0100
Post by James Harris
Post by ***@gmail.com
Any application that does any interrupt won't work.
Win32 executables should work, although I haven't
definitively proven that DLLs can be handled.
The bottom line is that, AISI, apps should only have to include
standard calls (no ints, no sysenters etc), and it is the OS or
library which should supply the code which they call. That's not
unusual. I think it's how OSes normally make their service routines
available.
If the OS provided the OS API via function calls instead of interrupts,
then he could possibly call them directly, depending on OS privileges,
and if desired, he could definitely emulate them. Interrupts act as a
barrier to those functions as privilege is required to set up an
interrupt table, or or OS control is required.
You and I may be of the same opinion on this. I've not been following
everything that Paul is trying to do but ISTM sensible for an OS to
provide functions for an app to call to invoke any the OS's services.
Then those functions can invoke the OS proper in whatever way is needed.
In addition, I'd personally prefer such functions to be linked
dynamically so that the application binary will work in different
environments.
Post by Rod Pemberton
So, with a Win32 executable, he suspects he call provide the OS
functions, if they're unavailable for his host environment, since a
Win32 executable apparently calls functions directly instead of using
software interrupts.
I was a bit puzzled by that but then I looked back at some primer code I
wrote years ago when I was trying to find out how to call Linux and
Windows. Whatever I based the code on did, indeed, recommend calling
Linux using an INT instruction.
Here's the Linux code and you can see the INT call within it.
http://codejar.pldev.org/aen/linux_stdout.nasm
By contrast, here's the Windows code and you can see that it invokes the
OS using a normal call instruction.
http://codejar.pldev.org/aen/windows_stdout.nasm
The latter code takes a better approach. It is more flexible, leaves the
app binary holding only app code, and means that the app can invoke OS
functions simply with normal function calls.
As a bonus it even specifies which DLL to get each entry point from.
That said, if I was writing the Linux code now I would look into how to
invoke the write system call via the write syscall function
https://man7.org/linux/man-pages/man2/write.2.html
and how to get it to be pulled in by dynamic linking.
This is how looks modern assembler on GNU/Linux on an x86:

;-------------------------------------
include 'format/format.inc'

format ELF64 executable ELFOSABI_LINUX
entry start

include 'import64.inc'

interpreter '/lib64/ld-linux-x86-64.so.2'
needed 'libc.so.6'
import printf,exit

segment readable executable

start:

lea rdi,[msg]
xor eax,eax
call [printf]

call [exit]

segment readable writeable
msg db 'Hello world!',0xA,0
;------------------------------------------
Rod Pemberton
2021-07-01 09:46:45 UTC
Permalink
On Wed, 30 Jun 2021 17:25:39 +0100
Post by James Harris
Post by ***@gmail.com
Win32 executables, at least normal ones, do not have
environmental dependencies like particular segment
registers being set to certain values, or certain interrupt
vectors being set to certain values.
That means that an unprivileged program can set up
the necessary environment to satisfy the Win32
executable.
Linux programs on the other hand do INT 80H calls,
just as MSDOS programs do INT 21H calls. This
means the calling environment needs sufficient
privilege to set up at least one interrupt vector.
It's not the calling environment which sets up the interrupt vector.
The kernel does that.
I think that misses his point ...

He'd rather have function calls instead of interrupts. I.e., he can
simulate the OS functions easier especially since he doesn't need
privilege to set up an interrupt table.
--
What is hidden in the ground, when found, is hidden there again?
a***@math.uni.wroc.pl
2021-07-01 12:46:26 UTC
Permalink
Post by ***@gmail.com
Win32 executables, at least normal ones, do not have
environmental dependencies like particular segment
registers being set to certain values, or certain interrupt
vectors being set to certain values.
That means that an unprivileged program can set up
the necessary environment to satisfy the Win32
executable.
Linux programs on the other hand do INT 80H calls,
just as MSDOS programs do INT 21H calls. This
means the calling environment needs sufficient
privilege to set up at least one interrupt vector.
No. First, both Linux and Windows programs do system
calls. In Linux system call may be INT 80H (it was
in original i386 Linux) but can be done differently.
Whatever way system calls are done, in normal
operation of system they cause transition of priviledge
and setting receiver of system call frequently require
priviledge. No Linux there is unpriviledged mechanizm
to intercept system calls. There was so called "user level
Linux kernel", which was version of Linux kernel running
in user space, which used interception mechanizm to
receive system calls. This kernel needed privilege
(root right) to perform privileged operations on
behalf of programs, but interception is availble
to ordinary users. In moderm times this approach
is obsoleted by "virtualization extentions" present
in modern processors.

Concerning Windows, my impression was that there was
no comparable mechanizem on Windows. AFAICS main
difference was that much of system call interface
of Windows was undocumented and many Windows
programmers were unaware that it exist at all.
OTOH there is a lot of info about Linux systems
calls.

You later wrote that you are interested in C90
programs. "Well behaved" C90 program is supposed
to use library functions and to dynamically link
to C library, both on Windows and Linux. On Linux
setting environment so that program uses your C
library instead of provided one require some effort
(there are several details that need to be done)
but is entirely unprivileged operation.

One more thing: on modern systems when program does
INT 80H (or say INT 21H) what happens is general
protection fault. So it is enough to set up exactly
one interrupt vector, namly the one which handles
general protection fault. But this handler must
handle a lot of things, which slows down handling
of system calls, so there is tendency to avoid
using INT instruction as system call interface.
However, if you want to stick to old ways and
use INT, that what you really want is that
system general protection fault handler recognizes
INT instruction and passes control to your program.
In Linux for INT 21H this is easy, because INT 21H
is treated as illegal instruction and system calls
appropriate signal handler in your program (if you
do not set up a hander your program would crash).
With INT 80H it is a bit more complicated, as
normally Linux fault handler would treat it as
system call. But you can use system call interception
to handle system calls in your code.
--
Waldek Hebisch
Rod Pemberton
2021-07-02 10:06:06 UTC
Permalink
On Thu, 1 Jul 2021 12:46:26 +0000 (UTC)
Post by a***@math.uni.wroc.pl
[...]
You later wrote that you are interested in C90
programs. "Well behaved" C90 program is supposed
to use library functions and to dynamically link
to C library, both on Windows and Linux.
I disagree.

There is no need for a "well behaved" C90 program to use C library
functions, as many C library functions are "well behaved", especially
those that are not host dependent, because the C library functions only
use the C language proper. Therefore, you can conclude that any C90
program, even if it doesn't use the C library, is "well behaved", since
the library is built upon the C language proper, and the language is
"well behaved". It's only when operating underneath an operating
system (OS) which implements host specific behaviors and OS specific
behaviors, that a C90 program needs to call the OS specific C library
to become "well behaved" with the OS.
--
What is hidden in the ground, when found, is hidden there again?
Loading...