ROM-BIOS leaves ds and es limits beyond 64 KiB (Developers)
> 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:
- ROM-BIOS leaves ds and es limits beyond 64 KiB - ecm, 28.10.2025, 17:20 (Developers)
![Open in board view [Board]](img/board_d.gif)
![Open in mix view [Mix]](img/mix_d.gif)
- ROM-BIOS leaves ds and es limits beyond 64 KiB - Oso2k, 28.10.2025, 21:46
- ROM-BIOS leaves ds and es limits beyond 64 KiB - ecm, 28.10.2025, 22:03
- ROM-BIOS leaves ds and es limits beyond 64 KiB - tkchia, 06.11.2025, 17:29
- ROM-BIOS leaves ds and es limits beyond 64 KiB - ecm, 06.11.2025, 20:13
- ROM-BIOS leaves ds and es limits beyond 64 KiB - ecm, 06.11.2025, 20:23
- ROM-BIOS leaves ds and es limits beyond 64 KiB - tkchia, 06.11.2025, 23:07
- ROM-BIOS leaves ds and es limits beyond 64 KiB - ecm, 06.11.2025, 20:23
- ROM-BIOS leaves ds and es limits beyond 64 KiB - ecm, 06.11.2025, 20:13
- ROM-BIOS leaves ds and es limits beyond 64 KiB - tkchia, 06.11.2025, 17:29
- ROM-BIOS leaves ds and es limits beyond 64 KiB - ecm, 28.10.2025, 22:03
- ROM-BIOS leaves ds and es limits beyond 64 KiB - bretjohn, 30.10.2025, 16:49
- ROM-BIOS leaves ds and es limits beyond 64 KiB - ecm, 30.10.2025, 18:49
- ROM-BIOS leaves ds and es limits beyond 64 KiB - bretjohn, 31.10.2025, 01:45
- LOADFIX - ecm, 06.11.2025, 20:20
- ROM-BIOS leaves ds and es limits beyond 64 KiB - bretjohn, 31.10.2025, 01:45
- ROM-BIOS leaves ds and es limits beyond 64 KiB - ecm, 30.10.2025, 18:49
- ROM-BIOS leaves ds and es limits beyond 64 KiB - Oso2k, 28.10.2025, 21:46
Mix view