Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

ROM-BIOS leaves ds and es limits beyond 64 KiB (Developers)

posted by ecm Homepage E-mail, Düsseldorf, Germany, 30.10.2025, 18:49

> The way it works on the original 8086/8088 CPUs, which I think is what
> should be emulated by default, is obviously that it wouldn't generate a
> fault (the old CPU's didn't have segment faults).

Yes, indeed. I previously discussed this on stackoverflow and on the dosemu2 site. As bartoldeman stated there:

> > it's documented in "Differences From 8086" in the original 80386 programmer's manual. e.g. https://pdos.csail.mit.edu/6.828/2018/readings/i386.pdf
>
> Page 211.

Quoting from there:

> Operand crossing offset 0 or 65,535.
>
> On the 8086, an attempt to access a memory operand that crosses
> offset 65,535 (e.g., MOV a word to offset 65,535) or offset 0 (e.g.,
> PUSH a word when SP = 1) causes the offset to wrap around modulo
> 65,536. The 80386 raises an exception in these cases──exception 13 if
> the segment is a data segment (i.e., if CS, DS, ES, FS, or GS is being
> used to address the segment), exception 12 if the segment is a stack
> segment (i.e., if SS is being used).
>
> Sequential execution across offset 65,535.
>
> On the 8086, if sequential execution of instructions proceeds past
> offset 65,535, the processor fetches the next instruction byte from
> offset 0 of the same segment. On the 80386, the processor raises
> exception 13 in such a case.

For more information on the IP fault, refer to https://www.os2museum.com/wp/does-eip-wrap-around-in-16-bit-segments/ as well.

> The issue is what byte
> ends up in AH when you do something like a MOV AX,[FFFFh]. Is
> it the byte at DS:[0000h] or the byte at the linear address one byte above
> DS:[FFFFh]. I believe it should be DS:[0000h], but am not 100% positive.

Yes, on the NEC V20 (as used by my HP 95LX) it does actually access the byte at offset 0000h, not 10000h, as the high byte. Not sure what Intel's 8086, 186, and 286 did.

---
l

 

Complete thread:

Back to the forum
Board view  Mix view
22789 Postings in 2123 Threads, 402 registered users (1 online)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum