简体   繁体   English

汇编:段寄存器和偏移寄存器

[英]Assembly: Segment register & offset register

I'm having a little trouble understanding where the 10H value is coming from? 我在理解10H值来自何处时遇到了一些麻烦? The example says that ds=1275H (?segment reg.) And bx:457H (?offset) why is ds being multiplied by 10H. 例子说ds = 1275H(?segment reg。)和bx:457H(?offset)为什么ds乘以10H。 And do they mean 1275 is the hex value(so dec. value is 4725)? 他们的意思是1275是十六进制值(所以dec。值是4725)? 来自“计算机病毒小书”的精确文本

The segment register points to a 16 byte block of memory... 段寄存器指向一个16字节的内存块......

This is where the confusion starts. 这就是混乱开始的地方。 The segment register points to a 65536 byte block of memory and the offset register tells how many bytes to add to the start of this 65536 byte block. 段寄存器指向65536字节的存储器块,偏移寄存器指示要添加到该65536字节块的起始位置的字节数。 Adding a word offset to the start of a 16 byte block would make no sense! 在16字节块的开头添加字偏移是没有意义的!

These 64KB blocks are heavily overlapped in memory. 这些64KB块在内存中重叠很多。 Their start addresses only differ by a mere 16 bytes! 它们的起始地址仅相差16个字节! You could look at these 64KB blocks as forming an array and what the segment register contains then is a zero based index to its elements. 您可以将这些64KB块视为形成数组,然后段寄存器包含的是其元素的基于零的索引。

It's thus the spacing between these blocks that is the true meaning of the 10H that you're asking about. 因此,这些块之间的间距是您所询问的10H的真正含义。

To get to the linear (real) address of the memory location, we need to multiply the value in the segment register with 16 (this is represented as 10h in hexadecimal notation) and then add the offset to it. 为了得到存储器位置的线性(实际)地址,我们需要将段寄存器中的值乘以16(用十六进制表示法表示为10h),然后将偏移量加到它上面。

The key words here are "the segment register points to a 16 byte block of memory". 这里的关键词是“段寄存器指向16字节的存储器块”。 If you arrange the whole memory in 16-byte blocks, a segment register (for example DS) would contain the number of the block. 如果将整个存储器排列为16字节块,则段寄存器(例如DS)将包含块的编号。

To get from the value of the segment register to the linear address, you have to multiply by 16, which is the same as hex number 10, which is usually written as 10H. 要从段寄存器的值到线性地址,必须乘以16,这与十六进制数10相同,后者通常写为10H。

After calculating the segment's starting address, add the offset register. 计算段的起始地址后,添加偏移寄存器。

Yes, 1275H is a hex number, that's what the "H" denotes. 是的,1275H是十六进制数,就是“H”表示的数字。 It corresponds to 4725 decimal. 它对应于4725十进制数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM