Registers can be divided into: general registers, instruction pointer IP, segment registers and so on. Its main function is to store data and code during computation. The registers are inside the CPU and are connected by the internal bus. In the previous article, the address lines, data lines, and control lines that connect the CPU and the memory are external to the CPU relative to the registers, and are connected by an external bus.
1. General purpose register
All registers of the 8086CPU are 16-bit and can fit two bytes. The four registers, AX, BX, CX, and DX, are usually used to store general data and are called general-purpose registers. The size of each register is 16 bits. Since the previous register is 8 bits, for compatibility, the register is split into two 8-bit registers that can be used independently. AX can be divided into AH (high eight bits) and AL (low eight bits), and BS is also divided into BH and BL.
Before introducing other registers, look at a few assembly instructions: ax original value: 0000H bx original value: 0000H
mov ax,4E20H puts 4E20H into register ax. AX: 4E20H BX: 0000H
add ax,1406H Add the value of 1406H and AX into ax. AX: 6226H BX: 0000H
mov bx,2000H sends 2000H into bx. AX: 6226H BX: 2000H
add ax,bx Add the value of bx and the value of ax, and put the result in ax AX: 8226H BX: 2000H
mov bx,ax puts the data in register ax into register b. AX: 8226H BX: 8226H
add ax,bx Add the value of bx and the value of ax, and put the result in ax AX: 044CH BX: 8226H
In the last step, the values of ax and bx are both 8226H, and the addition result is 1044CH, but ax is a 16-bit register, and the maximum value is FFFFH, which is out of range. Therefore, the highest bit 1 cannot be stored in ax, resulting in the data bit of ax being 044CH.