TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Does (E)IP Wrap Around in 16-bit Segments?

14 pointsby diffuse_lover 2 years ago

1 comment

rep_lodsbover 2 years ago
The stack pointer wraparound isn&#x27;t a compatibility hack. In 16-bit mode PUSH&#x2F;POP only affect SP (low 16 bits of ESP), just like string instructions only affect SI&#x2F;DI.<p>An exception only occurs if there is wraparound <i>during</i> a memory access, like a 16 bit word at [FFFFh]. I suspect that EIP never actually becomes 10000h either, but that the prefetch unit sets a special tag bit to indicate that the next instruction is beyond the segment limit, same as it would if it ran off the end of a segment smaller than 64K.<p>Would be easy to check by looking at the register information from that dialog, maybe it also depends on what CPU the code is run on.<p>The 80186 didn&#x27;t have segment limits (or the #GP exception), but behaved differently from the original in that a word access at [FFFFh] would in fact access the high byte at [10000h], because the increment is done on the 20 bit internal address instead of just the offset.