Assembly 绝对物理存储器参考

Assembly 绝对物理存储器参考,assembly,att,osdev,Assembly,Att,Osdev,考虑一个使用绝对物理内存引用的程序 movl ($0x100), %eax movl ($0x104), %ebx movl %eax, ($0x104) movl %ebx, ($0x100) 此程序在地址0x0加载时工作正常,但在地址0x1000加载时工作不正常。为什么不呢 重写上述代码,使程序在加载到内存地址0x1000时工作。这个答案在操作系统设计的上下文中,这本书可能会教授。在第3章中,我们将学习不同的体系结构设计,以及操作系统如何处理诸如在没

考虑一个使用绝对物理内存引用的程序

movl    ($0x100), %eax
movl    ($0x104), %ebx
movl    %eax,     ($0x104)
movl    %ebx,     ($0x100)
此程序在地址0x0加载时工作正常,但在地址0x1000加载时工作不正常。为什么不呢


重写上述代码,使程序在加载到内存地址0x1000时工作。

这个答案在操作系统设计的上下文中,这本书可能会教授。在第3章中,我们将学习不同的体系结构设计,以及操作系统如何处理诸如在没有内存抽象的情况下运行多个程序之类的问题。一种这样的机制是对内存进行分区,每个程序都在该分区内运行。例如,每个程序都加载在4kb边界上(0x0000、0x1000、0x2000)

我认为这个问题就是在这种情况下提出的

此程序在地址0x0加载时工作正常,但在地址0x1000加载时工作不正常。为什么不呢`

原因可能是提供的指令试图从内存地址(0x100和0x104)加载和存储。如果这些指令从0x1000开始加载,然后执行,则它们可能会干扰从0x0000加载到0x1000的程序。为了解决这个问题,一个简单的操作系统设计可以有一个程序加载器,静态地重新定位所有绝对内存引用,使它们相对于正在加载的内存分区的基址。在本例中,基数为0x1000,因此将添加到0x0100和0x0104中。生成的程序如下所示:

movl    ($0x1100), %eax
movl    ($0x1104), %ebx
movl    %eax,     ($0x1104)
movl    %ebx,     ($0x1100)
上面的语法似乎是针对一种虚构的(或教育性的)汇编语言(基于x86 AT&T语法),其中
($0x#####)
从绝对物理内存地址进行加载/存储


我上面的回答是基于这样的观察得出的,即这是一个标记为操作系统的位置,特别是0x1000和绝对内存引用的概念。这本身就让我假设(对或错),在一台不使用内存抽象(如分页和分段)的机器的上下文中,这可能是一个内存分区问题

我发现老年退休金问题似乎是课程的一部分。我注意到这个问题被更全面地提出为:

[剪报]

报告说,现代操作系统(第4版是最新版本)正在用于本课程,最近有一项作业到期。教学大纲还建议该练习室(练习)与本书第3章相关


考虑到这一点,我相信我上面给出的答案可能是一个合理的答案,因为这本书的第三章以及练习中提出的问题。

movl($0x1000),%eax movl($0x1004),%ebx movl%eax,($0x1004)movl%ebx,($0x1000)您可以编辑您的问题。编辑链接在标签下面这是一个家庭作业问题吗?如果是这样,请在你的问题中指出这一点,并说明你已经做了哪些工作来解决它。@PeterCordes:我已经回滚了你的更改(我很少这样做,而且从来没有对你做过)。你可能因为OP的第一条评论而做出了改变。我不相信他的第一条评论是为了改变问题中的实际代码,而是为了尝试解决它。如果我们了解上下文,这个问题实际上很有意义。多年来,我做过操作系统和编译器编写教程,以前也见过这种问题。问题是问题本身没有上下文来回答问题,但我相信发布的原始代码是正确的。@MichaelPetch:谢谢,这种解释也很有意义,并且使问题不那么琐碎。同意回滚;重新申请我的否决票,因为这是一个糟糕/不完整的问题,而不是一个微不足道的问题。
The earliest memory systems managed physical memory directly, and typically 
the operating system could do very little to make programming easier.

In this studio, you will:

Consider statically partitioned physical memory
Consider dynamically partitioned memory with base and limit registers
Explore the limitations of physical memory based methods 
2. Consider a program that uses absolute physical memory references meaning that each 
reference refers to a specific physical memory location. One part of such a program 
is below:
    movl  ($0x100),   %eax
    movl  ($0x104),   %ebx
    movl  %eax,       ($0x104)
    movl  %ebx,       ($0x100)

This program works fine when it is loaded at address 0x0, but not when it is
loaded at address 0x1000. Why not?

3. Re-write the above code so the program works when it is loaded at memory
   address 0x1000.
4. Suppose you have a machine with four static parititons, each capable of holding a
   program with a length of 4096 bytes (0x1000 bytes). The first partition starts
   at address 0x0. Give the first and last address of each of the four partitions.
5. Suppose the first of the four programs executes the following line of code,
   with the operand located at byte 0x25, and the destination address located
   at bytes 0x26-0x2A:
       0x25:  jmp ($0x50)

   Suppose also another program executes the following line first.
       movl $0x1234,  ($0x26)

   What happens to the first progam upon executing the instruction at address 0x25?
Oct 16    Memory management           MOS 3.1 Studio 15-a 
Oct 18    Address spaces and swapping MOS 3.2 Studio 15-b