How I write programs on FreeDOS

Поділитися
Вставка
  • Опубліковано 16 бер 2023
  • Some folks have asked how I set up my FreeDOS programming environment for my programming videos, so I wanted to do a video just on that.
    The short version is I edit the OWSETENV.BAT file to add an ALIAS command for FED. That way, if I can't run FED, I know my environment isn't set up right. And it saves one more entry in the PATH.
    Visit our website
    www.freedos.org/
    Join us on Facebook
    / freedosproject
    Follow us on Mastodon
    fosstodon.org/@freedosproject
    Consider supporting me on Patreon
    / freedos
    And don't forget to Like and Subscribe!
    Standard comment rules apply.
  • Наука та технологія

КОМЕНТАРІ • 73

  • @Snufflegrunt
    @Snufflegrunt Рік тому +20

    I adore DOS still being used, for “real work” or fun, it’s still great.

  • @ahmad-murery
    @ahmad-murery Рік тому +8

    Using alias is like creating an in-memory shortcut I think,
    It's really a good way to keep our path list clean and safe.
    Looking forward form more programming related videos.
    Thanks Jim,

    • @freedosproject
      @freedosproject  Рік тому +3

      Glad you liked it!

    • @OpenGL4ever
      @OpenGL4ever Рік тому

      The problem is, aliases do only work in FreeDOS 1.3. They do not work in MS-DOS or DR-DOS. And this is the reason, why is use a different approach. Read my comment in my own thread above. There i described it.

  • @martinhardy7659
    @martinhardy7659 Рік тому +3

    Wow 😳😲 a package mgr for DOS. Incredible!

    • @freedosproject
      @freedosproject  Рік тому +2

      Jerome did a great job with FDIMPLES ☺

    • @OpenGL4ever
      @OpenGL4ever Рік тому

      @@freedosproject Yes, but I would prefer FDIMPLES to work with catalog files that allow them to be installed on hard disk. This would allow the user to browse the catalog without having to insert the appropriate CD-ROM into the CD-ROM drive.
      It is very inconvenient to have to change the inserted CD-ROM every time just because a certain package is on the second FreeDOS installation CD. It would be easier if you could see in advance which CD-ROM contains which package, and for this it would be necessary to install the catalogs on the hard disk.

  • @CasperLabuschagne
    @CasperLabuschagne 10 місяців тому +1

    From the late 1980's until 2004 when I moved lock-stock-and-barrel to the first version of Ubuntu, I used an editor VDE with Wordstar commands similar to the Borland editors. I could rapidly change between editing and compile modes with a keystroke sequence and spent years with pascal programs edited in VDE and compiled from the command line. Apart from that VDE is a very fast, highly capable editor and will be well worth a review. There used to be a Google Sites page dedicated to VDE that is still available on the Internet Archive. There is also an actively shared torrent file with the VDE binaries.

  • @joepike1972
    @joepike1972 Рік тому +4

    That was brief and useful. Thank you for sharing it.

    • @freedosproject
      @freedosproject  Рік тому

      Glad it was helpful! Some folks have asked about it, so I figured I should finally do a video about it.

  • @thisisreallyme3130
    @thisisreallyme3130 Рік тому +8

    Hey Jim, Thank you for these and all the work you do. This almost exceeds the sum of all other retro platform activities. Although, worth noting DOS is still used and not just for nostalgia. Off you’re ever looking for topic ideas, I’d love to see more about build automation (GitHub actions), and how to structure your code (for something you’ve done) if you were targeting another platform. There’s lots of cool stuff targeting Amiga and Atari ST, or console Linux, that would be nice to have. Sorry for so many ideas, been meaning to post for a while, cheers.
    Also, can Freedos boot an image off the internet (like if you built remotely) or is that something nobody has built yet?

    • @freedosproject
      @freedosproject  Рік тому +4

      I can definitely do a video about writing code that will target both FreeDOS and Linux as different build environments. That would be a good opportunity to talk about "#if defined(__)" in a program, such as writing a function that picks a random number using rand() on DOS, but getrandom() on Linux. I'll add that to the list!
      I don't know if FreeDOS can be loaded as a PXE boot, I've never tried.

    • @OpenGL4ever
      @OpenGL4ever Рік тому +1

      @@freedosproject I tried it with PXE on a server mainboard with a IPMI BMC module and it works. But the old FreeDOS 1.2 CD wasn't a live CD. Thus i had to create a DOS system running from a USB stick and boot normally.

  • @bigbrothertw
    @bigbrothertw Рік тому +1

    i recently started my programming journey and i have to admit the novelty of practising my C in dos has definitely made it more exciting

    • @freedosproject
      @freedosproject  Рік тому +4

      Thanks! Programming on DOS definitely comes with some interesting limitations. For example, sometimes I see programmers on Linux or Windows who load an entire file into memory just to do some simple task (like look up a single value in a config file .. or in an extreme case, just to convert the entire file to lowercase). And they do that because on modern systems, memory is "cheap." But you can't take that approach on DOS because of memory limitations. So you need to be more careful and intentional about how you write DOS programs. I find it makes for a more interesting programming challenge.

    • @chastitywhiterose
      @chastitywhiterose 7 місяців тому

      @@freedosprojectQuite right. The limitations are what make it a special challenge. I used QBASIC many years ago and learned more because I had limitations to make me be creative. Now I am trying to do C programming on DOS because I haven’t had that experience before.

    • @axle.student
      @axle.student 5 місяців тому

      @@freedosproject I started out on a OS C1P and C4P with 8kb and 12kB of RAM. You learn real fast to be conservative with RAM lol

  • @cynical5062
    @cynical5062 Рік тому +5

    Interesting!

  • @wherami
    @wherami 8 місяців тому +1

    Ability to write c on this is essential for today

    • @freedosproject
      @freedosproject  8 місяців тому +1

      I think every new programmer should know a bit of C. Even if you don't learn enough to write a complex program like a kernel or even an editor, knowing some C helps you write better code in other programming languages.

    • @axle.student
      @axle.student 5 місяців тому

      @@freedosproject I find C and BASIC a good base as most common languages build from those principles. I wrote a beginners book using C, FreeBASIC and Python for the examples and the code flow is the same across all 3 almost line for line.

  • @noisepuppet
    @noisepuppet Рік тому +1

    They can take our lives, but they will never take... OUR FreeDOS!!

  • @Thatguyplayvr
    @Thatguyplayvr Рік тому

    I have a 4GB USB with FreeDOS and I enjoy using it!

  • @adancalderon8915
    @adancalderon8915 Рік тому +2

    Very Cool

  • @axle.student
    @axle.student 5 місяців тому

    Thanks, that's an interesting alternative to what I do, although simple enough :)
    I'm using DJGPP at the moment which has the environment variable set in a DJGPP.ENV but I keep a distinct copy of FED224B in my DJGPP directory (and separate FED for each other compiler).
    The FED install is only for DJGPP. Add a DJFED.BAT in my \LINKS directory (In the system path) with the DJGPP PATHS and environment variable DJGPP= .
    The FED install is unique to that compiler and I store the FED set up in the same location.
    I'm lazy so I add 2 (or more) batch files in the DJGPP root directory with the call to each batch file in the Tools menu (Like a typical IDE). The Compile.BAT and RUN.BAT take the source name from FED %f and carry out the compiler commands a bit like a make file. So Basically FED acts as the IDE with control over the compiler commands :)

    • @freedosproject
      @freedosproject  5 місяців тому

      Sounds like a good option. These days, disk is cheap so you can have a different copy of FED for every compiler (such as one that's geared with key shortcuts and colors that mimics one IDE, and so on). And FED is a pretty small editor, so it doesn't take up a lot of space anyway.
      In the days when disk was more expensive and disks were smaller, I might have done that with a single FED install and a FED.BAT that copied the FED.CFG config file I wanted. Keep multiple FED.CFG files, but one FED install.
      Different ways to do the same thing. ☺

  • @maxmuster7003
    @maxmuster7003 Рік тому +1

    We can put tiny batch files in the path directory to start applications (using drive and folder) that are not in the path.

    • @freedosproject
      @freedosproject  Рік тому +1

      Yes, that works too!

    • @szenti707
      @szenti707 11 місяців тому +1

      That's my way in MS-DOS. I created them in a folder C:\BIN, analogue to unix/linux.

    • @axle.student
      @axle.student 5 місяців тому +1

      I just place all my APP launch batch files in \FREEDOS\LINKS as it is already in the path.

  • @ericorilla3316
    @ericorilla3316 Рік тому +2

    nice to see that c: prompt back again, can we run those turbo c, turbo basic, turbo pascal in freedos?

    • @judgegroovyman
      @judgegroovyman Рік тому +2

      I ran turbo c in it last year quite a bit

    • @freedosproject
      @freedosproject  Рік тому +4

      Yes, you definitely can. (And some of our developers do that too.) But I prefer the open source compilers like IA-16 GCC and OpenWatcom C, so that's usually what I highlight on the channel.

    • @OpenGL4ever
      @OpenGL4ever Рік тому +2

      John Carmack from ID Software wrote DOOM with WatcomC, he did not use Turbo C for this. If i remember correctly, Turbo C does support only the typical real mode memory models. WatcomC was shipped with a DOS4/GW DOS extender, which allowed to program DOOM for protected mode.

    • @ericorilla3316
      @ericorilla3316 Рік тому

      Love to write TSRs during dos era, in a way, if properly disigned, u can simulate muti tasking by hooking timer interrupt

  • @potzko2552
    @potzko2552 Рік тому +3

    hi, im a bit new to dos and id love some help:
    I teach asm and I want to show my students how a compiler outputs asm
    for that I want to see the asm output of my compiler.
    so far it's simple enough as gcc with the -S flag would do what I want but I need preferably 16bit or maybe 8 bit code as that is what I teach and I want my student's to recognize the output
    so after giving up on gcc as it outputs 32bit code even with the -M16 flag I thought that if I just run a dos environment im bound to get something close to what I want
    I followed your tutorial and compiled a small hello world as well as compiling it with the -S flag to see the obj file, but when I opened it I can only see random chars (the file is already translated to machine code rather than asm) is there a better way to do what im trying to do?
    additionally im not sure if it will be a problem later but id preferably want to use TASM as my assembler again because that is what my students will understand best, however any similar syntax would also be fine
    any help would be much appreciated :)

    • @freedosproject
      @freedosproject  Рік тому +2

      I think you should try the IA-16 GCC compiler. You can find it on the FreeDOS 1.3 Bonus CD. It is GCC except targeted for 16-bit CPUs, and generates exactly what you're looking for. Here's the assembly output (-S option) from a "Hello world" program:
      .arch i8086,jumps
      .code16
      .att_syntax prefix
      #NO_APP
      .section .rodata
      .LC0:
      .string "hello world"
      .text
      .global main
      .type main, @function
      main:
      pushw %bp
      movw %sp, %bp
      movw $.LC0, %ax
      pushw %ax
      pushw %ss
      popw %ds
      call puts
      addw $2, %sp
      movw $0, %ax
      movw %ax, %ax
      movw %ax, %ax
      movw %bp, %sp
      popw %bp
      pushw %ss
      popw %ds
      ret
      .size main, .-main
      .ident "GCC: (GNU) 6.3.0"
      And the original C source:
      #include
      int
      main()
      {
      puts("hello world");
      return 0;
      }

    • @potzko2552
      @potzko2552 Рік тому

      @@freedosproject this is exactly what I was looking for, thanks a lot :)

  • @jsariv2707
    @jsariv2707 Рік тому

    Thanks for sharing, I love the C language, that this system lets me do this, I love it, greetings from Mexico.☺

  • @AlguienMas555
    @AlguienMas555 Рік тому +2

    Good video

  • @KhalidThwiny
    @KhalidThwiny 9 місяців тому

    Very informative video! One question though: How do you change the colors in fed? For example, I want to have green text on black background

    • @freedosproject
      @freedosproject  9 місяців тому

      It's easy! There's a Config menu in FED where you can change the colors. Here's a video where I show how I set my favorite colors: ua-cam.com/video/eXeTaRlyQdU/v-deo.html

  • @gscheben123
    @gscheben123 Рік тому +3

    Does FreeDOS support multicore programming? One of the reasons the MS went away from DOS was create a layer of abstraction to prevent programmers to interacting directly with system hardware (eg. serial ports. parallel ports, RTC, etc.). If FreeDOS supports multicore processors, you should do a video on FreeDOS handles core and process thread scheduling.

    • @bitslasher89
      @bitslasher89 Рік тому

      🤣

    • @OpenGL4ever
      @OpenGL4ever Рік тому +3

      DOS ist only a *Disk* operating system. If we can speak of process handling at all, then it only handles one process at a time and TSR is a workaround. There is no multithreading, no multitasking and no time sharing of processes. Allowing the programs to have full access to the hardware also means, that you have to implement multicore programming on your own on an application level. I would also assume that multicore programming requires the CPU to run in protected Mode.
      So to sum it up, DOS is not the system you want to use for that task.
      If you want have full access to your hardware and multicore support, then write a driver for Linux.
      And no, the reason why MS went away from DOS was definitely not to create a layer of abstractions to prevent programmers to interacting directly with the system hardware. The layer of abstractions to separate kernel space from user space is a thing a modern operating system should support. Windows NT did this. The abstractions increases security and allows a unified API layer to access different hardware from different manufacturers the same way. It was a blessing. It ended the requirement to write different code just to support different hardware on the application level.

    • @maxmuster7003
      @maxmuster7003 Рік тому

      mphello.s file from the University of San Francisco

    • @maxmuster7003
      @maxmuster7003 Рік тому

      ​@@OpenGL4ever But a DOS application can startup all cores.

    • @OpenGL4ever
      @OpenGL4ever Рік тому +1

      @@maxmuster7003 That's what i said.

  • @maxmuster7003
    @maxmuster7003 Рік тому

    I like to use debug for programming tiny DOS executable and i put all instructions into batch files.

  • @eternaldoorman5228
    @eternaldoorman5228 10 місяців тому

    Have you also done a video showing how you do these videos? They're really good.

    • @freedosproject
      @freedosproject  10 місяців тому

      Great idea! Until I do, here's an article I wrote 2 years ago about how I use OBS: opensource.com/article/21/4/obs-youtube

  • @alexloktionoff6833
    @alexloktionoff6833 4 місяці тому

    What C compiler do you prefer for FreeDOS? What compiler you'd recommend for 386SX: TC, WC, DJGPP or else?

    • @freedosproject
      @freedosproject  4 місяці тому +1

      I have two favorite C compilers on FreeDOS right now: I love the IA16 GCC by TK Chia and others, and I love using OpenWatcom C.

    • @alexloktionoff6833
      @alexloktionoff6833 4 місяці тому

      What CPU is in your developent PC?@@freedosproject

  • @maxmuster7003
    @maxmuster7003 Рік тому

    Is there a fix memory location for the enviroment variables, or is the memory location changing on driver loading, stacks and buffer size?

    • @freedosproject
      @freedosproject  Рік тому +1

      The environment space will be one of the first things allocated when FreeCOM starts up, but it's not "locked" to some specific location in memory. And it has to be, because you can run one instance of FreeCOM inside another instance of FreeCOM (such as testing) and they'll each have their own environment.

    • @maxmuster7003
      @maxmuster7003 Рік тому

      @@freedosproject Now i understand, thank you.

  • @Teofilo750
    @Teofilo750 4 місяці тому

    I have installed freedos on virtualbox, but how do I get this screen out where you select the packages to install?

    • @freedosproject
      @freedosproject  3 місяці тому +1

      Run the FDIMPLES program to run the package installer. Note that some programs are included on the BonusCD, so you may need to download that to get all the programs you want.
      Because FreeDOS is just DOS, you can also download any DOS program and install it the usual way too. You don't always have to go through the package manager.

  • @KJ7JHN
    @KJ7JHN 11 місяців тому

    When will FreeDOS be available on a ROM chip? I hope oh so very soon.

  • @Teofilo750
    @Teofilo750 4 місяці тому

    How are braces made?

  • @alexloktionoff6833
    @alexloktionoff6833 4 місяці тому

    CAn you make a video about writing hello-world driver for DOS that could be loaded in config.sys?

    • @freedosproject
      @freedosproject  4 місяці тому

      I don't really do much assembly programming, so I don't plan to do any videos about writing drivers. But I could do a video about "writing your first DOS assembly program" using NASM on FreeDOS. I'll add that to the list of upcoming videos. [I'm behind on the videos, I hope to post more videos very soon.]

    • @alexloktionoff6833
      @alexloktionoff6833 4 місяці тому

      It's a pity, writing a driver for DOS was my childhood dream. Might you know is there any documentation to read?@@freedosproject

  • @deltakid0
    @deltakid0 24 дні тому

    How do you do debugging?

    • @freedosproject
      @freedosproject  23 дні тому +1

      These days, I don't write huge applications in C, just tools that process text, turn based games, emulators, or some other program to do some specific thing. If it's not interactive, my debugging is usually just a *printf* or *puts* statement here or there, usually controlled like this:
      #if defined(DEBUG)
      printf("in process_line() .. linelen is %d
      ", linelen);
      #endif
      Then when I compile, I can use -DDEBUG to turn "on" debugging statements. And omit -DDEBUG to turn "off" debugging statements.