One lesson per day (8/75) Introduction to the register group of CPU resources and memory

Source: Internet
Author: User

When using assembly programming, you must directly operate on hardware resources, such as internal CPU resources, memory and I/O Ports. Therefore, you must learn and remember the name, function, and common usage of the internal CPU registers, thanks to God, there are not many registers. It is also difficult to understand the memory segment management mode, the address representation of the storage unit, and the physical address formation mode.

Register Group

Registers are the internal data storage resources of the CPU and the compilationProgramOne of the hardware resources that can be used, because the access speed is much faster than the memory, you should make full use of the register storage function when compiling and writing programs.
Registers are generally used to store the intermediate results of an operation process and quickly read Subsequent commands. This avoids overhead caused by pushing into the stack and then popping up.
In addition, because the number and capacity of registers are limited, it is impossible to store all the intermediate results into the registers. Therefore, we need to adjust the registers according to the order of instructions, how to arrange appropriate registers to avoid the transfer operation of too many operands is a very meticulous task, there are some specialized register allocation policiesArticleIn the Book Compilation principles.

16/32-bit CPU is often used in PC, so the names and specific functions of the internal registers of these two CPUs are introduced.

1. 16-bit CPU register group
4 data registers (ax, BX, CX, dx) 2 address changes and pointer registers (Si, DI) 2 pointer registers (SP, bp)
4 segment registers (ES, Cs, SS, DS) 1 Instruction Pointer register (IP) 1 flag register (flags: the 16 binary bits only use nine binary bits as the flag, which will be described in the next chapter)

Data registers, address changes, pointer registers, and pointer registers all belong to common registers. Because of their good versatility, data registers can be used as a 16-bit register, it can be split into two 8-bit registers.
In some CPU commands, General registers may be treated as implicit operands. For example, the loop command I introduced in chapter 6 treats ECx as an implicit operand and makes it a cyclic counter.

2. 32-bit CPU register group
All registers that contain 16-bit CPUs expand the General registers, instruction pointers, and sign registers to 32-bit, and add two segment registers FS and Gs.
4 data registers (eax, EBX, ECx, EDX) 2 address changes and pointer registers (ESI, EDI) 2 pointer registers (ESP, EBP)
6 segment registers (ES, Cs, SS, DS, FS, GS) 1 Instruction Pointer register (EIP) 1 flag register (eflags: 32 bits only use 13 BITs as the flag)

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.