NASM - The Netwide Assembler
NASM Forum => Other Discussion => Topic started by: amoroso on September 05, 2022, 01:22:56 PM
-
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.
-
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
-
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.
-
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:
bits 16
org 0x100 ; skip the PSP
; Your program start here
_start:
...
Here a simple 'Hello, World' in COM format:
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$`
-
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 (https://en.wikipedia.org/wiki/Netwide_Assembler#Sample_programs): your code doesn't declare sectons.
-
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 (https://en.wikipedia.org/wiki/Netwide_Assembler#Sample_programs): your code doesn't declare sectons.
As I said before: COM files don't have sections.
You CAN use sections, but `.text` (or _TEXT) must be the first one, and ORG 0x100 must be there. AND all the sections must be mapped in a single segment.
-
there's this old asm book that was released and the 386 chips were already in the market and this book had examples in real mode that has e(letter)x registers being used. idk what assembler was used but it was like doing some unreal programming..
i totally photocopied it from our university library.. it's titled "ibm pc assembly (and other words)" or somehow like that.
imma find my book stash and list the title..
update: sadly, the cover and the copyright page were lost. it just listed the e(letter)x registers associated or to be used with double word "dd" values as data definitions.
-
Kip Irvine, perhaps?
Best,
Frank