[MUSIC].
Let's take a look at how we represent
information using these zero's and one's
these low voltages and high voltages.
We're going to group our binary digits,
bits, into groups of eight, that we're
going to call bytes.
And, if we do that, you'll notice that we
can have a range of values that go from
000 to 11111.
And that gives a range for the kinds of
numbers we can represent in a, in a
single byte.
That's going to correspond to zero
decimal to 255.
And how did we get that 255?
Well, if we think about numbers being
represented by a ones digit.
And then of course in decimal we would
have a 10's digit here, but in binary
that's a 2's digit and then a 4's digit
and an 8's and 16's and 32's, 64's and
128's.
So, if we add all of those values we
would get 255.
As a little example.
Let's take a look at this number here.
00101011.
That corresponds to a 1 in the 32's
column, a 1 in the 8's column, a 1 in the
2's column, and lastly, a 1 in the 1's
column.
When we add those values, we get the
decimal number 43.
In the other direction, if we started
with the number 26 in decimal, that's a
16 plus an 8 plus a 2, all powers of 2.
And that yields the following binary
number, 00101010.
So the conversion is pretty simple.
It pretty much involves just the powers
of two.
Now, one of things that we do because it
gets tiring to say zero zero one zero one
zero one zero,
We'll take a byte and represent it as.
Two hexadecimal digits.
Hexadecimal digits are base 16 digits.
So now instead of a ones column or a twos
column.
We have a ones column and a 16 columns.
So in this case we would represent a byte
by the digits 0, 0.
Each one of these is a group of four
binary digits.
And we can range all the way up to FF.
The, case of all one binary digits, like
we had above.
The table on the right, shows you the
correspondence of the numbers from 0 to
15, in both binary and hexadecimal.
So, you can see that we use the numbers 0
through 9 because we're already familiar
with those.
We use those in our, in our decimal
system, but those other six values we
need from 10 to 15 in bay 16, we'll use
the letters A through F.
And the correspondence to the binary
digits is right here.
So, we can see we can go, we go from the
initials all 0's to a final all 1's.
'Kay.
In the C language, we can write these
expressions these values, very easily by
using the notation 0x to indicate a hex
number.
And a number in base 16.
Here, we see an eight digit hexidecimal
number.
Since the digits of 4 bits each, that's a
32 bit long number that will be
represented in for bytes.
And in C, it doesn't matter whether we
use upper case or lower case letters.
Either one will work.
Okay, so now that we have an idea of how
the numb-, numbers are represented we'll
be going a lot more into that soon.
But we have our basic integers here.
How do we find these in memory?
So the first thing we should understand
is that memory has been organized also in
bytes.
Basically it's just a big long list of
bytes, and each one of these bytes has
and address or an index that we can use
to refer to it.
the if we start at the index that begins
with all zeros and we end at the index of
all one's or all f's in hexidecimal
notation.
All right, so basically we have a byte.
At the start followed by another byte
another byte another byte all the way to
the end.
How many bytes do we have?
Well, that depends on how many bits we
have in the address.
that's possible and we're going to see
that we have 32-bit machines that use
32-bit addresses.
And the more modern 64-bit machines that
use 64-bits of address.
All right.
Where do those numbers go in these little
bytes in memory, these locations, is
dependent on the compiler and the
run-time system of our machine.
It will decide where the various numbers
are stored, and allocates them by finding
a place for them in that memory.
Alright so let's talk a little bit about
machine words we've been I've been
mentioned that maybe we'll have machines
with 32-bit addresses or 64-bit
addresses.
that, that amount corresponds to the word
size of the machine.
its all the word sizes also the nominal
size of all the integer values we use so
when a 32-bit machine will have integers
that can go up to 32 binary digits.
And this includes address represented in
words.
So what, as I mentioned before, until
recently, most machines used 32-bits, or
4 byte words.
In the old days, we also had machines
with 16-bit words or even at the very
beginning, 8-bit words.
This limits addresses to 4 gigabytes.
That's how many different numbers we can
have in 32-bits.
Therefore how many different addresses
that we can have in the memory.
This has become now too small for memory,
memory for many memory intensive
applications.
Many of our applications use much more
space than that.
So computers have changed to use 64 bit
words 8 bytes long and now we can have 2
to the 64 different addresses.
Which leads to 18 exabytes of data to be
addressed.
That's a huge amount, and we haven't run
into that wall yet, but we probably will
one day.
So for backward compatibility though,
many CPUs still support different word
sizes.
we'll be looking primarily at 64 and
32-bits.
But there are some instructions that
you'll encounter that might manipulate
16-bit quantities or 8-bit, one byte
quantities.
Alright, so how do we refer to then these
larger things in memory?
We have mentioned bytes so far.
Well, that's what we see here on the
right, in the slide.
We have an address corresponding to each
byte of the memory, each individual
little cell, where we can put an 8 bit
quantity.
But I just said that we use 32-bit words
to represent numbers in many of our
machines.
So 4 bytes will have to be grouped
together to represent a single word.
Well, what address are we going to give
that word?
The next one after it will also require
an address what will we use for that.
In a 64-bit machine of course, will have
to group the first 8 bytes into a word.
And then we have to decide on the address
for that.
To have a uniform policy, what we do is
we say, the address of the word is the
address of the first byte in the word.
So in this case we would have the first
32-bit word would have the address 000
because it starts at that byte.
The next word's address though is 0004.
And it doesn't make any sense to talk
about the words between those at
addresses 1, 2, and 3, because we're
going to be grouping things.
In this 4 byte structure.
So we want to move on to the next four
byte structure.
So the next address will be four, the
next address will be eight, the next
address after that will be 12, and so on.
And these are in base 10.
Wyszukiwarka
Podobne podstrony:
Organizacja i zarzadzanie 0202 Organizatorzy Auschwitz powracają02 Organizowanie działalności hotelarskiej05 02 Organizacja ruchu na budowie liniowej v1 1Organizacja i zarzadzanie EGZAMIN 0202 Organizowanie łańcucha dostawid703Organizacja rachunk 02 03 scenariusz2005 02 Linux on a Stick Booting Linux from a Usb Memory StickMargit Sandemo Cykl Saga o czarnoksiężniku (02) Blask twoich oczudysleksja organizacja pomocy w szkolet informatyk12[01] 02 10104?che Organizationintroligators4[02] z2 01 n02 martenzytyczne1OBRECZE MS OK 0202 Gametogenezawięcej podobnych podstron