Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”

Data segment DS+ Offset address segment BX

A data segment can be colloquially understood as a data container pointer

Such as:

MOV AX 0220H MOV DS AX MOV BX 0 MOV AX [BX] ; We find that the DS data segment is always assigning values to containers with different addressesCopy the code

Code segment CS+ offset address segment IP

Code snippets can be colloquially understood as assembly code Pointers

Such as:

MOV AX 0220H. If you want to skip this line of code, offset it

When viewing assembly code in debug mode with the -U command, you can view the scope according to CS:

Such as:

# The following analog console output -r AX=0000 BX=0000..... DS=13DB ES=13DB SS=13EB CS=13EB IP=0000 -u 13eb:0 13BE:0000 B8FFFF MOV AX,FFFFCopy the code

Stack segment SS+ offset address segment SP

A stack segment can be colloquially known as a stack pointer

What is the period of

First of all, memory is not segmented, the segmentation comes from the CPU, from our own operations on memory. By the 8086 CPU

(Segment address + Offset address = Physical Address)Copy the code

Gives the physical address of a memory cell, allowing us to manage memory in a segmented manner

Paragraph can be commonly understood as a building in the community, and the offset address is the number of the building’s residents. For example, room 101, Building 5,

Building 5 ----> Segment address Room 101 ----> offset addressCopy the code

Why do we do that?

Isn’t it easier to use a physical address directly, why split it into segments and physical addresses?

This is due to the limitations of the 8086CPU16-bit register. Since the 16-bit register can only store 0xFFFF, it cannot store addresses with more than five digits such as 0xFFFFA. To solve this problem, the designers of CUP came up with a method of segment address *16+ offset address to solve this problem perfectly

Physical address = Segment address x 16+ Offset address

A physical address can be written in four different ways, such as 0xFFFFA:

0xFFFFA=0xFFFF0*16+0x000A

0xFFFFA=0xFFF00*16+0x00FA

0xFFFFA=0xFF000*16+0x0FFA

0xFFFFA=0xF0000*16+0xFFFA
Copy the code

Period of assignment

Code segment CS data segment DS stack segment SS cannot be directly assigned, must be transferred through the general register

The offset address can be assigned directly

mov ax ,2000H
mov ss ,ax
mov sp ,10H
Copy the code