It was thus said that the Great Johnny Billquist once stated: > > Yeah. Segment is something I usually associate with the solution done in > the 8086 family, where you essentially have a segment register which > gives the base, and then you work from there. Essentially all memory is > one chunk. > > The 8086 have both an instruction and a data segment, which just means > that some instructions refer to data, and that uses the data segment > register, while instructions (obviously) are addressed through the > instruction segment register. I never worked with the 8086, but don't it > actually also have a third segment register? Not that I can remember > what it was used for... Oh, and all references are relative to the > segment register (should be obvious, but I figured I should point it out.)
The 8086 had four segment registers: CS - Code segment, used with IP register DS - Data segment SS - Stack segment, used with SP and BP registers ES - Extra segment, used with DI for string instructions as destination (DS:SI as source) You could override instructions dealing with memory with any of the segment registers: mov ax,[foo] ; load AX from memory location DS:foo mov bx,es:[bar] ; load BX from memory location ES:bar mov cx,cs:[baz] ; load CX from memory location CS:baz mov dx,ss:[snafu] ; load DX from memory locaiton SS:snafu On the 8086 and 80186, the contents of the segment registers are shifted 4 bits to the left then added to the offset (total 20 bit offset). Starting with the 80286, in protected mode, the segment registers are actually indexes into one of two tables (the GDT (global descriptor table) or LDT (local descriptor table)) and are not actual addresses. -spc (God! I still remember this stuff?)