@foone x86 real mode was the most gratuitously stupid addressing mode ever. 🤦
Conversation
Notices
-
Embed this notice
Rich Felker (dalias@hachyderm.io)'s status on Monday, 06-Jan-2025 16:09:00 JST Rich Felker
-
Embed this notice
Foone🏳️⚧️ (foone@digipres.club)'s status on Monday, 06-Jan-2025 16:09:01 JST Foone🏳️⚧️
and that'd make sense if only the lower 4 bits of the segment were used.
but all bits are used. They just add the segment and the offset together, after bitshifting the segment over by 4.
So the linear address of AAAA:BBBB is AAAA*16+BBBB.
-
Embed this notice
Foone🏳️⚧️ (foone@digipres.club)'s status on Monday, 06-Jan-2025 16:09:02 JST Foone🏳️⚧️
because the colon means this is 16-bit segmented x86! we're in Real Mode!
and real mode is nonsense of a higher order
-
Embed this notice
Foone🏳️⚧️ (foone@digipres.club)'s status on Monday, 06-Jan-2025 16:09:02 JST Foone🏳️⚧️
You've got two 16-bit integers, called the segment (or segment selector, or just selector) and your offset.
And it'd make sense that those are just two chunks of a larger 32bit linear address, but they're not. They're two 16-bit chunks of a 20-bit address. -
Embed this notice
Foone🏳️⚧️ (foone@digipres.club)'s status on Monday, 06-Jan-2025 16:09:03 JST Foone🏳️⚧️
btw the colon in that 32bit address means I lied. That's not really the address. The address is, obviously, 227EB
-
Embed this notice
Foone🏳️⚧️ (foone@digipres.club)'s status on Monday, 06-Jan-2025 16:09:04 JST Foone🏳️⚧️
you breakpoint at the function, and see the following 32 bits at the top of the stack.
7B0E9721what's the linear address of the return value? Well, obviously, it's
2197:0E7B!
you just gotta remember to reverse the bytes but not the nibbles, that'd be silly. Little Endian makes perfect sense.
-
Embed this notice