NASM Forum > Other Discussion

Looking for .COM program sources in NASM Assembly

(1/2) > >>

amoroso:
I'm looking for source code of MS-DOS .COM programs in real-mode 8086 Assembly written in NASM syntax. Any repositories or recommendations?

I'm learning Assembly programming under MS-DOS (and MikeOS) and cross-developing on Linux with NASM. To avoid the complexity of x86 segmentation, for the time being I prefer to focus on single-segment programs, as I plan to write small programs anyway. So I'd like to study examples of how such systems organize and reference data and code. I searched a bit but found remarkably little .COM code.

Frank Kotler:
Hi Paolo,

Welcome to the forum.

Have you looked in Example Code? It is not well indexed, but there should be at least some DOS .com code there.

I'll try to get back to you with more tips.

To others... Paolo Amoroso was sent here from clax86.

Best,
Frank

amoroso:
Thanks Frank, it didn't occur to me to check NASM's source tree as I assumed it would contain at most some test code like that.

fredericopissarra:
MS-DOS COM files are nothing more than a single binary with only ONE segment. All selectors points to the same segment (CS = DS = ES = SS) and there are no additional sections.

COM files are inherited from the old CP/M and not used anymore (it's not even supported on Win10 anymore!).

The first 256 bytes of this segment is reserved to PSP (Program Segment Prefix), where you can get the command line, and other things. The source code structure is very simple on NASM:

--- Code: ---  bits 16

  org  0x100    ; skip the PSP

  ; Your program start here
_start:
  ...
--- End code ---
Here a simple 'Hello, World' in COM format:

--- Code: ---  bits  16

  org   0x100

  ; start here
  lea   dx,[msg]
  mov   ah,9        ; PrintStr (DOS service).
  int   0x21

  mov   ax,0x4c00   ; Exit (DOS service)
  int   0x21

msg:
  db    `Hello, world\r\n$`
--- End code ---

amoroso:
Thanks Frederico, .COM files not being used anymore isn't an issue as I'm learning 8086 Assembly mostly for my interest in retrocomputing.

I see an interesting differences between your hello world code and the similar demo in Wikipedia's NASM entry: your code doesn't declare sectons.

Navigation

[0] Message Index

[#] Next page

Go to full version