OSDev.org

The Place to Start for Operating System Developers
It is currently Wed May 08, 2024 2:47 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: need some input on drawing a memmory map
PostPosted: Fri Nov 23, 2007 10:24 am 
Offline
Member
Member

Joined: Wed Nov 14, 2007 3:19 pm
Posts: 65
Hiya , Im going back to basics :-) , so after doing a guide I figured I would go back over real mode and draw a memmory map on paper, the problem is Im not 100% sure how to make it so its correct so Im starting at small begginings hehe

Ok so address 0000 to FFFF = 0000 to 65535 (65535 bits right? which = 1MB?)

so:

The low memmory would be drawn like so , without any sections for whats in between
Code:

0    1   2 (etc)                                 F
0    0   0                                         F
0    0   0                                         F
0    0   0                                         F
^   ^   ^                                        ^ -->
----------------------------------------------|

----------------------------------------------|


At current I have the above in 16 bit addresses and address are incremented every 16 bits to the next address , is the above how its done or are memmory addresses 32 bit?

What confuses me is theres a guide which shows
0xFFFFFFF as the final memmory address? thats 28 bits?

I could do with some explination and a good but as basic as possible and well explained memmory map if possible :-)

Im trying to get a on paper representation of memmory and see what memmory addresses look like in bits and how long a memmory address is etc, I have read a fair bit but I know theres alot I need clarified , I have read about segment:offset addressing in real mode but I want to make my memmory map of absolute addresses just so I can see whats going on , initially Im not to interested in the secrions that fill the 1mb address space , only the width of memmory addresses and what they really look like, I imagine in bits as I think thats how the computer sees them


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 23, 2007 10:27 am 
Offline
Member
Member

Joined: Wed Nov 14, 2007 3:19 pm
Posts: 65
sorry the code tags havent maintained my formatting 100% , FFFF should be at the end of the memmory map/rectangle


Top
 Profile  
 
 Post subject: Re: need some input on drawing a memmory map
PostPosted: Fri Nov 23, 2007 10:40 am 
Offline
Member
Member
User avatar

Joined: Sun Oct 22, 2006 7:01 am
Posts: 2646
Location: Devon, UK
maverick777 wrote:
Ok so address 0000 to FFFF = 0000 to 65535 (65535 bits right? which = 1MB?)


No. 1MB = 0x100000. 65535 bytes is 64KiB.

Cheers,
Adam

[EDIT]I haven't answered the rest of your post because I don't really get it. #-o [/EDIT]


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 23, 2007 11:35 am 
Offline
Member
Member

Joined: Wed Nov 14, 2007 3:19 pm
Posts: 65
Thanks Adam :-) realise you folks are so far beyond this but Im just trying to get my brain working again hehe as its been a while since I did comp architecture :-)

Ok re-done maths :

8 bits = 1 Byte
1024 Bytes = 1 KB
1024 KB = 1MB

so:
[KB] [BYTES]
1024 * 1024 = 1048576 bytes

[BYTES]
1048576 * 8 = 8388608 bits

At this point I though OK convert to hex:
8388608 dec = 800000h

Initially I wandering whys that differant from what you said adam , then I figured no memmory is addressed per byte? (8bits then new section?)
as 1048576 bytes = 100000h

Hopefully my maths is ok now , and my reasoning why your answer is correct are sound. I realised your answer was correct but just wanted to be sure I knew why . Im going to redraw a memmory map based on whats been discussed - just need to be sure im invisiging memmory correct, basically I imagine each memmory section as a square

| <-8 bits? ->| | | | (The maths is fine now its this part Im unsure about , gonna do some more reading)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 23, 2007 11:45 am 
Offline
Member
Member
User avatar

Joined: Sun Feb 18, 2007 7:28 pm
Posts: 1564
Each memory "block" is addressed on a per byte bases, so yes--each block is 8 bits.

_________________
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 23, 2007 12:03 pm 
Offline
Member
Member

Joined: Wed Nov 14, 2007 3:19 pm
Posts: 65
Ok finally :-)

a 32 bit computer can have 32 bit addresses so max address:
4 294 967 296bytes/1024/1024 = 4096MB

hex
0x00000000--------------------^
1byte
0x00000008----------------------

0x00000010----------------------

0x00000018----------------------

0x00000020----------------------

Memmory ^^

Hopefully Ive got the visualisation a bit better now :-) in short 32 bit addresses with a 1byte space to the next address?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 23, 2007 12:13 pm 
Offline
Member
Member
User avatar

Joined: Sun Feb 18, 2007 7:28 pm
Posts: 1564
If you are trying to represent bits (Have no idea why one would want to do that.) then yes, you are correct.

_________________
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 23, 2007 1:13 pm 
Offline
Member
Member

Joined: Wed Nov 14, 2007 3:19 pm
Posts: 65
Im just trying to gain understanding, when I read about real mode segment offset addressing Im not 100% sure about it , so Im just making sure I have the basics :-)

Im going to see If I can find a visual representation of segment:offset addressing, dont get me wrong I follow the formula base address = base address * seg size+ offset but Im going to try and draw that. Seems silly I know but once Ive done that I reckon It will help me feel alot more confident when it comes to reading and writing to memmory

actually I just come across this page:

Looks like its going over the basics that I was just asking about :-), hopefully this will help some other newbie :-)
http://www.folder101.com/CompHardware/N ... Addressing

Ok looks like from reading that page + all the guides , I think I understand why seg:offset is needed and In real mode every 16 bytes(128bits) constitues a segment.

so in real mode segments (memmory locations go)
0000
0010
0020
0030
and so on

(Excuse me blathering on lol but think Im soon going to fully understand real mode addressing and 32 bit protected mode addressing and I will be copyiung this into word lol


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 23, 2007 1:34 pm 
Offline
Member
Member
User avatar

Joined: Sun Feb 18, 2007 7:28 pm
Posts: 1564
That looks like a nice page ;)

I hope it helps you out :)

_________________
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 23, 2007 1:35 pm 
Offline
Member
Member

Joined: Wed Nov 14, 2007 3:19 pm
Posts: 65
Yeah it is neon :) with what you had in your guide + finding that page things are starting to make alot more sense :-)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 23, 2007 7:52 pm 
Offline
Member
Member

Joined: Wed Nov 14, 2007 3:19 pm
Posts: 65
Ok one final thing just for the sake of completness, I know the formulae for a segment offset addres to physical address is:

Paddy = 16 * segsize + offset

so say we have seg:offset = 0040:4444h

so paddy = 4844h

What would be the actual formulae to work 4844h back to its seg offset address?
0040:4444h

Thanks again (assuming seg size of 16)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 23, 2007 8:34 pm 
Offline
Member
Member
User avatar

Joined: Sun Feb 18, 2007 7:28 pm
Posts: 1564
Quote:
What would be the actual formulae to work 4844h back to its seg offset address?

There is not any (That I am aware of) because their can be so many seg:offset addresses that refer to that same linear address.

Quoted from my tutorial (This has been verified to be correct):
Quote:
Techinically, there is exactally 4,096 different combinations of segment:offset that can refer to the same byte in memory -- This is for each byte in memory!

What this means is that there are ALOT of combinations (4096, as noted above.) of seg:offset addresses that can refer to that linear address.

_________________
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 24, 2007 9:33 am 
Offline
Member
Member

Joined: Wed Nov 14, 2007 3:19 pm
Posts: 65
Thanks neon , yeah i actually slept on that thought last night and was thinking do paddy / 16 - offset but then you dont have the offset from a physical address so trying paddy / 16 would give you the segment but not any of the combinations of 4,096 offsets for that segment

Youve been saying the correct way offcourse , Im just making sure I understand it :-) , that page I mentioned is really good reading in conjunction with your guide :-)

I feel alot more confident going into protected mode now. Im going to go over GDT again and draw on paper full memmory maps at each stage when I feel I know enough to do so accuratly but Im getting there now :)

I will give you all some peace for a bit now :-)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 27 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group