3 ms·
didn't we call it 'segmented memory' back in DOS days...?
by baq 1y ago
didn't we call it 'segmented memory' back in DOS days...?
- munificent 1y agoWe call it "pointer compression" now. :)
- mananaysiempre 1y agoSeriously though, I’ve been wondering for a while whether I could build a GCC for x86-64 that would have 32-bit (low 4G) pointers (and no REX prefixes) by default and full 64-bit ones with __far or something. (In this episode of Everything Old Is New Again: the Very Large Memory API[1] from Windows NT for Alpha.) [1] https://devblogs.microsoft.com/oldnewthing/20070801-00/?p=25763 https://devblogs.microsoft.com/oldnewthing/20070801-00/?p=25...
- dajtxx 1y ago6502 zero page instruction vibes.
- o11c 1y agoA moderate fraction of the work is already done using: https://gcc.gnu.org/onlinedocs/gcc/Named-Address-Spaces.html https://gcc.gnu.org/onlinedocs/gcc/Named-Address-Spaces.html Unfortunately the obvious `__attribute__((mode(...)))` errors out if anything but the standard pointer-size mode (usually SI or DI) is passed. Or you may be able to do it based on x32, since your far pointers are likely rare enough that you can do them manually. Especially in C++. I'm pretty sure you can just call "foreign" syscalls if you do it carefully.
- deleted 1y ago[deleted]
- magicalhippo 1y agoIt was glorious I tell you. Especially how you could increase the segment value by one or the offset by 16 and you would address the same memory location. Think of the possibilities! And if you wanted more than 1MB you could just switch memory banks[1] to get access to a different part of memory. Later there was a newfangled alternative[2] where you called some interrupt to swap things around but it wasn't as cool. Though it did allow access to more memory so there was that. Then virtual mode came along and it's all been downhill from there. [1]: https://en.wikipedia.org/wiki/Expanded_memory https://en.wikipedia.org/wiki/Expanded_memory [2]: https://hackaday.com/2025/05/15/remembering-more-memory-xms-and-a-real-hack/ https://hackaday.com/2025/05/15/remembering-more-memory-xms-...
- deleted 1y ago[deleted]
- mananaysiempre 1y ago> Think of the possibilities! Schulman’s Unauthorized Windows 95 describes a particularly unhinged one: in the hypervisor of Windows/386 (and subsequently 386 Enhanced Mode in Windows 3.0 and 3.1, as well as the only available mode in 3.11, 95, 98, and Me), a driver could dynamically register upcalls for real-mode guests (within reason), all without either exerting control over the guest’s memory map or forcing the guest to do anything except a simple CALL to access it. The secret was that all the far addresses returned by the registration API referred to the exact same byte in memory, a protected-mode-only instruction whose attempted execution would trap into the hypervisor, and the trap handler would determine which upcall was meant by which of the redundant encodings was used. And if that’s not unhinged enough for you: the boot code tried to locate the chosen instruction inside the firmware ROM, because that will have to be mapped into the guest memory map anyway. It did have a fallback if that did not work out, but it usually succeeded. This time, the secret (the knowledge of which will not make you happier, this is your final warning) is that the instruction chosen was ARPL, and the encoding of ARPL r/m16, AX starts with 63 hex, also known as the ASCII code of the lowercase letter C. The absolute madmen put the upcall entry point inside the BIOS copyright string. (Incidentally, the ARPL instruction, “adjust requested privilege level”, is very specific to the 286’s weird don’t-call-it-capability-based segmented architecture... But it’s has a certain cunning to it, like CPU-enforced __user tagging of unprivileged addresses at runtime.)
- DaiPlusPlus 1y ago> The absolute madmen put the upcall entry point inside the BIOS copyright string. Isn’t that an arbitrary string, though? Presumably AMI and Insyde have different copyright messages, so then what?
- _nalply 1y agoI thought so, but "Copyright" is always the same? Haha, that's dangerously clever or cleverly dangerous.
- malkia 1y agowait.... UNREAL MODE!
- marcosdumay 1y agoAnd turned out we have the transistors to avoid it, but it's a really good optimization for CPUs nowadays. At least most people design non-overlaping segments. And I'm not sure wasm would gain anything from it, being a virtual machine instead of real.