memory location calculation - memory

The question is as follow :
A microcomputer has memory locations from 00000h to FFFFFh. Each memory
location stores 1 byte. In decimal, how many bytes can the microcomputer store in its
memory? How many Kilobytes is this?
Answer:
It requires two 2Kbytes of RAM and 512 bytes
of PROM.
I try to calculate myself before reviewing the answer,and find out that it is not same,till now i still don't understand why this is the answer,anyone may give me some help??Thanks

The answer is clearly the answer to another question and not this one.

Well, 00000h to FFFFFh, this represents 100,000h memory locations, hence 100,000h bytes. 10h^5 (hex) is 16^5 (decimal).
16^5 = (2^4)^5 = 2^20 = (1024)^2 = 1 M = 1024 K.
Conclusion: this processor can address one megabyte of memory.
Obviously, less than one megabyte is installed on this microcomputer, and not all of the installed memory is RAM. But you can't deduce this from the amount of addressable memory.

Related

How many bits are needed

I've stumbled across a problem:
How many bits are needed to address a 10kB data memory if one cell is 1 byte in size?
so when I try to solve this question the only thing I can solve is what's the amount of cells but not how many bits are needed to address a 10kB data memory.
Because what I have come up with is that the answer must be 81920/8=10240 cell amount but I'm pretty sure it's wrong because it answers the last part of the question and not how many bits.
Think of a cell as a minimal entity that can be uniquely accessed / addressed. You have 10240 such cells, so the address width must be able to represent up to that value. E.g. 8 bit wide address (noun) can address (verb) 256 unique entities, 10 bit wide address can address 1024 unique entities, etc.
Back in the days of 32-bit PCs, each process can have at most 4GB virtual memory exactly because the virtual address width was 32 bits, and the “minimal entity” addressable was a byte. So 2^32 bytes is the maximum addressable memory size for those PCs.

Confused about memory storage units

I'm reading this book 3 easy pieces by remzi. In chapter 18 paging introduction in the first paragraph it is written
(real address spaces are much bigger, of course,
commonly 32 bits and thus 4-GB of address space, or even 64 bits)
Now if 1 byte is 8 bits, shouldn't 32 bits be 32/8 4 bytes space? I have seen the math for getting the answer as 4GB
2^10 = 1KB
2^10 = 1MB
2^10 = 1GB
But then this is assuming 2^1 = 1B, But isn't this simply wrong?
What am I missing? What does my answer (4Bytes) represent here?
This question is related How many bits are needed to address this much memory?
But doesn't address why my math is incorrect. (OP there also has the exact same confusion).
Lets say that I change the word size to 64MB (wild I know). Then number of words is 1. According to the answers, number of bits would be 2^0 = 1, 0 bits? Then where and when do we use the fact that 1 byte = 8 bits?
Any help would be appreciated.
Today, RAM is byte addressable. Each address put on the address bus returns 1 byte. If you have 32 bits, the amount of different addresses that you can come up with is 2^32 = 4,294,967,296. Since you can have that much different addresses, then you can address that much bytes. In terms of bytes, this amount of bytes is called 4 GB.

How many bytes can be stored in a memory unit that uses 8 address bits and a 16 bit architecture?

I need help understanding memory. How many bytes can be stored in a memory unit that uses 8 address bits and a 16 bit architecture?
I think it's 2^8 = 256. Is this correct?
Edit: I mean 256
It depends.
Firstly "16 bit architecture" is too vague to be a helpful characterization for this problem. A characterization like that generally refers to the width of registers and data paths (e.g. in the ALU), not how memory is addressed.
Secondly, the answer actually depends on whether the addresses are byte addresses or "word" addresses. AFAIK "almost all" new processor / instruction set architectures designed since the 1980's have used byte addresses. But prior to that it was common for addresses to address words of up to 60 bits (or possibly more).
But assuming byte addressing, then an 8 bit address allows you to address 2^8 bytes; i.e. 256 bytes.
On the other hand, if we assume word addressing with a 16 bit word, then 8 bit addresses will address 256 words ... which is 512 bytes.
The base answer is the 2^number of bits. However,long ago sixteen bit systems came up with means for accessing more than 2^16 memory though segments. While an application can only access 2^16 bytes at a time, changing the values in hardware registers allows the application to change which 2^16 bytes of a larger address space are being accessed.
You typically do things like
Map buffer 1 to the address space.
Queue a read operation to the buffer.
Map another buffer 2 to the address space.
Read operation completes-map Buffer 1 back so that the data can be accessed.

Differences in calculating address bits between word / byte addressable machines

Im trying to learn about memory addressing (this is for Uni) and im unsure about the effect that a word addressable memory would have when i need to calculate number of address bits.
I will explain what (i think) I understand first.
To calculate the number of address bits I use : log2(n) where n is the number of bits of the memory.I.e for 1gb (1024mb * 1024 * 1024)= 1073741824 bits so therefore log2(1073741824 ) = 30 meaning a 1gb memory would require 30 address bits. I think im understanding that correctly.
The part im not sure about is byte addressable memory versus word addressable memory and how it might effect the number of address bits.
THE QUESTION:
Is it that the above example is correct ONLY for byte addressable and if for instance a memory was word addressable and using 16 bit or 32 bit words then the number of address bits required would be less (1/2 or 1/4 in the case of 16 and 32 bit words)??
My thinking is that if a cel holds 8 bits in a byte addressable machine then a cel in word addressable memory would hold 16bits or 32bits and therefore the address bits required should be less.
Further notes - I am aware that most memory nowadays is byte addressable and that word size in a computer is specific to the processor / bus , but the problems im working on do not mention and just ask about the effect byte /word addressable would have.
I have searched for other questions on this and not found one that answers it (or that i understand to answer it) . This for examplehttps://stackoverflow.com/questions/19528750/byte-word-addressable actually seems to be asking a similar thing but the OP seems to have posted the question incorrectly by specifying that the memory is 4M x 16 (instead of 4mb x 16bit) leading people to calculate the memory as 64mb.
First off, you need to be careful with you bits and bytes, the original example you have seems to deal with bits, each you really seem to want to know about bytes. It does matter when we are dealing with a bit addressable memory or a byte addressable memory. So, lets talk about things in terms of byte addressable or word addressable memory.
As stated, your analysis of how to get the number of bits needed to address a memory is correct; but it can be generalized. In order to get the minimum number of bits we need to fully address a memory, we need to know how many unit-size things we can address. In your case, you were calculating the number of addresses need to address a 1 Gb (giga-bit) memory. We can just as easily do it in bytes, in order to byte address a 1 GB (giga-byte) memory, you need to know the number of addressable things (bytes) there are and then take the log2 of it. So, number of things there are is easy to get, (1 GB has 1024^3 or 1 G bytes in it) so we just need to log2 that; log2(1 G) = log2(1024*1024*1024) = 3*log2(1024) = 3 * 10 = 30. So, we need 30 bits to fully address that space.
Now lets talk in words. First is knowing the word size. Word size is not strictly 32 or 16 bits, it can be a range of values, typically dependent on whatever the processor decides to call a word (or the spec that is). Lets deal in 32-bit words for our example.
Now that we have a word size, we need to know the memory size. Lets assume the same 1 GB from before, but now we are word addressing it (its a word addressable memory now and the word size is 32 bits or 4 bytes). So, just as before, we need to know the number of addressable things (now its words) that there are in the memory size. Well, this time it isnt 1 G, because our addressable thing is now 4 B in size instead of 1 B. So we need to take our 1 GB memory size and divide it by the word size (1 GB / 4 B = 0.25 G). Just as before, now that we have the number of addressable things (0.25 G), we just need to that the log2 of it; log2(0.25G) = log2 (256*1024*1024) = log2(256) + 2*log2(1024) = 8 + 2 * 10 = 28.
It all some down to the number of the addressable things (words, bytes, bits) in a given memory. As we typically give memory sizes in bytes, byte addressable calculations are easy, but the others just take a little manipulation to get something from a dimensional value (1 GB) into dimensionless value (1 G, ie 1024^3).

Displaying file size: 1000b = 1kb or 1024b = 1kb?

I am making a iOS app where the size of some files is diplayed in MB. My question is if it is correct to calculate 1000 byte = 1kb or 1024 byte = 1kb ? I have seen that Finder on the mac calculates with 1000b, but an iOS file manager called iFile calculates with 1024b. The wikipedia article didn't really answer my question. I am just askig speifically for file size not HD capacity etc.
My question is if it is correct to calculate 1000 byte = 1kb or 1024
byte = 1kb ?
Both are correct, and both are used in different situations.
1024 is more common for file sizes, while 1000 is more common for physical disk sizes, but neither is always used that way. As you mentioned, some programs uses 1000 for file sizes, and for memory cards 1024 is often used rather than 1000.
An example of how inconsistently the units are used is the 1.44 MB floppy disk. It's neither 1.44 * 1000 * 1000 bytes nor 1.44 * 1024 * 1024 bytes, but actually 1.44 * 1000 * 1024 bytes.
An effort was made to introduce the kibibyte unit, which is always 1024 bytes. It never was a hit, but you can see it used sometimes.
A kilobyte was, and sometimes (usually?) still is, 1024 bytes. And a megabyte is 1024 KB, a gigabyte is 1024 MB, and so on. But lately, those decimal-lovers have redefined them to powers of 1000, making a kilobyte 8000 bits instead of a nice power of two. They renamed the old units to "kibibites" and "mibibytes" or KiB and MiB.
So, if you want to please both crowds1, you can use KiB and powers of 1024. However, I'd suggest that, if you think it's worth the effort, make it a setting you can change that defaults to binary KB.
1 This isn't really pleasing both crowds, though. I personally hate seeing KiB. It shouldn't matter. When you need an exact measurement, measure in bytes and don't abbreviate.
1024b = 1kb
This 1000b stuff is metric... ;)
basic units(Physic, math...) :
K = 10^3,
M = 10^6
so...
1Km are 1000m.. but no 1km are 1024m
So...
A lot of programs using not good units 1024Kb = 1Mb
Historical bug. :)
Windows using normal 1kb = 1024
But if you buy disc 1GB you buy 10^9 B
The true unit of measurement for 1KB is 1024B: http://oxforddictionaries.com/definition/kilobyte?q=kilobyte
However, some manufactures of software and hardware, in an effort to decieve consumers in order to make themselves look better, may calculate it as 1000B. This is actually a pretty recent trend.
Kilo- denotes multiplication by one thousand (not 1024). Modern terminology reflects this fact:
1 kilobyte = 1000 bytes = 8000 bits
1 kibibyte = 1024 bytes = 8192 bits
Previous use of kilo (with bytes) was based on the approximation that 210 (1024) is merely close to 1000.
Imagine being tasked with coming up with a word that means 1000 bytes after some "loose approximation" had already taken the most obvious term you'd want to use. This lead to the corrected meanings listed above.
This terminology has been standardized. The following is a quote from page 143 of the The International System of Units:
The SI prefixes refer strictly to powers of 10. They should not be
used to indicate powers of 2 (for example, one kilobit represents 1000
bits and not 1024 bits). The names and symbols for prefixes to be used
with powers of 2 are recommended as follows:
kibi Ki 210
mebi Mi 220
gibi Gi 230
tebi Ti 240
pebi Pi 250
exbi Ei 260
zebi Zi 270
yobi Yi 280
The bi in the prefixes above are based on the word "binary". When you append "bit" or "byte" onto them, you get the units listed here (where conversions are also provided).

Resources