Тёмный

Using the MS-DOS 4 release to compile programs 

Подписаться
Просмотров 6 тыс.
% 265

Someone had asked me if it was possible to use the Microsoft MS-DOS 4.00 source code release to compile new programs.
And that's an interesting question, because as I showed in my other video at the time, the BAK (the Binary Adaptability Kit) includes a C compiler and an assembler so it could compile the source code.
So the short answer is Yes, you can use the Microsoft C compiler they included in the source code release to compile your own programs. The C compiler is provided as binary only, no source code, but it's a working C compiler.
So let's look at how you can use the C compiler there to compile your own programs.
Visit our website
www.freedos.org/
Join us on Facebook
groups/freedosproject/
Follow us on Mastodon
fosstodon.org/@freedosproject
Consider supporting me on Patreon
www.patreon.com/freedos
And don't forget to Like and Subscribe!
Standard comment rules apply.

Наука

Опубликовано:

 

20 май 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 39   
@kenielf
@kenielf 4 месяца назад
For absolutely no practical reason, I'd love to see a benchmark between ms-dos 4 and current free dos. It'd be great to see how it differs - even when virtualized
@OpenGL4ever
@OpenGL4ever 2 месяца назад
I created a small program that prints 9 lines of ASCII text including a date consisting of the day, month and year to stdout and then exits. Here is the result of executable size comparison (all files are stripped and thus without debugger symbols). (DJGPP) GCC 4.7.1 = 60928 Bytes Open Watcom C/C++ 1.9 = 14076 Bytes Microsoft C 5.10 = 10099 Bytes Note that the two binaries generated by the Open Watcom and Microsoft compilers could fit into the 16 KiB L1 cache of the late i486 and Pentium processors. If the program were running in a loop, that alone would be relevant to performance. The GCC binary doesn't even fit into the 32 KiB L1 cache of the Pentium 2. Only the L2 cache is large enough starting with the Pentium Pro. All programs run in Real Mode on an 8086, except the GCC binary, which requires a 386 and a DJGPP go32 DOS extender. It is therefore the only one that is written in 32 bits. The other two are 16 bits. The almost identical program written in Real Mode *assembler,* but without the function for reading the date, requires less than 350 bytes.
@MattKasdorf
@MattKasdorf 4 месяца назад
Just stumbled across this video, you make a great teacher.
@freedosproject
@freedosproject 4 месяца назад
Thanks, I'm glad you think so 😃
@ahmad-murery
@ahmad-murery 4 месяца назад
Nice video as usual, Programming sessions are always welcome and I expect there will be more to come(I hope) Thanks Jim!
@freedosproject
@freedosproject 4 месяца назад
More to come. I'm trying not to be "all programming all the time" but we'll definitely come back to more programming exmaples.
@ahmad-murery
@ahmad-murery 4 месяца назад
@@freedosproject 👍💯
@OpenGL4ever
@OpenGL4ever 4 месяца назад
I already extracted the MS C compiler, its libs and include files and the additional tools and MASM from the MS-DOS 4 release a couple of weeks ago, when the source code of MS-DOS 4 was released.
@alexandershendi7428
@alexandershendi7428 4 месяца назад
A question: the provided multitasking version of MS-DOS stops other programs wenn you use "normal" DOS EXEs. Can the Microsoft compiler produce Windows-style "new" executables that you could concurrently? Thank you for the video!
@SlideRSB
@SlideRSB 4 месяца назад
I think you may have missed a sys directory inside the headers directory.
@freedosproject
@freedosproject 4 месяца назад
Oops, I did! The 'sys' directory contains locking.h, stat.h, timeb.h, types.h and utime.h. I didn't spot that when I looked at the DIR listing.
@MonochromeWench
@MonochromeWench 4 месяца назад
Sure it's nice that Microsoft released this but why would you want to use it when we have OpenWatcom that can target 16bit dos and supports a relatively modern C standard. I guess this might be useful if cl itself actually is 16 bit and you absolutely need to compile a program on an AT or an XT. Benchmark comparison might be interesting but it seems unlikely this old compiler could win but maybe it has optimizations better targeted to 8086 and 80286 cpus than what you'd find in a 32 bit compiler.
@OpenGL4ever
@OpenGL4ever 4 месяца назад
One reason could be better compatibility with old programming books written for the Microsoft C compiler. Not all early C compilers were ANSI compatible. Some had their proprietary extensions. Another one could be lower RAM requirements. It may require less RAM than the 16-bit version of gcc. When it comes to code optimization, especially program speed, modern compilers are probably better. However, the MS compiler could have been optimized for generated program code size since memory was expensive back then. In the end you will have to test it and directly compare who performs better where. In any case, the later 32-bit C compilers from Microsoft for Windows were still very bad at the time. They were only significantly improved after the release of Windows NT 3.1. Which meant that Windows NT 3.5 ran significantly more efficiently than its predecessor. The slow speed of Windows NT 3.1 was the main reason for Microsoft to improve the compiler.
@freedosproject
@freedosproject 4 месяца назад
I agree, I prefer the newer open source compilers like OpenWatcom and IA-16 GCC. We also have BCC and a few other open source compilers that are older but work fine. The MS compiler is interesting for some. And it's interesting that they included the binaries for free in the MS-DOS 4.00 BAK source code release. Another legit free (gratis) proprietary compiler is Borland Turbo C 2.01 and Borland Turbo C++ 1.01, which you can download from Embarcadero's museum, if you don't mind registering a free account with them. We have a link to them from our website under the 'Developer' section. Works great on FreeDOS - I did a video a while back about TurboC++ on FreeDOS and the IDE was super slow in that video because it doesn't run well under JEMMEX; boot "without drivers" and the IDE runs fine.
@zoomosis
@zoomosis 4 месяца назад
Borland also released a version of Turbo C++ as freeware years ago which is arguably an easier compiler to use if all you want is to target 16-bit DOS.
@grappydingus
@grappydingus 4 месяца назад
I await the ultimate showdown! Which is better ed or edlin!
@freedosproject
@freedosproject 4 месяца назад
OMG, I should totally do a video on that! :-)
@plato4ek
@plato4ek 2 месяца назад
16:02 the INC directory contains SYS subdirectory
@simpleprogrammingcodes
@simpleprogrammingcodes 4 месяца назад
I noticed that this compiler can understand the modern syntax for the function parameters, and it's a 1986 compiler, before K&R 2. When was the new syntax introduced and when did it become the norm for a compiler to support it?
@zoomosis
@zoomosis 4 месяца назад
Microsoft C 5.1 shown in this video is from 1988, the same year MS-DOS 4.0 was released. ANSI/ISO C was ratified two years later. From memory MSC 5.0 was their first to support ANSI/ISO C. Trivia: Most of the early OS/2 1.x C source code from 1986-7 was written in K&R syntax.
@Maxjoker98
@Maxjoker98 4 месяца назад
Why is the second version of the array.exe program 10x smaller? At 18:22 it's ~700 bytes, while at 14:00 it's ~7kB.
@TSteffi
@TSteffi 4 месяца назад
I was curious after seeing this comment, but watching closely, the second .EXE was around 7k, too.
@Maxjoker98
@Maxjoker98 4 месяца назад
@@TSteffi Oh, I must have read the wrong row. My bad!
@freedosproject
@freedosproject 4 месяца назад
@@Maxjoker98 No problem. 🙂 In fact, the [corrected] ARRAY.EXE at 14:16 is 7,825 .. and after copying the libs and includes, the recompiled ARRAY.EXE at 19:04 is also 7,825. So it's the same size (i.e. nothing "broke" when copying files to a new "CC" directory)
@MasterH2005
@MasterH2005 4 месяца назад
I know this is gonna sound strange, considering the fact that DOS is mainly a CLI OS, but is it possible to get a desktop environment running on FreeDOS?
@maciejstachowski183
@maciejstachowski183 4 месяца назад
Windows 3.1 seems to work with some tinkering. DESQView I think runs out of the box, but I haven't tried it.
@freedosproject
@freedosproject 4 месяца назад
You can run Windows 3.x in Standard Mode on FreeDOS. Jeremy (kernel developer) has an in-development version of the FreeDOS kernel that runs Windows 3.11 in Enhanced Mode .. I'm hoping that can get released so we can share it. But you can find it in his GitHub. You can also use other graphical environmnets on FreeDOS, too. See my other videos for OpenGEM and Seal.
@maxmuster7003
@maxmuster7003 4 месяца назад
Very good.
@aintaintaword666
@aintaintaword666 4 месяца назад
13:18 Why did the program work? I imagined it should have crashed right after that null pointer assignment?
@tehlaser
@tehlaser 4 месяца назад
Ah, the joys of undefined behavior. “Everything appears to work just fine at first, but then sometime later something weird happens” is surprisingly common.
@hubstrangers3450
@hubstrangers3450 4 месяца назад
Thank you...
@Australian_Made
@Australian_Made 4 месяца назад
😎👌
@snap_oversteer
@snap_oversteer 4 месяца назад
Nice video as always, I have never properly programmed in C under DOS but the usage of malloc got me thinking, when it's running (presumably) in real mode you're limited to what's left of 640K base memory, right? And if I wanted to use more memory I'd have to use a different compiler that can produce programs that run in protected/enhanced mode.
@rugxulo
@rugxulo 4 месяца назад
No, you could (manually??) use EMS or XMS (286+), if available. Or use overlays or swap to disk.
@zoomosis
@zoomosis 4 месяца назад
You also can't allocate more than 64K at a time unless you use the "huge" memory model. The easiest way around both this and the 640K limit is to use Watcom's wcl386 compiler to build 32-bit DOS4G executables.
@SensualSquirrel
@SensualSquirrel 4 месяца назад
What's lib short for?
@OpenGL4ever
@OpenGL4ever 4 месяца назад
library
@SensualSquirrel
@SensualSquirrel 4 месяца назад
@@OpenGL4ever yet it never gets pronounced correctly