-1

I am reading about memory organisation and address capability of 8086 processors.

So far I have understood that 8086 processor via its 20 bit address bus can address 1MB different physical memory locations & the whole memory location is segmented into 16 blocks, each segment is of 64KB size.So in order to access contents of memory location inside a segment we need to provide its 16 bit binary value(a.k.a offset address) which completely makes sense as we need exactly 16 bits to represent all the 64 kilobytes of memory.

what I don't understand is that why does the base address has to be a 16 bit value ?

From my understanding We just need 4 more bits(base) to represent all the 16 segments (i.e 0000, 0001, 0010, 0011, 0100, 0101, 0110, 0111, 1000, 1001, 1010, 1011, 1100, 1101, 1110, 1111 ) and we need additional 16 bits(offset) to represent bytes within these segments ((2^16)*(2^4))=2^20.

Here is an example from textbook explaining offset and base address

1000:1F00 = (1000*10h)+1F00 = 11F00 ; 16 bit base and offset

steve_c
  • 1
  • 2
  • 1
    See http://stackoverflow.com/questions/42861524/what-are-segments-and-how-can-they-be-addressed-in-8086-mode – Ross Ridge Mar 22 '17 at 00:15

1 Answers1

0

I need to see these text books, all that matters is your address is the segment times 0x10 plus the offset/address (address = (segment<<4)+offset). So the size of a segment as far as I am concerned is 16 bytes, there are 65536 segments which can each have 65536 bytes in them and there is a lot of overlapping that goes on.

What matters is work backward, I have a 20 bit address that I need to generate, I have a segment register and an offset. There are 12 bits that overlap, so there are 4096 different ways to make that address. Pick one. Ideally you want to pick one that reduces the number of times you have to change the segment, and or saying it another way maximize reuse of the same segment.

EDIT

I forgot about the term paragraph. Say your offset was always zero, and you incremented the segment, that would be on aligned 16 byte boundaries. those are paragraphs. A segment is the 65536 Bytes you can access without changing the segment register, so there are 65536 segments with a lot of overlap (one for every possible segment register value).

If you have say 16Kbytes of data in some structure/array/whatever you want to access with some chunk of code, you would want to use a segment offset combination so that you dont have to change the segment but one time to surround that 16K and the use offsets to wander through it linearly or randomly. The less efficient way would be to use segment offset combinations where to walk through or randomly go through that 16Kbytes of data you need to change the segment register.

old_timer
  • 69,149
  • 8
  • 89
  • 168
  • A paragraph is usually the term for each 16-byte block of memory, and each segment is 65536 bytes in size (with A20 line off it wraps to bottom of memory otherwise extends above 1MB to physical address 0x10FFEF) – Michael Petch Mar 22 '17 at 04:57
  • That is ringing a bell, either way you are trying to produce a 20 bit address with two items added together and are free to change either item, but just want to do it in the least painful way (not have to change the segment every access unless you are trying for a huge model). – old_timer Mar 22 '17 at 14:15
  • @MichaelPetch using the paragraph/segment terminology can a segment start at any paragraph or only certain ones? I would assume any...as a segment would make sense to be the 64K you can access without changing the segment register. – old_timer Mar 22 '17 at 14:16
  • Paragraphs are all 16-byte aligned. – Michael Petch Mar 22 '17 at 14:25
  • of course they are, have to be. wasnt the question. – old_timer Mar 22 '17 at 14:39
  • All segments start on a paragraph boundary. All paragraphs are 16-byte aligned. Segments start on a particular paragraph. A segment by itself can never point to a non 16-byte aligned memory region. – Michael Petch Mar 22 '17 at 14:40
  • good, so there are 65536 possible segments with a lot of overlap, thats what I thought, I forgot about the paragraph term. – old_timer Mar 22 '17 at 14:43