As we all know, before starting programming, we must be familiar with the components of the target system. Although today's computers have changed in price, size, and power, it can be said that many of them are similar in essence. If you take a quick look at today's computers, you will understand that many of these computers are composed of components such as main memory, peripheral memory, CPU, input devices (such as mouse and keyboard) and output devices (such as computer screen and printer).
Any program that a programmer writes must be transferred from peripheral memory to main memory before it can be executed. The user of your final program usually has to enter some data for processing, which in this context is clear to all of us that this data will not come from space, but will be entered by the user through an input device and stored in the computer's main memory.
But the work does not end there. In the main memory, this data is retrieved and processed by the CPU, and at the end of the work, we can display the information in the main memory in the desired output by an output device.
This is the general function that we perform as programmers. We store the codes we write in a memory, these codes are processed by the CPU during execution along with the required data, which may have been entered by the end user and of course through an input device, and finally the information provided is usually displayed in some way in the output, for example, in an output device, or perhaps stored in another file in the external memory in a specific format.
We can consider the memory of a computer as a series of ordered and continuous points called memory cells. So we can say that in order to store and retrieve information, the computer must be able to understand the address of each of these memory cells. For this reason, each of the memory cells has a unique address that specifies the location of that cell in the memory. Every computer has millions of memory cells, each of which has its own address and each cell is numbered with a number. For example, if we have 50 memory cells, these cells are numbered from 0 to 49.
The data stored inside the memory cells is called the contents of that memory cell. In general, what I can tell you is that all memory cells always contain information that we may not understand.
For example, in the figure I drew to show the memory cells, it is clear that cell 0 has the number -12
while the content of memory cell number 48 has the string x
.
Of course, a memory cell may contain a program instruction because, as I said, an instruction must be stored in main memory before it can be executed.
Each memory cell is made up of smaller units called bytes. A byte is the amount of memory required to store one character. The number of bytes in a memory cell varies from computer to computer, and as you might have guessed, each byte is made up of smaller units called bits.
The word bit comes from the words binary digit and is the smallest unit that a computer can handle. To put it simply, each byte is usually made up of 8 bits.
Binary is a numbering system based on zeros and ones, so each bit can have one of two values, 0
or 1
.
All data in memory is represented by a specific pattern of bits (zero or one), and a computer can both store data and retrieve data. But as we all know, a computer only recognizes zeros and ones, or bits. Therefore, to store data, the computer fills the previous contents of that cell with a specific pattern of zeros or ones, and to retrieve data, it copies the contents of the desired cell. What we learn from this process is that in the operation of storing data in memory cells, the content of the cell in question changes, but in the operation of retrieving the content of a cell from memory, the content of that cell does not change. This is a point that a programmer will always keep in mind when creating a program because although this process seems very simple to us, I have personally experienced what consequences changes have had during the execution of the program. I have personally seen and experienced that a variable has been used during the execution of the program, but for any reason, such as not being properly initialized, it has had a destructive effect on the final result and the execution process of the program. This is why you may have seen steps during the process of learning a programming language or during the process of learning programming that force you to examine the path of a variable throughout the program and determine the content of the variable at each step. This is why they teach you that you should always know the contents of the memory cells you are using at the moment to prevent unwanted errors (logical errors, bugs, or whatever you call them).
Thank you for the useful information you provided. I look forward to more posts.😍 !wine