Assembly language notes 02_Overview 2_CPU and registers (Summary of small turtle notes)

CPU overview

A typical CPU is composed of arithmetic units, controllers, registers and other devices, which are connected by internal buses .

Internal bus and external bus

  1. Internal bus: realize the connection between the various devices inside the CPU.

  2. External bus: Realize the connection between the CPU and other devices on the motherboard.

Register overview

8086CPU has 14 registers, of which there are 8 general-purpose registers.

General register

The 8086CPU has 14 registers, all of which are 16 bits. Each register can store two bytes, that is, one word.

What is a general register

AX, BX, CX, DX are usually used to store general data, called general-purpose registers.

The registers in the previous generation of 8086 CPUs are all 8-bit, so in order to ensure compatibility, these four registers can be divided into two independent 8-bit registers for use.

AX can be divided into AH and AL , which are high and low bits respectively. The same is true for the other three general-purpose registers.

How to be compatible: AH is all 0, use an AL alone.

The structure of general registers

Take AX as an example

16 bits: 0-15 from low address to high address respectively.

The storage of 16-bit data in the register

data Binary representation Storage in register AX
18 10010 0000000000010010
20000 100111000100000 0100111000100000

The maximum value of data that can be stored in a 16-bit register: 2^16-1

Word storage in registers

A word is two bytes.

The high byte and low byte of the word naturally exist in the high 8-bit register and the low 8-bit register of this register.

Common assembly instructions

Assembly instructions are not case sensitive!

Assembly instructions High-level language description
mov ax,18 ax=18
add ax,bx ax=ax+bx

When carrying out data transfer or operation, pay attention to the number of bits of the two operation objects of the instruction should be the same.

If the result of the addition exceeds the maximum value, the lower bits are stored, but the extra bits are not thrown away.

AL also follows the above rules, the extra bits will not be in AH.

Physical address

The storage space formed by all memory cells is a one-dimensional linear space.

The address of the memory unit is given when the CPU accesses the memory unit.

This unique address is the physical address.

16-bit CPU

feature:

  1. The arithmetic unit can process up to 16 bits of data at a time.

  2. The maximum width of the register is 16 bits

  3. The path between the register and the arithmetic unit is 16-bit

Working principle of 8086 address adder

Physical address = segment address * 16 + offset address

Segment address *16 in binary representation: the segment address is shifted to the left by four digits and the segment address in hexadecimal notation is shifted to the left by one.

A number's X base is shifted by n bits to the left, which is equivalent to multiplying by X n X^nXn

Guess you like

Origin blog.csdn.net/david2000999/article/details/115198825