Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 5th, 2005, 12:42 PM   #1
conbrio
Newbie
 
Join Date: Apr 2005
Posts: 10
Rep Power: 0 conbrio is on a distinguished road
Descriptor tables

This question doesn't have anything directly to do with assembly code but is "essential," I would think, to assembly (and is from what I've seen a topic in many assembly tutorials).

Anyway, my question is relating to the area of the descriptor table entry called the "limit." This limit is supposed to hold a 20-bit number describing the size of the segment, in bytes (or 4K if granularity bit is enabled). Now, nearly everywhere I've read says that in protected mode segments can be up to 4GB. Yet 2^20=1,048,576B and hence 1MB segments at most seem possible. I don't understand how this can be. I think the discrepancy is obvious.

The information on the 'net regarding memory logic layout & low level CPU stuff is pretty scant. It's either usually outdated and maybe only covers real mode and old processors or really condensed. If anyone has any good links, pass them along

Help is appreciated. I feel like I ask too many questions here.
conbrio is offline   Reply With Quote
Old Jul 5th, 2005, 2:35 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
What you're talking about is platform and tool dependent. From what does your question arise, exactly?
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jul 5th, 2005, 6:38 PM   #3
conbrio
Newbie
 
Join Date: Apr 2005
Posts: 10
Rep Power: 0 conbrio is on a distinguished road
Hmm, platform and tool dependent? Not sure what you mean by tool, but I was of the thought that OSes only managed what were already fixed CPU-memory relationships (ie, the segmented real and protected modes and flat memory model). The question arises mainly out of curiosity, but I suppose it'd help whenever I desire to start learning assembly lang. too.
conbrio is offline   Reply With Quote
Old Jul 5th, 2005, 7:28 PM   #4
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
I presume, possibly erroneously, that you're referring to descriptor tables for some memory management approaches. Not every system indulges in memory management or segmented addressing schemes, or even "real" vs. "protected" modes. It's very implementation dependent. Despite the huge number of desktop machines out there running a few "common" operating systems, there are even more non-desktop microprocessor "computers" or systems. If you want to learn assembly language, pick a processor -- they differ, often radically. When you have a processor in hand (or mind), then familiarize yourself with what IT does and how it does it. A great deal of system software is an adjunct constrained by the capabilities of the underlying machine.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jul 5th, 2005, 7:55 PM   #5
conbrio
Newbie
 
Join Date: Apr 2005
Posts: 10
Rep Power: 0 conbrio is on a distinguished road
You're correct. I was talking specifically about PC memory management/CPUs. I thought "PC" was assumed by default on the forum, but apparently not, which is probably a good thing.
conbrio is offline   Reply With Quote
Old Jul 5th, 2005, 8:42 PM   #6
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
A very large amount of commercial programming is not in "PCs". Neither does PC mean "IBM PC compatible". The world of the microprocessor is actually quite diverse and probably more widespread than frequently thought. I don't have the usual picture of the market, I suppose; in 35 years of microprocessor programming interspersed throughout other engineering duties, "desktop" programs are but a tiny fraction of the whole.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jul 6th, 2005, 3:41 AM   #7
omega_red
Newbie
 
omega_red's Avatar
 
Join Date: Jun 2005
Location: Poland
Posts: 5
Rep Power: 0 omega_red is on a distinguished road
Send a message via Yahoo to omega_red
Quote:
Originally Posted by conbrio
Anyway, my question is relating to the area of the descriptor table entry called the "limit." This limit is supposed to hold a 20-bit number describing the size of the segment, in bytes (or 4K if granularity bit is enabled). Now, nearly everywhere I've read says that in protected mode segments can be up to 4GB. Yet 2^20=1,048,576B and hence 1MB segments at most seem possible. I don't understand how this can be. I think the discrepancy is obvious.
From Intel's manual (vol. 3):

Quote:
Segment limit field
Specifies the size of the segment. The processor puts together the two segment limit fields to form a 20-bit value. The processor interprets the segment limit in one of two ways, depending on the setting of the G (granularity) flag:
• If the granularity flag is clear, the segment size can range from 1 byte to 1
MByte, in byte increments.
• If the granularity flag is set, the segment size can range from 4 KBytes to
4 GBytes, in 4-KByte increments.
And that's it
Either you have byte-resolution and 1MB max size, or 4kB (page) resolution and 4GB size (this is used by most OSes).
omega_red is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:01 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC