C Board  

Go Back   C Board > Community Boards > General Discussions

Reply
 
LinkBack Thread Tools Display Modes
Old 09-10-2009, 11:10 AM   #1
DESTINY
 
BEN10's Avatar
 
Join Date: Jul 2008
Location: in front of my computer
Posts: 803
microprocessor

Hello all,
I dont know why I always get stuck in the microprocessors things. I'm having a course of 8086 microprocessor. I ahve following questions. Please answer them in detail-
1. The address bus is of 20 bits, so this means that 8086 can access 1M of memory. I dont understand what this means. Does this mean that we can attach 1M of RAM to it? Please explain in detail as if you are explaining a real stupid. Really I'm a real noooooooooob when it comes to deal with memory and registers.
2. Why does the 8086 need 4 segment registers of 64K? I've also read 8085 but there was no need of such segment registers.
I have gone through my book and few websites but none of them explains the memory part in detail.
Thanks
__________________
HOPE YOU UNDERSTAND.......

By associating with wise people you will become wise yourself
It's fine to celebrate success but it is more important to heed the lessons of failure
We've got to put a lot of money into changing behavior


PC specifications- 512MB RAM, Windows XP sp3, 2.79 GHz pentium D.
IDE- Microsoft Visual Studio 2008 Express Edition
BEN10 is offline   Reply With Quote
Old 09-10-2009, 11:17 AM   #2
critical genius
 
MK27's Avatar
 
Join Date: Jul 2008
Location: SE Queens
Posts: 5,212
BEN10 you know our policy here about homework!

But since I don't actually know the answer for a fact, I will give you a clue about what I would guess (in an educated way) for #1: How big can an (unsigned) int be if it is 20 bits long? In other words, what is the largest number you can represent with 20 bits, if the smallest is 0x0?

A much less educated guess for #2 has something to do with the number of instruction pointers maintained by the processor.
__________________

"A man can't just sit around." -- Larry Walters

Last edited by MK27; 09-10-2009 at 11:19 AM.
MK27 is online now   Reply With Quote
Old 09-10-2009, 11:18 AM   #3
Super Moderator
 
Join Date: Sep 2001
Posts: 4,746
In each case, the limit is because you have a binary number of a certain length stored in a certain device. The maximum value of that number is how much memory that device can address.
sean is offline   Reply With Quote
Old 09-10-2009, 11:18 AM   #4
Malum in se
 
abachler's Avatar
 
Join Date: Apr 2007
Posts: 3,188
An 8086 wired in Harvard configuration can address 4MB of memory, warning this is an advanced configuration used (AFAIK) only in embedded designs and your instructor is unlikely to have even heard of it, so I wouldn't mention it in class. 4 segment registers are needed because, well, they aren't really needed, they just make the processor more flexible.
__________________
Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.
abachler is offline   Reply With Quote
Old 09-10-2009, 11:44 AM   #5
Jaxom's & Imriel's Dad
 
Kennedy's Avatar
 
Join Date: Aug 2006
Location: Alabama
Posts: 877
A couple of keywords to search for would be "Protected mode", "Gate A20", and snot, it left. About 3 years ago I had to write a boot loader for an i486 clone. I actually _had_ to learn all that crap to get it to work, however, I cannot recall what any of the terminology means at the moment.
Kennedy is offline   Reply With Quote
Old 09-10-2009, 09:46 PM   #6
DESTINY
 
BEN10's Avatar
 
Join Date: Jul 2008
Location: in front of my computer
Posts: 803
@MK27
This is not a homework I'm not asking for someone to code something for me. I'm just asking for make the concepts clear to me. And yes I do know that 2^20=1M, but what I dont understand is what this means? The resources say that it can address 1MB of memory, here is where I get confused.
So, please if somebody know it better help me in understanding it.
__________________
HOPE YOU UNDERSTAND.......

By associating with wise people you will become wise yourself
It's fine to celebrate success but it is more important to heed the lessons of failure
We've got to put a lot of money into changing behavior


PC specifications- 512MB RAM, Windows XP sp3, 2.79 GHz pentium D.
IDE- Microsoft Visual Studio 2008 Express Edition
BEN10 is offline   Reply With Quote
Old 09-10-2009, 09:57 PM   #7
Senior software engineer
 
brewbuck's Avatar
 
Join Date: Mar 2007
Location: Portland, OR
Posts: 5,768
Quote:
Originally Posted by BEN10 View Post
@MK27
This is not a homework I'm not asking for someone to code something for me. I'm just asking for make the concepts clear to me. And yes I do know that 2^20=1M, but what I dont understand is what this means? The resources say that it can address 1MB of memory, here is where I get confused.
So, please if somebody know it better help me in understanding it.
Do you mean why is the size of the address space equal to 2^N where N is the number of address bits? That's because with N bits it is possible to describe 2^N possible values. We can use each of those values to refer to a byte of memory so that each byte has its own address.

Or are you confused about how a 16-bit segment address and a 16-bit segment offset combine to produce a 20-bit address? That's an oddity peculiar to real mode x86.

If an address is given as SEGMENT:OFFSET, then the absolute physical address is SEGMENT*16 + OFFSET. You should be able to see that there is more than one way to refer to the same physical address. The address 0x0001:0000 and the address 0x0000:0010 both refer to physical address 0x10, because 1*16+0 == 16 and also 0*16+16 == 16.

This produces a huge overlap in the address space such that each byte of memory can be addressed in 4096 different ways. These 4096 ways represent a redundancy in the address space of 12 bits (2^12 == 4096). Thus, although you have 32 bits of address, you lose 12 bits because of this overlapping, resulting in (effectively) a 20-bit address space.

Edit: If you're observant you notice that there are some addresses which don't have 4096 different ways of addressing them. For instance, physical address 0x0 can only be written as 0x0000:0000. This might lead you to wonder where these "missing" addresses have gone. In fact, they appear at the very top of the address space as an extra 64k (okay, actually 65519 bytes) of memory you can access beyond the 1M barrier. I only mention this because I'm sure abachler will point it out if I don't
__________________
"Congratulations on your purchase. To begin using your quantum computer, set the power switch to both off and on simultaneously." -- raftpeople@slashdot

Last edited by brewbuck; 09-10-2009 at 10:02 PM.
brewbuck is offline   Reply With Quote
Old 09-10-2009, 10:04 PM   #8
DESTINY
 
BEN10's Avatar
 
Join Date: Jul 2008
Location: in front of my computer
Posts: 803
Thanks brewbuck for a helpful reply. What I'm asking is that what do they mean when they say that the microprocessor can address 1M(for 20bitaddress bus) or 64K(for 16 bit) of memory. Could you elaborate this one please. I know how do they get it(2^20 or 2^16), but I dont undertsand what is actually its meaning. In some places they say it can address 1M of memory and in other places they say it can address 1MByte of meomory(why not 1Mbit)? I hope now my question is clear.
EDIT: My second question is why is their a need of segment registers in 8086, why not a full 20bit address rather than dividing the address in 4segments?
__________________
HOPE YOU UNDERSTAND.......

By associating with wise people you will become wise yourself
It's fine to celebrate success but it is more important to heed the lessons of failure
We've got to put a lot of money into changing behavior


PC specifications- 512MB RAM, Windows XP sp3, 2.79 GHz pentium D.
IDE- Microsoft Visual Studio 2008 Express Edition

Last edited by BEN10; 09-10-2009 at 10:08 PM.
BEN10 is offline   Reply With Quote
Old 09-10-2009, 10:11 PM   #9
Senior software engineer
 
brewbuck's Avatar
 
Join Date: Mar 2007
Location: Portland, OR
Posts: 5,768
Well, either 1 M or 1 Mbyte or 1 megabyte all mean the same thing -- 1048576 ( == 2^20 ) bytes.

There are several reasons why addresses refer to bytes instead of bits. For one, each bit having its own address doesn't turn out to be helpful in practice (i.e. it makes it more difficult to write programs). It also reduces the amount of RAM that could be addressed by a given number of address bits.

On the other hand, why don't addresses refer to 32-bit quantities instead of 8-bit quantities (for instance)? Well, there ARE some machines like that. The advantage is that you get a larger memory (4 times what you could address with byte addressing). The disadvantage is that types which are less than 32 bits large are more difficult to manipulate (the C type 'char' would be very inefficient for instance).

Of course, all molds are broken, and I'm sure there are machines out there where each bit has its own address.

EDIT: To be clear, the memory is not divided into four segments, the processor's VIEW of the memory is divided because it only has four segment registers. As for why the addressing is not directly 20-bit, it's a complicated thing. For one, having these overlapping segments is actually convenient in many ways. It means that data can be divided up into 64k-sized chunks and moved around in memory. It's sort of like a primitive form of virtual memory but without any protection. For another, the architecture was inherently 16-bit, and it would have been inefficient to have 20-bit address values flowing through the processor -- especially so because most applications would never need to use that much memory to begin with.

It's weird how this stuff all made so much sense back when it was widely used, and these days people (quite rightly) ask questions like this.
__________________
"Congratulations on your purchase. To begin using your quantum computer, set the power switch to both off and on simultaneously." -- raftpeople@slashdot

Last edited by brewbuck; 09-10-2009 at 10:20 PM.
brewbuck is offline   Reply With Quote
Old 09-10-2009, 11:58 PM   #10
DESTINY
 
BEN10's Avatar
 
Join Date: Jul 2008
Location: in front of my computer
Posts: 803
This is what I found on one of the websites:
Quote:
The 'width' of the address bus (i.e. the number of signals (bits) that comprise it) determine how much memory can be addressed. Hence, if you have a 16-bit address bus, you can represent a number (in binary) up to 2^16 (=65536) possible values (actually the range used is 0-65535), so you can individually refer to 65536 different memory addresses, or 64K of memory*.

(* This is actually not strictly the case; when people refer to '64k of memory' they mean 64k bytes (8-bit values) of memory. If you've got a 16-bit address bus (so 65536 possible address) and a 16-bit data bus, you can still address 65536 different physical memory locations, but each one is a 16-bit value. As a 16-bit value can also be considered as two 8-bit bytes, you can address 128k(bytes) of actual memory with this setup)
What does the footnote mean?
__________________
HOPE YOU UNDERSTAND.......

By associating with wise people you will become wise yourself
It's fine to celebrate success but it is more important to heed the lessons of failure
We've got to put a lot of money into changing behavior


PC specifications- 512MB RAM, Windows XP sp3, 2.79 GHz pentium D.
IDE- Microsoft Visual Studio 2008 Express Edition
BEN10 is offline   Reply With Quote
Old 09-11-2009, 12:49 AM   #11
Senior software engineer
 
brewbuck's Avatar
 
Join Date: Mar 2007
Location: Portland, OR
Posts: 5,768
Quote:
Originally Posted by BEN10 View Post
This is what I found on one of the websites:

What does the footnote mean?
It means what I said in the third paragraph of my previous post.
__________________
"Congratulations on your purchase. To begin using your quantum computer, set the power switch to both off and on simultaneously." -- raftpeople@slashdot
brewbuck is offline   Reply With Quote
Old 09-11-2009, 08:08 AM   #12
critical genius
 
MK27's Avatar
 
Join Date: Jul 2008
Location: SE Queens
Posts: 5,212
I don't understand why you are so confused. You know what an address is, right, eg, a pointer address? Notice the units with malloc are integer bytes. If I have a million possible addresses, then I can access up to 1M of memory.

The address bus delivers an address to the processor. If it is 20-bits wide, that is an observation about a physical characteristic of the bus: it's a pathway thru which a simultaneous "sequence" of bits flows (ie, they do not actually occur one after the other, 010101001, they occur all at once, in a row, 20 of them). If one such row is a memory address, and the addresses are integers, the range of addresses will be from 0 to 2^20-1. Even if there are a million gigabytes hooked up to the processor, it can only make use of 1Mb because it cannot processes addresses for any more than that.

I suppose you could make each unit of memory larger, but then you would have to write software exclusively for such an arrangement (I think), because as you know from programming, it is fundamental that one address refer to one byte, 8 bits. Although the address of each byte actually requires 20 bits to store (in the 8086), of course they actually are not stored anywhere, they are abstractions that refer to places in physical memory.
__________________

"A man can't just sit around." -- Larry Walters

Last edited by MK27; 09-11-2009 at 08:12 AM.
MK27 is online now   Reply With Quote
Old 09-11-2009, 05:08 PM   #13
Super Moderator
 
Bubba's Avatar
 
Join Date: Aug 2001
Posts: 7,817
This discussion is bringing back terrible memories of having to bank switch to access a frame buffer that was larger than 64k. Real mode was just awful and we stayed in it for way way too long. Intel had protected mode as of the 386 and yet we really didn't use it all that much until the Pentium 1 when W95 came out. The 486 actually had a very good protected mode and games frequently made use of it via Rational Systems DOS4GW extender or some other extender....but the OS was sadly all in real mode. Also brings back memories of EMM386 (EMS) and HIMEM.SYS (XMS) and the awful re-entrancy problems in DOS. Only good thing about those days is that they are gone.

This also made memory configs a huge mess. There was barely enough room for MSCDEX, your mouse, sound, and other drivers in upper memory.
__________________
If you aim at everything you will hit something but you won't know what it is.
Bubba is offline   Reply With Quote
Old 09-11-2009, 10:15 PM   #14
DESTINY
 
BEN10's Avatar
 
Join Date: Jul 2008
Location: in front of my computer
Posts: 803
Quote:
Originally Posted by MK27 View Post
Even if there are a million gigabytes hooked up to the processor, it can only make use of 1Mb because it cannot processes addresses for any more than that.
That's what my question is, what's get "hooked" up with the processor to make use of the 1MB of memory. Is it RAM of 1MB size? The various places of RAM is given addresses varying from 00000H uptill 1MB and whatever is stored in these addresses gets executed by our system. Is this true?
__________________
HOPE YOU UNDERSTAND.......

By associating with wise people you will become wise yourself
It's fine to celebrate success but it is more important to heed the lessons of failure
We've got to put a lot of money into changing behavior


PC specifications- 512MB RAM, Windows XP sp3, 2.79 GHz pentium D.
IDE- Microsoft Visual Studio 2008 Express Edition

Last edited by BEN10; 09-11-2009 at 10:17 PM.
BEN10 is offline   Reply With Quote
Old 09-12-2009, 06:36 AM   #15
critical genius
 
MK27's Avatar
 
Join Date: Jul 2008
Location: SE Queens
Posts: 5,212
Quote:
Originally Posted by BEN10 View Post
That's what my question is, what's get "hooked" up with the processor to make use of the 1MB of memory. Is it RAM of 1MB size? The various places of RAM is given addresses varying from 00000H uptill 1MB and whatever is stored in these addresses gets executed by our system. Is this true?
The physical memory is connected to the processor via the system bus. Looks to me like the address bus is considered part of the system bus:

system bus demonstration (ROM and RAM)

The RAM is connected to the north bridge on the mother board, and the north bridge connects to the processor via the system bus, also called the Front Side Bus. If you look at your motherboard, the processor, the north bridge, and the RAM are very easy to see (the north bridge has a big square heat sink on it, like the processor, but less elaborate).

This is a FSB chip, I believe. So the "address bus" is part of it. I also figure each of the little pin legs represents a one bit pathway, in which case you can see how all the bits line up. But I don't know that for sure.
Attached Images
 
__________________

"A man can't just sit around." -- Larry Walters

Last edited by MK27; 09-12-2009 at 06:40 AM.
MK27 is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
assembly for M8 microprocessor series GanglyLamb Tech Board 3 03-15-2006 05:34 PM
What's cooler than free boobs? 5 free assembly books from AMD. Silvercord A Brief History of Cprogramming.com 47 02-13-2003 08:22 PM
Does inline assembly still have to follow microprocessor instruction set? Silvercord C++ Programming 8 01-30-2003 04:29 PM
a microprocessor thing! badhri C Programming 8 05-29-2002 10:58 AM
What is the best way to test the microprocessor until failure vnrabbit C Programming 9 03-13-2002 10:46 AM


All times are GMT -6. The time now is 10:56 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22