什么是细分,如何在8086模式下解决? [英] What are Segments and how can they be addressed in 8086 mode?

查看:141
本文介绍了什么是细分,如何在8086模式下解决?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从开始使用8086汇编语言编程以来,我就一直在思考这些段和段寄存器.我面临的问题是,我无法直观地看到脑海中有哪些细分,因此这些概念对我来说并不明确.

Ever since I started with 8086 Assembly Language programming, I have been hammering my mind about these Segments and Segment registers. The problem I am facing is that I can't have a visual image of what segments are in my mind and therefore the concepts are not clear to me.

  • 有人可以帮助我理解与现实世界相关的概念吗??我还有以下问题:
  • Can anyone help me understand the concept relating it to a real world scenario? Also I have the following questions:

问题1:

据我了解,在启用20条地址线的16位实模式下,我们可以将物理内存分为16个段,每个段具有64KiB.第一段从0x00000开始.下一个分段的起始地址是什么.会添加0x10000(65536 = 64KiB)吗?

As far as I have understood, In 16-bit real mode with 20 address line enabled, we could divide the physical memory into 16 segments with 64KiB each. The first segment starts at 0x00000. What will be the starting address of next segment. Will it be by adding 0x10000 (65536 = 64KiB)?

问题2:

在这里问这个问题有点奇怪,但是仍然是我唯一的选择.假设给我一个偏移地址为0x6000的地址,如何找到该地址所属的段以解决该地址.

This question is a bit odd to ask here but still SO is my only option. Suppose if I am given with an Offset address of 0x6000, How can I find the segment to which it belongs in order to address it.

谢谢

推荐答案

...我们可以将物理内存分为16个段,每个段具有64KiB.

...we could divide the physical memory into 16 segments with 64KiB each.

是的,但更确切的说是将其表述为"16个非重叠段",因为还有可能将内存划分为65536个重叠段.

True, but more exact would be to phrase this as "16 non-overlapping segments" since there's also the possibility to divide the memory into 65536 overlapping segments.

启用A20线后,我们可以使用超过1MB的空间. (1048576 + 65536-16)将相关段寄存器设置为0xFFFF时,我们可以访问0x0FFFF0和0x10FFEF之间的存储器.

When the A20 line is enabled, we have more than 1MB to play with. (1048576+65536-16) When setting the relevant segment register to 0xFFFF, we can gain access to the memory between 0x0FFFF0 and 0x10FFEF.

这两种细分的主要特征是:

The main features of both kinds of segments are:

  1. 不重叠的细分
    • 包含65536个字节.
    • 内存中相距65536字节.
    • 这是人们经常方便地查看内存的方式.它使我们能够说我们已经把
      • A段(0xA0000-0xAFFFF)中的图形窗口
      • B段(0xB0000-0xBFFFF)中的文本视频窗口
      • F段(0xF0000-0xFFFFF)中的BIOS
  1. Non-overlapping segments
    • Contain 65536 bytes.
    • Are 65536 bytes apart in memory.
    • This is the way us people often conveniently view memory. It enables us to say that we've put
      • the graphics window in the A-segment (0xA0000-0xAFFFF)
      • the text video window in the B-segment (0xB0000-0xBFFFF)
      • the BIOS in the F-segment (0xF0000-0xFFFFF)

重叠细分

  • 包含65536个字节.
  • 在内存中相隔16个字节.

  • Contain 65536 bytes.
  • Are 16 bytes apart in memory.

有时您会看到人们将16字节的内存块称为段,但是显然这是错误的.但是,对于这样的存储量,有一个广泛使用的名称:"段落".

Sometimes you'll see people refer to a 16-byte chunk of memory as a segment but obviously this is wrong. There is however a widely used name for such an amount of memory : "paragraph".

  • 首先计算指令操作数的偏移地址.结果被截断以适合16位(64KB环绕).
  • 接下来添加了 SegmentRegister * 16
    的乘积 如果A20线处于非活动状态,则结果将被截断以适合20位(1MB环绕).
    如果A20线处于活动状态,则按原样使用结果,因此不会发生1MB的回绕.
  • First is calculated the offset address from the operands of the instruction. The result is truncated to fit in 16 bits (64KB wraparound).
  • Next is added the product of SegmentRegister * 16
    If the A20 line is inactive the result is truncated to fit in 20 bits (1MB wraparound).
    If the A20 line is active the result is used as is and thus no 1MB wraparound occurs.

假设给我一个偏移地址为0x6000,我该如何找到它所属的段以对其进行寻址.

Suppose if I am given with an Offset address of 0x6000, How can I find the segment to which it belongs in order to address it.

问题再次出在措词上!

Here again the problem lies in the phrasing!

如果用"0x6000的偏移地址"来表示像我们通常在实地址模式编程中通常使用的偏移那样的偏移,则该问题无法回答,因为在每个存在的段中都有这样的偏移0x6000

If by "an Offset address of 0x6000" you mean an offset like the one we normally use in the real address mode programming then the question cannot be answered since there is such an offset 0x6000 in every segment that exists!

如果另一方面,偏移地址0x6000"实际上是指线性地址 0x6000,那么对于段寄存器有很多解决方案:

If on the other hand the wording "an Offset address of 0x6000" actually refers to the linear address 0x6000 then there are a lot of solutions for the segment register:

segment:offset
--------------
   0000:6000
   0001:5FF0
   0002:5FE0
   0003:5FD0
   ...
   05FD:0030
   05FE:0020
   05FF:0010
   0600:0000

如您所见,有0x0601种可能的段寄存器设置可以到达线性地址0x6000.
以上适用于确实启用了A20线路的情况.如果A20处于非活动状态,则可以以精确的0x1000(4096)方式访问线性地址0x6000(就像从0到1MB-1的任何其他线性地址一样):

As you can see there are 0x0601 possible segment register settings to get to linear address 0x6000.
The above applies to when the A20 line is indeed enabled. If A20 was inactive then the linear address 0x6000 (just like any other linear address from 0 to 1MB-1) can be reached in precisely 0x1000 (4096) ways:

segment:offset
--------------
   F601:FFF0
   F602:FFE0
   F603:FFD0
   ...
   FFFD:6030
   FFFE:6020
   FFFF:6010
   0000:6000
   0001:5FF0
   0002:5FE0
   0003:5FD0
   ...
   05FD:0030
   05FE:0020
   05FF:0010
   0600:0000

这篇关于什么是细分,如何在8086模式下解决?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆