C language (record) -- memory related _ 1: Memory base, _ 1

Source: Internet
Author: User

C language (record) -- memory related _ 1: Memory base, _ 1

This article is based on the embedded C Language

--------------------------------------------------

First, understand what the program is? Why do computers need programming?

The purpose of programming is to run and get some results. As the name implies, a computer is used for computation. Therefore, all the programs in the computer are in computation. So what is computing in the computer? Of course, data is being computed. Therefore, data is an important component of the Program. Released: computer programs = code + data. After the program runs, the result is: code + original program = new data.

From the macro perspective of the image, code is the action of processing data, and data is what the code is going to process.

For example, the following line of code (a simple function): This function (num_p) is used to execute the code for adding two numbers. The operation is to convert the two data (the form parameter int num_1, int num_2) to get a new data.

Int num_p (int num_1, int num_2)

{

Return num_1 + num_2;

}

Computer program running process

  The process of running a computer program is the process of running multiple function cameras. A program is composed of multiple functions. A function is the essence of a program, and a function is processed data.

Why memory?

  First, you need to know what memory is: (hardware and logic)
From the hardware point of view: memory is actually a computer accessory (usually called a memory stick ). Based on different hardware implementation principles, we can also divide the memory into SRAM and DRAM (DRAM has many generations, such as the earliest SDRAM, and later DDR1, DDR2 ·, LPDDR)
From a logic point of view: memory is such a thing that can be accessed randomly (random access means that you only need to give an address to access this memory address) and can be read and written (of course, it can be logically limited to read-only or write-only); Memory in programming is used to store variables (that is, because of the memory, the C language can define variables, A variable in C language actually corresponds to a unit in memory ).

  Memory is used to store data. It is the essential requirement for programming and program running. The English name (also called RAM) is RAM, which can be divided into DRAM and SRAM. Based on different storage methods, there are two types of memory: The von noriman structure and the Harvard structure. The von noriman structure is: Data and code are put together. The Harvard structure is: Data and code are separated. For example, when running an application on a linux system running on S5PV210 (the chip I am currently learning): At this time, the code and data of all applications are stored in DRAM, therefore, this structure is the Von noriman structure. In single chip microcomputer, we burn the program code to Flash (NorFlash), and then the program runs in the original Flash, the data involved in the program (global and local variables) cannot be stored in Flash, and must be stored in RAM (SRAM. This is called the Harvard structure.

Single-statement memory

  Logically speaking, memory is actually composed of an infinite number of memory cells. Each cell has a fixed address called memory address, which is the same as the memory cell.UniqueAndPermanentBIND.
Logically, the memory is like an infinite Building, and the memory cells are like small rooms in the building. The address of each memory cell is like the room number of each small room. The content stored in the memory is like the person in the room.
Ideally, the memory can be infinitely large (because the number in mathematics can always be increased and never ends ). But in reality, the actual memory size is limited. For example, a 32-bit system (a 32-bit system refers to a 32-bit data line, but the general address line is also 32-bit, the 32-bit address line determines that the memory address can only have 32-bit binary, so the logical size is 2 to the 32 power) the memory limit is 4 GB. In fact, the memory available in the 32-bit system is smaller than or equal to 4 GB (for example, I have 32-bit CPU for 32-bit windows, but the actual computer only has MB of memory ).

Memory Quantization

  For memory quantification, we have already set rules for our predecessors and big players. Generally, there are four types of characters: Bit, byte, half word, and word. In some cases, dual-text occurs, but it is not frequently used as I know, and the size of the three units, namely, half, word, and double-word, varies depending on the size.

For any system platform, one bit is 1 bit, and one byte is 8 bit, which will never change.

In some systems, the size of half-, double-, and double-words is not fixed, but the size of the double-word is always twice the size of the word, the word size is always twice that of a half word.

Memory Bit Width(Hardware and logic)
From the hardware point of view: the implementation of the hardware memory itself has a width, that is, some memory is 8 bits, and some are 16 bits. It should be emphasized that memory chips can be connected in parallel. After the parallel operation, the 8-bit memory chip can also be used to prepare 16-bit or 32-bit Hardware Memory.
Logically speaking, the memory bit width is logically arbitrary, and even the Logical Memory bit width is 24 bits (but in fact this kind of hardware cannot be purchased and has no practical significance ). Logically speaking, no matter what the memory bit width is, I can operate directly without affecting my operations. However, because your operations are not purely logical but require hardware to execute, you cannot do whatever you want. Therefore, many of our actual operations are limited by the features of hardware. For example, the 24-bit memory logic is no different from the 32-Bit Memory, but the actual hardware is 32-bit, and it must be implemented according to the characteristics and restrictions of the 32-bit hardware.

  

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.