Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2013-09

Why development remains constant for msdos?

29 messages · 12 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Junior

Why development remains constant for msdos?

Is there a human being who uses msdos yet?

I see constant updating in fpc 2.7.1 for msdos, was in doubt so I'm asking the question out of curiosity.

thanks

Reply by email

Unknown author
Junior wrote
Is there a human being who uses msdos yet?

yes, there are still quitet many DOS systems out there... there's even freeDOS and similar FOSS(?) DOS projects... some of them are even 32bit and can use all available memory like other OSes of today ;)

Reply by email

Nikolay Nikolov
to Florian Klämpfl: Because somebody wants to do so. No more, no less.
Florian Kl?mpfl wrote
Am 22.09.2013 13:46, schrieb Junior: > Why development remains constant for msdos? Because somebody wants to do so. No more, no less.

As the person working on the i8086-msdos port, here's the story how it all started: I wanted to learn how FPC code generators work by porting it to a new architecture, but I didn't have any computer in my home with a CPU that isn't supported already (well, except for 6502 :) ). So porting to a new architecture would require buying some exotic hardware from eBay (say, an Itanium or SPARC64) that'll likely be already obsolete in a few years anyway. And one day it occurred to me that I could try an i8086 port. It seemed perfect to me for the following reasons:

1) while, you may consider 16-bit x86 dead, it never really died in the sense that every modern x86 processor (including 64-bit ones) supports it in real mode. In fact, unless you have an UEFI system, 16-bit code is always executed at some point during the boot process, because that's how the BIOS boots the system - it loads the first sector from the hard disk at address 0000h:7C00h and jumps to it in 16-bit real mode. In fact, modern machines are able to boot DOS and it works without issues. If it didn't, boot loaders of modern operating systems wouldn't work either. So, in 5 years, everybody will have a machine that is able to execute i8086 code (and thus, able to test and maintain the port), but that may not be the case for e.g. Itanium or SPARC64. Also, there are plenty of virtual machines available, where you can install DOS and test it. There's also DOSBox. In fact, you can run the FPC testsuite for i8086-msdos on any 32-bit or 64-bit linux _or_ windows via DOSBox.
2) I didn't need to learn an entirely new instruction set and OS API, since I'm already familiar with them, so I could focus only on the compiler itself.
3) There isn't a 16-bit x86 pascal compiler that is free/open source. Borland Pascal is proprietary and while you can download old versions for free from the Embarcadero museum site, the latest version available gratis is 5.5. You can't legally use 7.0, unless you bought it back then and even if you did, you don't have the sources to the compiler, so you can't fix bugs in it and improve it.
4) Since x86 compatibility goes all the way back to 16-bit, if FPC would support it could claim to be the first compiler which supports the full x86 range going all the way from 16-bit up to 64-bit. It's something unique and cool :)
OpenWatcom may be the only other compiler that is able to do it, since they haven't dropped 16-bit support and are supposedly working on 64-bit, but their 64-bit port is still not ready AFAIK. And of course GCC and LLVM are extremely unlikely to do such a crazy thing as a 16-bit port. :)

It all started semi-seriously, I just wanted to see how difficult it would be to do the port, but I soon reached the point of no return, where I had almost got it working and I just had to keep working on it in order to get that next feature going, etc. And also, I'm having a lot of fun, while working on it. I also bought some vintage 16-bit machines from eBay for the extra fun and motivation :)

As for people still using DOS, there's still a community of people using it for fun or for nostalgia reasons. Check out:

http://www.bttr-software.de/forum/forum.php

There's also the FreeDOS project, which was already mentioned by another poster: http://www.freedos.org/

Also note that DOS has always been supported by FPC via the go32v2 dos extender (ok, it might have been go32v1 when fpc was started), but it has always been 32-bit and thus requiring at least a 386. Only the 16-bit DOS support is new.

Nikolay

Reply by email

Junior
to Unknown author: yes, there are still quitet many DOS systems out there... there's even freeDOS and…

That's incredible, I knew not!

thanks

Show quoted text 12 lines
On Sunday, September 22, 2013 7:46 AM, Junior wrote: > Is there a human being who uses msdos yet? yes, there are still quitet many DOS systems out there... there's even freeDOS and similar FOSS(?) DOS projects... some of them are even 32bit and can use all available memory like other OSes of today ;) -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Kostas Michalopoulos
to Nikolay Nikolov: As the person working on the i8086-msdos port, here's the story how it all started: I…
Nikolay Nikolov wrote
OpenWatcom may be the only other compiler that is able to do it, since they haven't dropped 16-bit support and are supposedly working on 64-bit, but their 64-bit port is still not ready AFAIK.

FWIW, there is an OpenWatcom fork which is under more active development than the "main" one and has 64bit support there:
http://sourceforge.net/projects/openwatcom/. I haven't tried the 64bit support myself though.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130923/84b55fc0/attachment.html>

Reply by email

Nikolay Nikolov
to Kostas Michalopoulos
Kostas Michalopoulos wrote 12 lines
On Mon, Sep 23, 2013 at 4:47 PM, Nikolay Nikolov < <mailto:>> wrote: OpenWatcom may be the only other compiler that is able to do it, since they haven't dropped 16-bit support and are supposedly working on 64-bit, but their 64-bit port is still not ready AFAIK. FWIW, there is an OpenWatcom fork which is under more active development than the "main" one and has 64bit support there: http://sourceforge.net/projects/openwatcom/. I haven't tried the 64bit support myself though.

Interesting. I didn't know about it. From the features list:

"DOS version of tools now support long file names (LFN) if appropriate LFN driver is loaded by DOS"

Maybe we could use their linker for our go32v2 hosted crosscompiler to i8086.

Nikolay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130923/ec8873a0/attachment-0001.html>

Reply by email

Nikolay Nikolov
to Michael Schnell
Michael Schnell wrote 9 lines
On 09/22/2013 10:40 PM, wrote: > yes, there are still quitet many DOS systems out there... there's > even freeDOS and similar FOSS(?) DOS projects... some of them are > even 32bit and can use all available memory like other OSes of today ;) How does fpc for DOS handle TThread ? Just curious...

When you try to create a thread, your program terminates and writes a message that threading is not supported. Things like threadvar work in the sense that they compile and work, but since you don't have threads, they behave just like regular vars. Underneath they still generate the extra bloat needed for threadvars (e.g. calls to FPC_THREADVAR_RELOCATE, which are probably stubs and do nothing in the rtl)

Nikolay

Reply by email

Sven Barth
to Nikolay Nikolov
Nikolay Nikolov wrote 18 lines
On 24.9.2013 ?. 10:42, Michael Schnell wrote: > On 09/22/2013 10:40 PM, wrote: >> yes, there are still quitet many DOS systems out there... there's >> even freeDOS and similar FOSS(?) DOS projects... some of them are >> even 32bit and can use all available memory like other OSes of today ;) > > > How does fpc for DOS handle TThread ? > > Just curious... When you try to create a thread, your program terminates and writes a message that threading is not supported. Things like threadvar work in the sense that they compile and work, but since you don't have threads, they behave just like regular vars. Underneath they still generate the extra bloat needed for threadvars (e.g. calls to FPC_THREADVAR_RELOCATE, which are probably stubs and do nothing in the rtl)

Maybe we should adjust the compiler that it treats threadvars really like normal vars if the target does not support threading...

Regards,
Sven

Reply by email

Nikolay Nikolov
to Sven Barth
Sven Barth wrote 16 lines
Am 24.09.2013 10:58, schrieb Nikolay Nikolov: > On 24.9.2013 ?. 10:42, Michael Schnell wrote: >> >> How does fpc for DOS handle TThread ? >> >> Just curious... > > When you try to create a thread, your program terminates and writes a > message that threading is not supported. Things like threadvar work > in the sense that they compile and work, but since you don't have > threads, they behave just like regular vars. Underneath they still > generate the extra bloat needed for threadvars (e.g. calls to > FPC_THREADVAR_RELOCATE, which are probably stubs and do nothing in > the rtl) Maybe we should adjust the compiler that it treats threadvars really like normal vars if the target does not support threading...

Yes, that's a good idea and in fact I was planning to do it, since it'll save precious space in the i8086 small and tiny memory models (and perhaps the embedded targets also), but I still haven't done it, due to other things with higher priority.

Nikolay

Reply by email

Kavalenka Anton
to Nikolay Nikolov: As the person working on the i8086-msdos port, here's the story how it all started: I…

BTW - i have a port of Turbovision -like library called GraphVision (with sources) - window system built entirely on graph unit. I think it is possible to create Lazarus widgetset wrapped around this DOS GUI system.
I'll ask the author - if he agrees to give it out for community.

Nikolay Nikolov wrote 78 lines
On 22.9.2013 ?. 14:59 ?., Florian Kl?mpfl wrote: > Am 22.09.2013 13:46, schrieb Junior: > >> Why development remains constant for msdos? >> > Because somebody wants to do so. No more, no less. > As the person working on the i8086-msdos port, here's the story how it all started: I wanted to learn how FPC code generators work by porting it to a new architecture, but I didn't have any computer in my home with a CPU that isn't supported already (well, except for 6502 :) ). So porting to a new architecture would require buying some exotic hardware from eBay (say, an Itanium or SPARC64) that'll likely be already obsolete in a few years anyway. And one day it occurred to me that I could try an i8086 port. It seemed perfect to me for the following reasons: 1) while, you may consider 16-bit x86 dead, it never really died in the sense that every modern x86 processor (including 64-bit ones) supports it in real mode. In fact, unless you have an UEFI system, 16-bit code is always executed at some point during the boot process, because that's how the BIOS boots the system - it loads the first sector from the hard disk at address 0000h:7C00h and jumps to it in 16-bit real mode. In fact, modern machines are able to boot DOS and it works without issues. If it didn't, boot loaders of modern operating systems wouldn't work either. So, in 5 years, everybody will have a machine that is able to execute i8086 code (and thus, able to test and maintain the port), but that may not be the case for e.g. Itanium or SPARC64. Also, there are plenty of virtual machines available, where you can install DOS and test it. There's also DOSBox. In fact, you can run the FPC testsuite for i8086-msdos on any 32-bit or 64-bit linux _or_ windows via DOSBox. 2) I didn't need to learn an entirely new instruction set and OS API, since I'm already familiar with them, so I could focus only on the compiler itself. 3) There isn't a 16-bit x86 pascal compiler that is free/open source. Borland Pascal is proprietary and while you can download old versions for free from the Embarcadero museum site, the latest version available gratis is 5.5. You can't legally use 7.0, unless you bought it back then and even if you did, you don't have the sources to the compiler, so you can't fix bugs in it and improve it. 4) Since x86 compatibility goes all the way back to 16-bit, if FPC would support it could claim to be the first compiler which supports the full x86 range going all the way from 16-bit up to 64-bit. It's something unique and cool :) OpenWatcom may be the only other compiler that is able to do it, since they haven't dropped 16-bit support and are supposedly working on 64-bit, but their 64-bit port is still not ready AFAIK. And of course GCC and LLVM are extremely unlikely to do such a crazy thing as a 16-bit port. :) It all started semi-seriously, I just wanted to see how difficult it would be to do the port, but I soon reached the point of no return, where I had almost got it working and I just had to keep working on it in order to get that next feature going, etc. And also, I'm having a lot of fun, while working on it. I also bought some vintage 16-bit machines from eBay for the extra fun and motivation :) As for people still using DOS, there's still a community of people using it for fun or for nostalgia reasons. Check out: http://www.bttr-software.de/**forum/forum.php<http://www.bttr-software.de/forum/forum.php> There's also the FreeDOS project, which was already mentioned by another poster: http://www.freedos.org/ Also note that DOS has always been supported by FPC via the go32v2 dos extender (ok, it might have been go32v1 when fpc was started), but it has always been 32-bit and thus requiring at least a 386. Only the 16-bit DOS support is new. Nikolay -- ______________________________**_________________ Lazarus mailing list .**freepascal.org http://lists.lazarus.**freepascal.org/mailman/**listinfo/lazarus<http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130925/ae7fbc26/attachment-0001.html>

Reply by email

Michael Schnell
to Nikolay Nikolov: When you try to create a thread, your program terminates and writes a message that…
Nikolay Nikolov wrote
When you try to create a thread, your program terminates and writes a message that threading is not supported.

While this absolutely does make sense, one could think about alternatives.

AFAIK, (at least for some archs) there is a variant of the pthread (="POSIX thread") library, that internally does "user-land multithreading". IIRC, the original POSIX definition was done with exactly this in mind and, regarding Linux, the original Linux implementations (aka "Linux Threads") was not fully compatible with POSIX. Only some years ago, the Linux changed it's way of Kernel-based thread handling to the POSIX compatible "NPTL" implementation.

Thus it should be possible to link fpc projects to a user-land thread enabled version of pthreadlib and allow for working with TThread in DOS.

-Michael

Reply by email

Hans-Peter Diettrich
to Michael Schnell
Show quoted text 17 lines
On 09/24/2013 10:58 AM, Nikolay Nikolov wrote: > > When you try to create a thread, your program terminates and writes a > message that threading is not supported. While this absolutely does make sense, one could think about alternatives. AFAIK, (at least for some archs) there is a variant of the pthread (="POSIX thread") library, that internally does "user-land multithreading". IIRC, the original POSIX definition was done with exactly this in mind and, regarding Linux, the original Linux implementations (aka "Linux Threads") was not fully compatible with POSIX. Only some years ago, the Linux changed it's way of Kernel-based thread handling to the POSIX compatible "NPTL" implementation. Thus it should be possible to link fpc projects to a user-land thread enabled version of pthreadlib and allow for working with TThread in DOS.

Do you mean DOS as a (16 bit) OS, or as a DOS-Box (terminal)?

I doubt that a DOS OS supports threading at all (scheduling...). What's a thread worth when it never executes?

DoDi

Reply by email

Mark Morgan Lloyd
to Michael Schnell: While this absolutely does make sense, one could think about alternatives. AFAIK, (at…
Michael Schnell wrote 17 lines
On 09/24/2013 10:58 AM, Nikolay Nikolov wrote: > > When you try to create a thread, your program terminates and writes a > message that threading is not supported. While this absolutely does make sense, one could think about alternatives. AFAIK, (at least for some archs) there is a variant of the pthread (="POSIX thread") library, that internally does "user-land multithreading". IIRC, the original POSIX definition was done with exactly this in mind and, regarding Linux, the original Linux implementations (aka "Linux Threads") was not fully compatible with POSIX. Only some years ago, the Linux changed it's way of Kernel-based thread handling to the POSIX compatible "NPTL" implementation. Thus it should be possible to link fpc projects to a user-land thread enabled version of pthreadlib and allow for working with TThread in DOS.

The change happened at different times on different architectures. I've definitely had to write (Lazarus) code to take this into account, since the PID behaviour differed.

But since AIUI LinuxThreads generally attempted to use multiple processes, getting that to work on DOS might be a problem. It would probably be easier to start off with coroutines, and then to change them into real threads by preemption.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Reinier Olislagers
to Hans-Peter Diettrich: Do you mean DOS as a (16 bit) OS, or as a DOS-Box (terminal)? I doubt that a DOS OS…
Hans-Peter Diettrich wrote
Michael Schnell schrieb: Do you mean DOS as a (16 bit) OS, or as a DOS-Box (terminal)?

As the thread indicates: DOS as in 16 bit DOS, runnable on an 8086 processor. Yes, the compiler could run in the DOSBox product (which emulates the environment 16 bit DOS runs under) but not in a cmd/command window/"DOS" window on e.g. x64 Windows Vista+

Reply by email

Reinier Olislagers
to Reinier Olislagers
Reinier Olislagers wrote 8 lines
On 25/09/2013 10:51, Hans-Peter Diettrich wrote: > Michael Schnell schrieb: > Do you mean DOS as a (16 bit) OS, or as a DOS-Box (terminal)? As the thread indicates: DOS as in 16 bit DOS, runnable on an 8086 processor. Yes, the compiler could run in the DOSBox product (which emulates the environment 16 bit DOS runs under) but not in a cmd/command window/"DOS" window on e.g. x64 Windows Vista+

Oops, sorry. No idea if the compiler could run on 8086, I seem to remember Nikolay implemented a cross compiler because (I think) the compiler needed more memory than could easily be gotten from DOS... Anyway, obviously the resulting code /is/ targeted for 8086...

Reply by email

Nikolay Nikolov
to Michael Schnell: While this absolutely does make sense, one could think about alternatives. AFAIK, (at…
Michael Schnell wrote 18 lines
On 09/24/2013 10:58 AM, Nikolay Nikolov wrote: > > When you try to create a thread, your program terminates and writes a > message that threading is not supported. While this absolutely does make sense, one could think about alternatives. AFAIK, (at least for some archs) there is a variant of the pthread (="POSIX thread") library, that internally does "user-land multithreading". IIRC, the original POSIX definition was done with exactly this in mind and, regarding Linux, the original Linux implementations (aka "Linux Threads") was not fully compatible with POSIX. Only some years ago, the Linux changed it's way of Kernel-based thread handling to the POSIX compatible "NPTL" implementation. Thus it should be possible to link fpc projects to a user-land thread enabled version of pthreadlib and allow for working with TThread in DOS.

I've actually thought about implementing some sort of multithreading for DOS for a long time. The problems are the following:

1) DOS functions are not reetrant and are thus not safe to call from different threads. There's an undocumented InDOS flag that indicates whether a DOS function is safe to call:

http://stanislavs.org/helppc/int_21-34.html

But the RTL currently doesn't check it before every call and normally it's only used when writing TSRs.

2) In DPMI protected mode applications (such as go32v2), you cannot modify the return address from within an interrupt handler, which means you cannot implement your task scheduler as a timer interrupt handler, because you won't be able to switch to a different context from there. Doing this would require modifications to the DPMI host (cwsdpmi.exe) and will not work if another DPMI host is active (such as when running in a windows dos prompt, etc.)

3) Even if you solve 2), DPMI requires that all code and data touched from an interrupt handler to be locked, so that it cannot be swapped out. This is a tedious and error prone task to do from a high level language such as pascal. You should ensure that your entire scheduler's code and data are locked. An alternative option is to switch to a DPMI host, that doesn't support swapping (i.e. cwsdpr0.exe), but then you lose the virtual memory support (and thus the ability to run on machines that don't have enough memory).

2) and 3) do not apply to 16-bit MS-DOS.

Another option is to implement cooperative multitasking, which would require each thread to call periodically an yield function. This solves 1), 2) and 3), but threaded code written for other OSes will require modifications to run under DOS. However, that's still better than not

Reply by email

Reinier Olislagers
to Michael Schnell
Michael Schnell wrote 8 lines
On 09/25/2013 10:51 AM, Hans-Peter Diettrich wrote: > > Do you mean DOS as a (16 bit) OS, or as a DOS-Box (terminal)? Of course limited to a "DOS box" this would make no sense at all. I did not do a research on in what environments such pthreadlib could work. I suppose you need a 32 bit DOS extender.

You do know there already is a GO32v2 compiler?

Reply by email

Mark Morgan Lloyd
to Nikolay Nikolov: I've actually thought about implementing some sort of multithreading for DOS for a long…
Nikolay Nikolov wrote 31 lines
On 09/25/2013 11:26 AM, Michael Schnell wrote: > On 09/24/2013 10:58 AM, Nikolay Nikolov wrote: >> >> When you try to create a thread, your program terminates and writes a >> message that threading is not supported. > > While this absolutely does make sense, one could think about > alternatives. > > AFAIK, (at least for some archs) there is a variant of the pthread > (="POSIX thread") library, that internally does "user-land > multithreading". IIRC, the original POSIX definition was done with > exactly this in mind and, regarding Linux, the original Linux > implementations (aka "Linux Threads") was not fully compatible with > POSIX. Only some years ago, the Linux changed it's way of Kernel-based > thread handling to the POSIX compatible "NPTL" implementation. > > Thus it should be possible to link fpc projects to a user-land thread > enabled version of pthreadlib and allow for working with TThread in DOS. I've actually thought about implementing some sort of multithreading for DOS for a long time. The problems are the following: 1) DOS functions are not reetrant and are thus not safe to call from different threads. There's an undocumented InDOS flag that indicates whether a DOS function is safe to call: http://stanislavs.org/helppc/int_21-34.html But the RTL currently doesn't check it before every call and normally it's only used when writing TSRs.

It's more complex than that: there's undocumented provision in DOS for context switching under certain well-defined conditions, and each context can invoke int 21h irrespective of other contexts' states. That sort of thing was used fairly extensively by- for example- IBM real-time control executives (RIC card etc.) but it wasn't until the 1990s that it leaked to general knowledge see Ralph Brown's list).

Show quoted text 24 lines
2) In DPMI protected mode applications (such as go32v2), you cannot modify the return address from within an interrupt handler, which means you cannot implement your task scheduler as a timer interrupt handler, because you won't be able to switch to a different context from there. Doing this would require modifications to the DPMI host (cwsdpmi.exe) and will not work if another DPMI host is active (such as when running in a windows dos prompt, etc.) 3) Even if you solve 2), DPMI requires that all code and data touched from an interrupt handler to be locked, so that it cannot be swapped out. This is a tedious and error prone task to do from a high level language such as pascal. You should ensure that your entire scheduler's code and data are locked. An alternative option is to switch to a DPMI host, that doesn't support swapping (i.e. cwsdpr0.exe), but then you lose the virtual memory support (and thus the ability to run on machines that don't have enough memory). 2) and 3) do not apply to 16-bit MS-DOS. Another option is to implement cooperative multitasking, which would require each thread to call periodically an yield function. This solves 1), 2) and 3), but threaded code written for other OSes will require modifications to run under DOS. However, that's still better than not DPMI issue sounds... interesting, but if I recall correctly what you

do is provide a per-thread entry point analogous to a unix signal. A preemption interrupt transfers control to this, and then a coroutine mechanism- outside the ISR- transfers control to the most deserving thread.

Sorry if that's a bit vague, it's been many years since I played with this. Implementation left as an exercise :-)

Whether it's really worth tackling, and whether any implementation can be really reliable, are questions to be considered.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Nikolay Nikolov
to Michael Schnell
Michael Schnell wrote 6 lines
On 09/25/2013 01:00 PM, Nikolay Nikolov wrote: > > Real mode or DPMI? IMHO, real mode is doable, DPMI - not so much (at > least not without using a certain DPMI host with special modifications). Did DPMI even exist at this time ?

15 years ago is 1998, so yes. Maybe it was even earlier?

IIRC it was a native 8088 chip -> http://en.wikipedia.org/wiki/Intel_8088

Real mode it is, then. DPMI requires 286+ and the DOS extender that FPC uses is 386+. Borland Pascal 7 had a 16-bit (286+) DPMI dos extender. We can implement that as well, as soon as the i8086 large memory model is finished. The Open Watcom linker we're using already supports the DOS/16M extender binary format I think.

Nikolay

Reply by email