Chapter 3 Memory (X86 Assembly Tutorial)

Publisher:brian808090Latest update time:2015-05-15 Source: 51heiKeywords:Memory Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
        After thinking for so long, I finally figured out the theme of this chapter, which is also very important (no chapter is unimportant!).
 
        Storage refers to the things used to store data in the computer. The more common ones are: memory, hard disk, USB flash drive, memory card, CD and other storage.

 
        The storage data mode of the memory is divided into
                    The data stored in the cache will disappear when the computer is turned off. It is usually used to store data that is needed at any time, such as running code, half-calculated mathematical equations, music being played, and videos being watched (of course, most of this data will be deleted from the cache after it is played)
                    Save, the data still exists after the power is turned off, and it can be used to store data that needs to be saved, such as games, music, videos, etc.
                    2. The cache is usually very small, such as memory, which is only a few GB. But the data operation speed is super fast. About 5 billion per second~
 
                            The files are usually very large, with hard disks of hundreds or thousands of GB, and the speed is a bit slow. Only a few hundred thousand files are saved per second (it is said that there is a kind of hard disk called solid state drive, a 500G hard disk costs more than 2,000 RMB, and the speed of operating large files is super fast (of course, it will not be faster than the memory). The principle is that it is made up of U disks, and the speed of storing files together with countless U disks is of course fast)
 

 
         Storage read and write permissions 
                    Readable and writable (data can be read and written freely)
                    Read-only (can only read data, cannot write)
                    Write-only (can only write data but not read)
        These 3 types (some special ones are not mentioned), hard disk and memory are readable and writable (memory is special, there is something called protection mode, some parts of memory cannot be read or written), read-only, CD-ROM is the classic example of read-only memory (what? You mean burning CD? They are all special ones, so I won’t mention them)
 

 

 

 
Here, we introduce a kind of memory that you may not have heard of: register
        It exists in the CPU. Different CPUs have different registers. Here we are talking about the X86 assembly tutorial. I will take the register of 80186 (the first version of X86) as an example. The register is the smallest memory. The register of 80186 can only store a glyph data (16 bits, 2 bytes) at most. Of course, there are more than one register, there are more than ten, each with a special name.

 
        The most commonly used are AX, BX, CX, DX, these 4 registers are also called general registers, are 16 bits, used for mathematical calculations and data storage, are the registers with the least special functions (specially used to store the intermediate results of mathematical calculations. If there are more special functions, wouldn't it be troublesome?), these 4 registers can also be divided into 2 8-bit registers for use, AX can be divided into AH, AL, BX can be divided into AH, AL and so on, AH is the high 8 bits of AX, AL is the low 8 bits of AX, what is the high bit and the low bit? Let's put it this way. A 2-digit decimal number. 15, where 1 is the tens digit and 5 is the ones digit, 1 is the high bit and 5 is the low bit.

 
        The CPU must rely on memory to operate, because the code (to be more specific, the machine code) is placed in the memory, and the CPU reads the code in the memory for calculation. The commonly used segment registers for operating memory: SS, CS, DS, ES (all 16 bits) and offset registers: IP, SP (16 bits) In 80186, two registers must be used to operate memory (more on this later). Among them, CS and IP often work together to point to the code to be executed, and SS and SP point to a place in the memory called the stack. Not only IP and SP can be used with segment registers for memory addressing, but also SI, DI, BP (also 16 bits) and general registers.

 
       SI, DI, BP are similar to general registers, but have some special functions (to be explained later)
 

 
        PSW, flag register, after the CPU performs mathematical calculations, it inputs data according to different calculation results. From here, we can see whether the calculation result of the previous step of the code has special meaning.
Keywords:Memory Reference address:Chapter 3 Memory (X86 Assembly Tutorial)

Previous article:Chapter 5 Hands-on Operation - Use of DEBUG 1 (X86 Assembly Tutorial)
Next article:Chapter 1 From Machine Code to Development Language (X86 Assembly Tutorial)

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号