MMGameslogo  MMGames
TwitterSharebutton  FacebookSharebutton   
learn through sufferingC Language
learn through sufferingC Language

The Mechanism of Memory

Memory?
The word "memory" is a familiar term for those interested in computers.
This is where the computer's data is stored.
I think it's a story that most people have heard, even if they don't know much about computers.

"For the average person's computer knowledge, that's quite sufficient, but..."
Programming alone is not enough.
How does memory store data?
You'll need to understand that thoroughly.

I have absolutely no intention of explaining the structure of CMOS.
It's not the hardware, but the software concepts that matter.
How does memory work, and what mechanisms allow it to store data?
And the program will explain how memory is being handled.
Ultra-massive single-column locker
The memory contains a vast number of electronic components.
Each one has its own state.
It's a matter of state, meaning on or off.

And the state of the electronic component is 1 if it's on, and 0 if it's off.
Each component remembers whether it is 1 or 0.

This is, to put it in an analogy, like a massive, single-column locker.
That number is beyond anything conventional, like 10 or 100.
With a computer having 64MB of memory, you can handle more than 500 million lockers.

And that locker is numbered.
Each locker also has a state of containing luggage.
Let's count 1 if the luggage is in, and 0 if it isn't.

The computer packs the items into this locker and memorizes the numbers.
All numbers are stored as combinations of 1s and 0s.
In essence, computers store numbers in binary.
CPU bit width
You've probably also heard of the term "bit".
The computers we are currently using are 32-bit.
Currently, AMD's 64-bit CPUs are the talk of the town.
It's still a long way off before we, as general users, start using it.
As of 2017, 64-bit is now standard.

By the way, what exactly is this bit referring to?
In fact, it's deeply connected to the theme of memory this time.

"Earlier, I explained that memory is like a giant, single-column locker."
And they explained that the numbers were recorded as binary.
However, all of this data is recorded in binary.
It's really tedious to exchange data one by one.

So, one thing that comes to mind is using them in groups.
For example, if you were to use data from memory in groups of eight,
In binary, numbers from 00000000 to 11111111, that is,
"The dimensions are calculated using numbers in the range of 0 to 255 in decimal."
That should give us a reasonably accurate calculation.

You may have already noticed, but that's correct.
The number of binary digits the CPU can process at once is what we call the bit count.
That's roughly what it means when something is referred to as being a certain number of bits.
However, some CPUs can calculate more bits at once with special instructions.

In addition, a bit refers to a single digit in binary.
In the previous case, it means the CPU's processing unit is 32 bits.
32-bit rocker
We explained how the CPU handles chunks of data from memory.
And many modern computers handle them in groups of 32.
That's why we call it a 32-bit computer.
From this point forward, we will proceed assuming a 32-bit environment.

A 32-bit computer processes data in chunks of 32 bits.
Simply put, you just need to use the colossal single-column locker, sorting and using it in groups of 32.
However, in reality, they are sorted into groups of eight and each is numbered.
Dividing data into groups of eight means handling memory in units of eight bits.

"An 8-bit value is also known as a byte and serves as a fundamental unit of measurement in computing."
"This is convenient when dealing with various types of data because 8 bits are often a good fit."
"Since 8-bit values can represent numbers from 0 to 255, they are ideal for storing relatively small numbers."
Furthermore, 8 bits is also a convenient size for computers that operate in binary.

Due to circumstances like these, memory handling in a real computer is...
We are grouping the lockers into sets of eight and assigning numbers to each set.
In a 32-bit computer, they are assigned numbers within a 32-bit range.
Being within a 32-bit range means, in binary,...
00000000000000000000000000000000 ~ 11111111111111111111111111111111
It can handle 8-bit numbers within that range, up to approximately 4.2 billion in decimal.


About This Site

Learning C language through suffering (Kushi C) is
This is the definitive introduction to the C language.
It systematically explains the basic functions of the C language.
The quality is equal to or higher than commercially available books.

Part 0: Program Overview
  1. What is a program?
Chapter 3: Displaying on the Screen
  1. String Display
  2. newline character
  3. Practice Problem 3
Chapter 4: Displaying and Calculating Numbers
  1. Display of numbers
  2. Basic calculations
  3. Numeric types
  4. Practice Problem 4
Chapter 6: Input from the Keyboard
  1. input function
  2. The fear of input
  3. Practice Problem 6
Chapter 9: Repeating a Fixed Number of Times
  1. Iterative sentence
  2. How Loops Work
  3. Practice Problem 9
Chapter 10: Repeating Without Knowing the Number of Times
  1. Unspecified loop
  2. Input validation
  3. Practice Problem 10
Chapter 13: Handling Multiple Variables at Once
  1. Handling multiple variables collectively.
  2. Arrays
  3. Practice Problem 13
Chapter 19: Dynamic Arrays
  1. Create arrays freely.
  2. Practice Problem 19