Assembly Question (Segment:Offset)
Results 1 to 5 of 5

Thread: Assembly Question (Segment:Offset)

  1. #1
    Senior Member
    Join Date
    Jun 2002
    Posts
    148

    Assembly Question (Segment:Offset)

    Hi, I am teaching myself assembly language for the 80X86 familly of microprocessors. I have already read some assembly tutorials for 80X86, and am now reading one at:

    http://www.compapp.dcu.ie/~ray/CA225.html#Index

    I am haveing dificulties understanding the whole segemnt/offset thingy, so let me explain what I understand:

    I understand that It was believed 640K of RAM was enough for anyone, and with the 16 bit registers you could not address much memory anyway, so when memory capacity was extended to 1Megs memory was then split into 64k segments, so the use of a segment register that is 16 bits can address 2^16 = 65.5k ? so in order to address more then 1M of RAM a second register was used as an offset, then combining the segment and offset registers, shifting the segment to the left 4 places, we could have a 20 bit address, that can address more then 1Megs of system memory.

    That is what I understand, or at least think I understand, and I was woundering if somebody can clerify that, and tell me, are segments still 64k or have they grown, because i read with the extended 32 bit register for the offset you can address more memory, so are segments still 64k or have they goten biger? And can you clerify that what I said is corect.
    In snatches, they learn something of the wisdom
    which is of good, and more of the mere knowledge which is of evil. But must I know what must not come, for I shale become those of knowledgedome. Peace~

  2. #2
    AO Curmudgeon rcgreen's Avatar
    Join Date
    Nov 2001
    Posts
    2,716
    newer processors have a feature called "protected mode".
    when the processor is in protected mode, it uses 32 bit
    memory addresses, and segment/offset addressing doesn't apply.

    Segment/offset addressing only applies in "real" 8086 mode,
    where there are only 20 address bits available.
    I came in to the world with nothing. I still have most of it.

  3. #3
    Senior Member
    Join Date
    Jun 2002
    Posts
    148
    10X, The memory stuff gets confuseing, it will be my first herdle to overcomon my assembly journey, Incase anyone is woundering why I decided to learn assembly, it is because my ultimate long term goal is to build an operating system, and through research I have discovered that much of my programing will involve some assembly, so I must learn assembly first. I chose the 80X86 archetecture because I have only used Intel Processors, and I believe it is the most popular.

    Just to clerify, the programing I am doing in assembly with the segments and offsets are only in real mode programing, but if I am programing in protected mode I will not have to wory about that? I was reading about protected mode, and had posted a question about it in which I got a responce, I am geting more involved with low level programing now, so I will need to have a much beter understanding of hardware. But I am slowly getting there. I am still confused about the size of the segments, with the extended registers being 32 bit, useing an extended register as the offsett register would alow a greater mount of memory locations to be accessed, and thus more bytes per segment? So have the segment size grown from the initial 64k?
    In snatches, they learn something of the wisdom
    which is of good, and more of the mere knowledge which is of evil. But must I know what must not come, for I shale become those of knowledgedome. Peace~

  4. #4
    AO Curmudgeon rcgreen's Avatar
    Join Date
    Nov 2001
    Posts
    2,716
    As far as I know, you don't use segments in protected
    mode, just a simple 32 bit number. I don't know that much about
    protected mode, whether the address goes into a single register
    or if it is split into two registers, but it is called a "flat" memory
    model, where, with that 32 bit address, you can access any memory
    address, no matter how much memory is installed.

    There's a lot more to it, though, because our processors are also capable
    of setting up "virtual memory" through a swap file on disk. The OS has
    a memory manager that presents the available memory to programs
    in a simple way. Programs use the addresses presented to them by the
    memory manager, and don't have low level physical access to memory
    as they would in real mode.
    I came in to the world with nothing. I still have most of it.

  5. #5
    Senior Member
    Join Date
    Jun 2002
    Posts
    148
    I found some answers to my questions at http://www.x86.org/articles/pmbasics/

    The site says that in protected mode, the values in the segment registers are used as pointers to look up tables called GDT and LDT (Global and Local discriptor tables) and each of these enterys are on 8 bit blocks, so the values loaded into the segment register can only be a multiple of 8 because they are pointers to the look up tables. The look up table then contains segment information, and will place the corect base/segment address in an invisible register called the segment discriptor cache, which is a register that is not accessable to the programer, The value loaded into the segment discriptor cache is then added to the 16 bit or 32 bit offset register to obtain the physical address. Thank you so much for all your help. I will have to go and learn about virtual memory now.
    In snatches, they learn something of the wisdom
    which is of good, and more of the mere knowledge which is of evil. But must I know what must not come, for I shale become those of knowledgedome. Peace~

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 Security News

     Patches

       Security Trends

         How-To

           Buying Guides