Menu English Ukrainian russian Home

Free technical library for hobbyists and professionals Free technical library


Lecture notes, cheat sheets
Free library / Directory / Lecture notes, cheat sheets

Computer science and information technology. Programs in Assembler (lecture notes)

Lecture notes, cheat sheets

Directory / Lecture notes, cheat sheets

Comments on the article Comments on the article

Table of contents (expand)

LECTURE No. 15. Registers

1. Microprocessor system registers

The very name of these registers suggests that they perform specific functions in the system. The use of system registers is strictly regulated. It is they who provide the protected mode. They can also be thought of as part of the microprocessor architecture, which is deliberately left visible so that a qualified system programmer can perform the most low-level operations.

System registers can be divided into three groups:

1) four control registers;

2) four registers of system addresses;

3) eight debug registers.

2. Control registers

The group of control registers includes four registers: cr0, cr1, cr2, cr3. These registers are for general system control. Control registers are only available to programs with privilege level 0.

Although the microprocessor has four control registers, only three of them are available - cr1 is excluded, the functions of which are not yet defined (it is reserved for future use).

The cr0 register contains system flags that control the modes of operation of the microprocessor and reflect its state globally, regardless of the specific tasks being performed.

Purpose of system flags:

1) pe (Protect Enable), bit 0 - enable the protected mode of operation. The state of this flag shows in which of the two modes - real (pe = 0) or protected (pe = 1) - the microprocessor is operating at a given time;

2) mp (Math Present), bit 1 - the presence of a coprocessor. Always 1;

3) ts (Task Switched), bit 3 - task switching. The processor automatically sets this bit when it switches to another task;

4) am (Alignment Mask), bit 18 - alignment mask. This bit enables (am = 1) or disables (am = 0) alignment control;

5) cd (Cache Disable), bit 30 - disable cache memory.

Using this bit, you can disable (cd =1) or enable (cd = 0) the use of the internal cache (the first level cache);

6) pg (PaGing), bit 31 - enable (pg =1) or disable (pg = 0) paging.

The flag is used in the paging model of memory organization.

The cr2 register is used in RAM paging to register the situation when the current instruction accessed the address contained in a memory page that is currently not in memory.

In such a situation, an exception number 14 occurs in the microprocessor, and the linear 32-bit address of the instruction that caused this exception is written to register cr2. With this information, the exception handler 14 determines the desired page, swaps it into memory and resumes the normal operation of the program;

The cr3 register is also used for paging memory. This is the so-called first-level page directory register. It contains the 20-bit physical base address of the current task's page directory. This directory contains 1024 32-bit descriptors, each of which contains the address of the second level page table. In turn, each of the second level page tables contains 1024 32-bit descriptors that address page frames in memory. The page frame size is 4 KB.

3. Registers of system addresses

These registers are also called memory management registers.

They are designed to protect programs and data in the multitasking mode of the microprocessor. When operating in microprocessor protected mode, the address space is divided into:

1) global - common to all tasks;

2) local - separate for each task.

This separation explains the presence of the following system registers in the microprocessor architecture:

1) the register of the global descriptor table gdtr (Global Descriptor Table Register), having a size of 48 bits and containing a 32-bit (bits 16-47) base address of the global descriptor table GDT and a 16-bit (bits 0-15) limit value, which is size in bytes of the GDT table;

2) the local descriptor table register ldtr (Local Descriptor Table Register), having a size of 16 bits and containing the so-called selector of the descriptor of the local descriptor table LDT This selector is a pointer in the GDT table, which describes the segment containing the local descriptor table LDT;

3) the register of the interrupt descriptor table idtr (Interrupt Descriptor Table Register), having a size of 48 bits and containing a 32-bit (bits 16-47) base address of the IDT interrupt descriptor table and a 16-bit (bits 0-15) limit value, which is size in bytes of the IDT table;

4) 16-bit task register tr (Task Register), which, like the ldtr register, contains a selector, i.e. a pointer to a descriptor in the GDT table. This descriptor describes the current Task Segment Status (TSS). This segment is created for each task in the system, has a strictly regulated structure and contains the context (current state) of the task. The main purpose of TSS segments is to save the current state of a task at the moment of switching to another task.

4. ​​Debug registers

This is a very interesting group of registers intended for hardware debugging. Hardware debugging tools first appeared in the i486 microprocessor. In hardware, the microprocessor contains eight debug registers, but only six of them are actually used.

Registers dr0, dr1, dr2, dr3 have a width of 32 bits and are designed to set the linear addresses of four breakpoints. The mechanism used in this case is the following: any address generated by the current program is compared with the addresses in registers dr0... dr3, and if there is a match, a debugging exception with number 1 is generated.

Register dr6 is called the debug status register. The bits in this register are set according to the reasons that caused the last exception number 1 to occur.

We list these bits and their purpose:

1) b0 - if this bit is set to 1, then the last exception (interrupt) occurred as a result of reaching the checkpoint defined in register dr0;

2) b1 - similar to b0, but for a checkpoint in register dr1;

3) b2 - similar to b0, but for a checkpoint in register dr2;

4) bЗ - similar to b0, but for a checkpoint in register dr3;

5) bd (bit 13) - serves to protect the debug registers;

6) bs (bit 14) - set to 1 if exception 1 was caused by the state of the flag tf = 1 in the eflags register;

7) bt (bit 15) is set to 1 if exception 1 was caused by a switch to a task with the trap bit set in TSS t = 1.

All other bits in this register are filled with zeros. Exception handler 1, based on the contents of dr6, must determine the reason for the exception and take the necessary actions.

Register dr7 is called the debug control register. It contains fields for each of the four debug breakpoint registers that allow you to specify the following conditions under which an interrupt should be generated:

1) checkpoint registration location - only in the current task or in any task. These bits occupy the lower 8 bits of register dr7 (2 bits for each breakpoint (actually a breakpoint) set by registers dr0, dr1, dr2, dr3, respectively).

The first bit of each pair is the so-called local resolution; setting it tells the breakpoint to take effect if it is within the current task's address space.

The second bit in each pair specifies the global permission, which indicates that the given breakpoint is valid within the address spaces of all tasks in the system;

2) the type of access by which the interrupt is initiated: only when fetching a command, when writing, or when writing / reading data. The bits that determine this nature of the occurrence of an interrupt are located in the upper part of this register. Most of the system registers are programmatically accessible.

Author: Tsvetkova A.V.

<< Back: Registers (Microprocessor system registers. Control registers. System address registers. Debug registers)

>> Forward: Assembly Instruction Structures (Structure of a machine instruction. Methods for specifying instruction operands. Addressing methods)

We recommend interesting articles Section Lecture notes, cheat sheets:

Nervous diseases. Crib

Psychology of development and developmental psychology. Lecture notes

Housing law. Crib

See other articles Section Lecture notes, cheat sheets.

Read and write useful comments on this article.

<< Back

Latest news of science and technology, new electronics:

The existence of an entropy rule for quantum entanglement has been proven 09.05.2024

Quantum mechanics continues to amaze us with its mysterious phenomena and unexpected discoveries. Recently, Bartosz Regula from the RIKEN Center for Quantum Computing and Ludovico Lamy from the University of Amsterdam presented a new discovery that concerns quantum entanglement and its relation to entropy. Quantum entanglement plays an important role in modern quantum information science and technology. However, the complexity of its structure makes understanding and managing it challenging. Regulus and Lamy's discovery shows that quantum entanglement follows an entropy rule similar to that for classical systems. This discovery opens new perspectives in the field of quantum information science and technology, deepening our understanding of quantum entanglement and its connection to thermodynamics. The results of the study indicate the possibility of reversibility of entanglement transformations, which could greatly simplify their use in various quantum technologies. Opening a new rule ... >>

Mini air conditioner Sony Reon Pocket 5 09.05.2024

Summer is a time for relaxation and travel, but often the heat can turn this time into an unbearable torment. Meet a new product from Sony - the Reon Pocket 5 mini-air conditioner, which promises to make summer more comfortable for its users. Sony has introduced a unique device - the Reon Pocket 5 mini-conditioner, which provides body cooling on hot days. With it, users can enjoy coolness anytime, anywhere by simply wearing it around their neck. This mini air conditioner is equipped with automatic adjustment of operating modes, as well as temperature and humidity sensors. Thanks to innovative technologies, Reon Pocket 5 adjusts its operation depending on the user's activity and environmental conditions. Users can easily adjust the temperature using a dedicated mobile app connected via Bluetooth. Additionally, specially designed T-shirts and shorts are available for convenience, to which a mini air conditioner can be attached. The device can oh ... >>

Energy from space for Starship 08.05.2024

Producing solar energy in space is becoming more feasible with the advent of new technologies and the development of space programs. The head of the startup Virtus Solis shared his vision of using SpaceX's Starship to create orbital power plants capable of powering the Earth. Startup Virtus Solis has unveiled an ambitious project to create orbital power plants using SpaceX's Starship. This idea could significantly change the field of solar energy production, making it more accessible and cheaper. The core of the startup's plan is to reduce the cost of launching satellites into space using Starship. This technological breakthrough is expected to make solar energy production in space more competitive with traditional energy sources. Virtual Solis plans to build large photovoltaic panels in orbit, using Starship to deliver the necessary equipment. However, one of the key challenges ... >>

Random news from the Archive

Laser communication in space 14.06.2008

German physicists transmit information between spacecraft using a laser.

Satellites now use radio signals to communicate. However, with their help, it is no longer possible to transfer the volumes of data that modern researchers need. There is a solution: switch to light waves. They have a much shorter wavelength, respectively, and more information will fit.

As German engineers from the Fraunhofer Institute for Laser Technology found out during recent tests, when using a laser, the information density increases a hundred times and provides the transfer of its volume equivalent to 400 DVDs per hour. They quite successfully transmitted information over a distance of 5000 km from German to an American satellite.

"The laser must be small and reliable. We managed to create such a design that its size does not exceed the size of a matchbox, and the weight corresponds to a bar of chocolate. It withstood extremely difficult conditions: temperatures from -35 to 60 ° C, acceleration of 1300 g and gamma irradiation "rays," says project manager Martin Traub. "However, the laser power is several watts, and we have not yet decided how to dissipate the heat generated during operation."

Other interesting news:

▪ The cat's brain shrinks

▪ 32-bit RISC microcontrollers

▪ Microplastics affect life in soil

▪ Ultra-precise star

▪ New FLUKE Insulation Testers

News feed of science and technology, new electronics

 

Interesting materials of the Free Technical Library:

▪ site section Tone and volume controls. Article selection

▪ article Flower garden on wheels. Tips for the home master

▪ article Who and why divided the Commonwealth in the XVIII century? Detailed answer

▪ article Head of Revenue Collection Department. Job description

▪ article Triac power regulator. Encyclopedia of radio electronics and electrical engineering

▪ article Boost voltage converter, 5-9/9-12 volts. Encyclopedia of radio electronics and electrical engineering

Leave your comment on this article:

Name:


Email (optional):


A comment:





All languages ​​of this page

Home page | Library | Articles | Website map | Site Reviews

www.diagram.com.ua

www.diagram.com.ua
2000-2024