NASM - The Netwide Assembler

NASM Forum => Using NASM => Topic started by: ben321 on June 13, 2016, 12:42:15 AM

Title: I think there may be a bug in the claim of using ORG 0x100 for COM files
Post by: ben321 on June 13, 2016, 12:42:15 AM
The reason I say this, is because when I execute a COM file, rather than being loaded into the memory location 0000h:0100h (flat memory location 00100h) it instead loads into memory location 0F63h:0100h (flat memory location 0F730h). And I'm not making this up. I tested it in the debugger version of DosBox, which allows me to easily debug 16bit applications. I expected the first byte of code of my COM file program to loaded into memory at 0000h:0100h but instead it was at 0F63h:0100h.
Title: Re: I think there may be a bug in the claim of using ORG 0x100 for COM files
Post by: Frank Kotler on August 05, 2016, 03:38:38 AM
Hi Ben321,
Your expectation of what DOS does appears to be incorrect. It does not load at segment 0 (would trash your IVT if it did) but at a segment of its choice (lowest free segment available, usually). Sorry for the delay - I imagine you've figured that out by now.

Best,
Frank

Title: Re: I think there may be a bug in the claim of using ORG 0x100 for COM files
Post by: debs3759 on August 31, 2016, 02:42:12 PM
To expand on what Frank said (and to introduce myself here)

DOS decides where to load your file in memory. In your case it was loaded into segment 0F30h. At offset 0 is a program header that takes up 256 bytes, which is why you start your code at org 100h, which is the offset of your code in the segment DOS loaded it into.