Answer: The addressing range of 8086 CPU is 1MB. This is because the 8086 CPU has 20 address lines, and 2^20 equals 1024KB, which is 1MB. However, in the 8086 system, instructions only provide 16-bit addresses, and the registers related to addressing are only 16 bits long. Therefore, the addressing range is only 64KB. In order to be able to address 1MB of memory space, the 8086 CPU divides the memory into four logical segments. When the CPU accesses memory, the contents of the segment register (segment base address) are automatically shifted left by 4 bits (in binary representation), and then added to the 16-bit address offset within the segment to form a 20-bit physical address.
In segmented structured memory, each logical address consists of a 16-bit segment base address and offset address.
Physical address: The absolute address of the memory, from 00000H~FFFFFH, is the actual addressing address of the CPU accessing the memory (also called the absolute address)
The 16-bit segment base address is shifted left by 4 bits (equivalent to adding 4 "0"s after the lowest bit of the segment base address), and is added to the offset address to obtain the physical address.
Physical address=segment base address*16 offset address
?
In segmented structured memory, each logical address consists of a 16-bit segment base address and offset address.
Physical address: The absolute address of the memory, from 00000H~FFFFFH, is the actual addressing address of the CPU accessing the memory (also called the absolute address)
The 16-bit segment base address is shifted left by 4 bits (equivalent to adding 4 "0"s after the lowest bit of the segment base address), and is added to the offset address to obtain the physical address.
Physical address=segment base address*16 offset address
(1/2)Assembly language. 1. The maximum storage space allowed by 8086/8088 CPU is (1MB 65520), and its physical address number is from (00000) to (ffff0 ffff 1=10FFF0)H. 2. The hexadecimal number of decimal number -46 is expressed as (0FFD2h or 0D2H)
The hexadecimal representation of the decimal number 46 is 2EH
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\Administrator>debug
-a
0AFE:0100 mov ax,2e
0AFE:0103 xor bx,bx
0AFE:0105 sub bx,ax
0AFE:0107
-t
AX=002E BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000
DS=0AFE ES=0AFE SS=0AFE CS=0AFE IP=0103 NV UP EI PL NZ NA PO NC
0AFE:0103 31DB XOR BX,BX
-t
AX=002E BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000
DS=0AFE ES=0AFE SS=0AFE CS=0AFE IP=0105 NV UP EI PL ZR NA PE NC
0AFE:0105 29C3 SUB BX,AX
-t
AX=002E BX=FFD2 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000
DS=0AFE ES=0AFE SS=0AFE CS=0AFE IP=0107 NV UP EI NG NZ AC PE CY
0AFE:0107 0029 ADD [BX DI],CH DS:FFD2=00
-
Registers are 16-bit. For example, AX, BX, SI, and DI are all 16-bit. The address codes they can represent are only 16-bit. 2 to the 16th power is equal to 64K. This is the memory space that we as programmer can directly access through registers. The address bus provided by the 8086/8088 CPU has 20 bits, and 2 to the 20th power is equal to 1M. This is the maximum memory space that the CPU can access by itself.
There is a contradiction: the CPU can access 1M memory, but the register can only represent 64K memory size. Therefore, the concepts of segment address and offset address are introduced. Divide this 1M memory space into segments of 64K size, specify which segment, and then add an "offset address" at the beginning of this segment. Doesn't this allow you to access any space in 1M memory?
How to get the segment address:
For example, a character variable STR
is declared somewhere in the assembly data segment.MOV DX,SEG STR
Through the SEG statement, the segment address of STR can be taken out and sent to DX.
I hope the above content will be helpful to you!
The above is the detailed content of Why does the 8086CPU have 20 address lines but the maximum addressable storage space is only 1MB?. For more information, please follow other related articles on the PHP Chinese website!