Live data from Hacker News

8086 Segmented Memory was a good idea

owl.billpg.com

81–90 of 150 posts

Re: 8086 Segmented Memory was a good idea

#82

I seem to recall at the time that flat memory was self evidently a better idea. It's not like people were sitting around going "gee I can't think of any better way to do memory addressing that this" until some genius suggests "how about flat?!?!?" Everyone knew flat was best but were stuck with 8086 crap.

Except than later we returned to a sort-of segmented memory. That is of course paging, our programs allocates pages of memory that are a fixed size (4096 bytes) and are arranged in memory or in swap space how the OS decides. We just have the illusion of a "flat" memory model, but it's not really flat, the CPU and the operating system does an important job in translating our flat memory model in something that is not…

[deleted]

Re: 8086 Segmented Memory was a good idea

#83
Wow.... I remember writing 8086 assembly on MASM and another assembler I've forgotten the name of, and then also doing inline ASM in Turbo C++

The segment thing and the convoluted different pointer math caused real gymnastics if you ever had data bigger than 64k... such as images.

I always thought of the segments as windows of 64k but moving between those windows, esp with the limited register set, required some real mental gymnastics.

Re: 8086 Segmented Memory was a good idea

#84

1992-me hates the author. Coming from 68k assembly, x86 was a nightmare. And together with the ridiculous number of registers, segments made up a huge chunk of that horrible experience.

What? It has 4 times as many general purpose registers as you'd ever need, right? /s

Agree.. 68k assembly was dreamy compared to 80x86..

Re: 8086 Segmented Memory was a good idea

#85

I blame 8086 segmented memory and the rest of its horrid architecture on why no one liked programming in assembly language. There were other elegant RISC machines with flat memory models and large general register sets that were a complete joy to program. Memory paging allowed you to do everything you needed to do that segmented memory provided and left the programmer unbothered for the most part.

Totally agree.

Re: 8086 Segmented Memory was a good idea

#87
Did anyone else find the AI written style of this offputting?

The original 20 bit vision of the 8086 was when memory was very expensive and they expected typical high end machines to have 128K of memory.

Intel’s assembler was designed so you could have up to 128K of code with a “shared” segment in the middle that either side could reach with near (16 bit only) pointers to call commonly shared routines, and more rarely executed code existed on either end.

In addition data could be its own segment, and/or memory mapped I/O outside of the 128K space.

But memory got so cheap that nobody bothered with this, and the performance gains of writing code that way wasn’t worth the effort. X86 code was compact enough most programs could cram their code into 64k anyway, or 64k per functional unit with calls between them being rare.

The real tragedy is they went for 20 bit instead of 24 bit. 8086 with 16MB of addressable space would have been a very different world and would have made little difference if there use. (Paragraphs would have been 256 bytes, the same size as a page; most data structures would have been fine with that.)

Re: 8086 Segmented Memory was a good idea

#88
They could have used 16 bit segments with no overlap. It would have a 16 bit offset register + a 16 bit segment selector register with the top 12 bits reserved (always 0). 16 bit software would run as usual in a single segment, while larger programs would use both registers for 20 bit addresses.

286 could then use the next 4 bits from the segment register to allow 16 MB address space and 386 could use all of them for 4GB. And wouldn't it be nice if 386 had 64KB pages (1 segment)?

Re: 8086 Segmented Memory was a good idea

#89

Did anyone else find the AI written style of this offputting? The original 20 bit vision of the 8086 was when memory was very expensive and they expected typical high end machines to have 128K of memory. Intel’s assembler was designed so you could have up to 128K of code with a “shared” segment in the middle that either side could reach with near (16 bit only) pointers to call commonly shared routines, and more rarel…

Hi. I wrote it, and I'm a human. (Or at least I think I am.)

I did use an AI for spell-checking, punctuation, generally making it flow, but its all my text.

You think a machine is going to come up with "near pointers, far pointers, wherever-you-are pointers"?

Re: 8086 Segmented Memory was a good idea

#90
post #88

They could have used 16 bit segments with no overlap. It would have a 16 bit offset register + a 16 bit segment selector register with the top 12 bits reserved (always 0). 16 bit software would run as usual in a single segment, while larger programs would use both registers for 20 bit addresses. 286 could then use the next 4 bits from the segment register to allow 16 MB address space and 386 could use all of them for…

That wouldn't have worked, the point was to pack data in memory. Even on 64kb computers, MS-DOS 1.x loaded .COM files at the bottom of available memory and allowed using the "familiar" CALL 5 interface even if the program was not loaded at physical address 0x100 (which is part of the interrupt table on x86). MS-DOS 2.x augmented that with TSR (terminate and stay resident) programs that could relocate themselves to use the minimal amount of memory at 16-byte offsets.

The 68000 was a complete break so it opted for relocatable code (which also needed more registers, and in fact the 68k had 16 instead of 8).

Post reply on HN