x86 assembly language for MS-DOS: Hello, world

Поділитися
Вставка
  • Опубліковано 4 бер 2022
  • I do a demonstration on how to get started programming in x86 assembly language for the MS-DOS operating system using NASM and DOSBox-X. We write a "hello, world" program, assemble and run it, and then disassemble and analyze the executable COM file.
    NASM: nasm.us/
    DOSBox: www.dosbox.com/
    DOSBox-X: dosbox-x.com/
    Intel 8086 CPU user manual: edge.edx.org/c4x/BITSPilani/E...
  • Наука та технологія

КОМЕНТАРІ • 27

  • @bernieman9016
    @bernieman9016 11 днів тому

    You made all that sound quite straight forward and approachable which is saying something when you're introducing assembly!

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

    3:55 DOSBox-X does make a better job at emulating the machine and DOS environment than DOSBox without the x will do. The development scope of the latter is mainly for running games, thus its goal is not 100 % compatibility. DOSBox-X's goal is to try and achieve 100 % compatibility, thus more exotic DOS software will run on DOSBox-X than on DOSbox. And this is important for assembly programming.

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

    Just found your channel and I'm really enjoying these!

  • @maxmuster7003
    @maxmuster7003 2 роки тому +9

    Hint: We can also terminate a DOS based COM-programm with a "ret" instruction, if we do not corrupt the stack and the code segment. Because DOS place the instruction of an "int 20h" at the top of the PSP and it pushes a zero word to the stack just before it let the programm execute. If we execute at last the "ret" instruction, then the cpu return to the address of zero and continue executing the instruction of the "int 20h" inside of the PSP for terminating our programm.
    But the default practice for terminating a DOS programm is to use the DOS function: AH=4Ch, AL=(DOS "ERRORLEVEL") of the int 21h.

    • @SolarLantern424
      @SolarLantern424 8 місяців тому

      Wouldn't there still be a RET after the 4C dos call?

    • @maxmuster7003
      @maxmuster7003 8 місяців тому

      @@SolarLantern424 I don`t know.

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

      @@SolarLantern424 Why would there be? If DOS never returns control to the COM program after 4Ch, then nothing after that would ever get executed anyway. (Which is why the literal string at 010c doesn't get interpreted as code.)

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

      @@nickwallette6201 So will the address for a RET stay on the stack in that situation?

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

      @@SolarLantern424 The executing environment would get torn down by DOS, and all of that memory reused for something else (another executed program, e.g.)

  • @NickFletcher-gb9ne
    @NickFletcher-gb9ne Місяць тому

    That was great, thank you!

  • @bendono
    @bendono 9 місяців тому +3

    It's been a few decades since I last worked with COM files. This was a nice refresher. I was not aware of DOSBox-X, so it was to be able to recreate a real mode DOS environment.
    BTW Since you're already using NASM, why not use the built in disassembler ndisasm in favor of hexdump?

    • @chillruns6221
      @chillruns6221  9 місяців тому +2

      I think hexdump is nice for demonstrating to newcomers that the assembled file is merely instructions in the form of binary data.
      You're right, though. ndisasm is a more convenient tool. I actually didn't know about it at the time I made this video. I use NASM extensively in my current project, a real mode operating system: ua-cam.com/video/BX-DA1AY5tQ/v-deo.html&pp=gAQBiAQB
      I do use ndisasm to support that work.

  • @arturwiebe7482
    @arturwiebe7482 Місяць тому

    If i remember correctly one can generate COM files with the DOS debugger, too. No need for an assembler 😊

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

    Nice vid

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

    好懷念的 mov ah, 4ch; int 21h

  • @nery100
    @nery100 8 місяців тому

    Hi bro, I have a question that I would like you to answer if it’s possible
    Look, I have like a test in a course where I’m using assembly, my professor ask to make that throw assembly receive the data in a serial port y show what’s sent in the console. Do you know if it’s possible to do it using dosbox and the same logic that you used in this video?
    PD: English is not my main language, sorry if I have some grammar mistakes, but hope it’s understandable.

    • @chillruns6221
      @chillruns6221  8 місяців тому

      DOSBox has support for emulating serial ports. If it's complete enough, you should be able to use it.
      Enabling it: www.dosbox.com/DOSBoxManual.html
      Programming it (C code. You have to translate to assembly): wiki.osdev.org/Serial_Ports#Programming_the_Serial_Communications_Port
      But if you have the option to write assembly on an x86 GNU/Linux computer, I'd recommend doing that instead. If you want to emulate, you could use Linux in the QEMU emulator, which emulates a serial port and can bind to a device or file on the host machine.
      (search for serial) www.qemu.org/docs/master/system/invocation.html#hxtool-6
      If you have any other questions, I'll try to help you.

  • @zzco
    @zzco 18 днів тому

    I want to write an OS that sits atop MS-DOS that runs on ELF, similar to how Windows 3 uses NE.
    Lol.

  • @davidgrisez
    @davidgrisez 8 місяців тому +2

    We have the well known example of the "Hello World!" program. This was first run over 40 years ago on real IBM PC hardware and also run on many PC compatible computers. This was practically the simplest program that could be written for MS-DOS. Now unless we have a historic restored IBM PC or PC compatible computer we have to run it on a DOS emulator.

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

      Well, who _doesn't_ have a 5150 hanging around? :-D

    • @jussiala-konni288
      @jussiala-konni288 12 днів тому

      No need to go that far back. A few days ago I booted Intel 6th generation machine to DOS from 3,5" floppy.

    • @davidgrisez
      @davidgrisez 12 днів тому

      @@jussiala-konni288 It is amazing that after all these years that there are some Intel PCs that can still boot up the MS-DOS operating system.

  • @DKBZA
    @DKBZA 2 роки тому

    excelent video, i have a question, is there a form to read and write file through with AH=3F and AH=40??? is possible a video with this information? and the function to seek a specified position in a file "seek" wich is the AH=42? all interrupt 21. thank very much.

    • @chillruns6221
      @chillruns6221  2 роки тому +2

      Thanks for watching! I'm planning a future video for I/O, but I'm not sure when. In the meantime, here are my favorite DOS interrupt references. I think they both have very good sections on the 3Fh,40h,42h file functions.
      www.techhelpmanual.com/5-dos_function_index___quick_reference_subset.html
      flint.cs.yale.edu/cs422/doc/art-of-asm/pdf/CH13.PDF

    • @DKBZA
      @DKBZA 2 роки тому

      @@chillruns6221 is very interesting. thank very much, already reading it

  • @maxmuster7003
    @maxmuster7003 2 роки тому

    I am on an Android tablet with the Magic Dosbox Free app installed from the play store.

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

    I tryied to post a new comment, but it is deleted in seconds.