间接寻址模式(Indirect Addressing Mode)
我目前正在尝试解决我给出这些标准的问题:
我相信我的答案是正确的,但我很困惑,因为问题没有提到地址存储在地址10,所以间接寻址怎么可能发生呢?
问题 :给定以下寻址模式的相应操作数在哪里?
假设指令的地址字段包含小数10.对应的操作数在哪里给出以下寻址模式?
- 立即寻址:操作数-10
- 直接寻址:操作数 - 10 - >地址
- 间接寻址:10 - >地址 - >地址
- 注册寻址:
- 注册间接寻址:
有人可以帮帮我吗?
这是我正在使用的图表:
更新的地方:
立即寻址:相应的操作数位于给定存储器的地址字段中。 在所有情况下,操作数只是给定内存位置的地址字段中的值。 因此,在这种情况下,操作数值将为10。
直接寻址:在直接寻址中,地址字段包含操作数的地址。 因此,相应的操作数将是存储器地址10处的操作数所存储的任何操作数。
间接寻址:在间接寻址中,存储器地址10的内容是操作数的地址。 因此,位置10的地址字段包含在其地址字段中保存操作数的位置的地址。
寄存器寻址:在寄存器寻址中,存储器位置10的地址字段保持寄存器的地址而不是另一个存储器地址。 相应的操作数位于寄存器的内容中。
寄存器间接寻址:寄存器间接寻址与寄存器寻址非常相似,因为存储器位置10也将地址保存到包含其操作数的位置; 区别在于地址可以是寄存器或存储器位置。
I am currently trying to solve a problem where I am given these criteria:
I believe that I have some of the answers correct but I am confused because the question mentions nothing about an address being stored at address 10 so how can indirect addressing even happen?
Question: Where is the corresponding operand given the following addressing modes?
Assume the address field of an instruction contains the decimal 10. Where is the corresponding operand given the following addressing modes?
- Immediate addressing: Operand- 10
- Direct addressing: Operand - 10 -> address
- Indirect addressing: 10 -> address -> address
- Register addressing:
- Register indirect addressing:
Can anybody help me out?
Here's the chart I'm using:
Updated where's:
Immediate addressing: The corresponding operand is located in the address field of the given memory. In all cases the operand is simply the value in the address field of the given memory location. So in this case the operand value would be 10.
Direct addressing: In direct addressing the address field contains the address of the operand. Therefore the corresponding operand is going to be whatever is stored for an operand at memory address 10.
Indirect addressing: In indirect addressing the contents of memory address 10 are the address to the operand. Therefore the address field of location 10 contains the address to the location holding the operand in its address field.
Register addressing: In register addressing the address field of memory location 10 holds an address to a register instead of another memory address. The corresponding operand is found inside the contents of the register.
Register indirect addressing: Register indirect addressing is very similar to register addressing because memory location 10 also holds an address to a location containing its operand, however; the difference is that the address could be to a register or to a memory location.
原文:https://stackoverflow.com/questions/29958883
最满意答案
原则上,没有必要做这样的事情。 如果要关联两个连续的行,只需将分析调整为此事实(在读取第2行时执行第1行操作)。 示例代码:
using (System.IO.StreamReader sr = new System.IO.StreamReader("path")) { string line = null; string prevLine = null; while ((line = sr.ReadLine()) != null) { if (prevLine != null) { //perform all the actions you wish with the previous line now } prevLine = line; } }
这可能适用于处理所需的行数(前一行的集合而不仅仅是
prevLine
)。In principle, there is no need to do such a thing. If you want to relate two consecutive lines, just adapt the analysis to this fact (perform the line 1 actions while reading line 2). Sample code:
using (System.IO.StreamReader sr = new System.IO.StreamReader("path")) { string line = null; string prevLine = null; while ((line = sr.ReadLine()) != null) { if (prevLine != null) { //perform all the actions you wish with the previous line now } prevLine = line; } }
This might be adapted to deal with as many lines as required (a collection of previous lines instead of just
prevLine
).
相关问答
更多-
如何移动拥有的指针(How to move an owned pointer)[2023-11-25]
无论是从自我分配(我认为包括构建一个新事物,如Link(item, *self) 意味着一个移动 ,这意味着在构建新Link的过程中,自我变得不可用,因为: “一个值被移动后,它不能再从源位置使用,并且不会在那里被销毁。” 正确的方式™可能是最好的记录stdlib在这个例子中做了什么。 这是一个双向链接列表,它是托管的,但它是可变的,我希望免费拷贝。 还有一些有用的容器类型 。 然而,我确实设法让你的数据结构的这个不变版本起作用。 trait Stack{ fn push(self, ite ... -
如何将HEAD移回以前的位置?(How to move HEAD back to a previous location? (Detached head) & Undo commits)[2023-12-11]
在回答之前,请添加一些背景,解释这是什么头。 First of all what is HEAD? HEAD只是对当前分支的当前提交(最新)的引用。 在任何给定时间只能有一个HEAD 。 (不包括git worktree ) HEAD的内容存储在.git/HEAD ,它包含当前提交的40字节SHA-1。 detached HEAD 如果你不是最新的提交 - 这意味着HEAD指向历史上的一个先前的承诺,它被称为detached HEAD 。 在命令行上,它将看起来像这样SHA-1而不是分支名称,因为HEAD没 ... -
使用fgets(a,5,fp1)之后,文件指针是否向前移动了5个位置? 指针fp1不受fgets调用(或任何其他stdio I / O例程)的影响; 将更新fp1指向的FILE对象以反映新文件位置,但指针本身不会更改。 after using fgets(a,5,fp1) does the file pointer move 5 positions ahead ? The pointer fp1 is not affected by the fgets call (or any other stdio I/ ...
-
git如何移回提交(git how to move back commit)[2023-09-29]
git checkout b9c157d由sha开始的提交,并以b9c157d - 您提到的提交。 git checkout b9c157d checks out the commit represented by the sha starting with b9c157d -- the commit you asked about. -
指向python中的指针(pointer to pointer in python)[2023-10-19]
编辑:添加l == l[::-1]为is_palindrome5 ,这是非常快,到目前为止最可读和pythonic。 我可以检查回收的最快速度是这个单线程: def is_palindrome1(l): return l[:len(l) / 2] == l[(len(l)+1) / 2:][::-1] 在您的问题中对c ++函数的python转换检查非回文是最快的: def is_palindrome2(l): left = 0 right = len(l) - 1 ... -
我找到了解决方案。 我只是在后台调用finish() @Override public void onBackPressed(){ finish(); } 这解决了我的问题。 finish()调用包含片段的活动 I found the solution. I just called finish() on backpress @Override public void onBackPressed(){ finish(); } And this solved my issue. The ...
-
原则上,没有必要做这样的事情。 如果要关联两个连续的行,只需将分析调整为此事实(在读取第2行时执行第1行操作)。 示例代码: using (System.IO.StreamReader sr = new System.IO.StreamReader("path")) { string line = null; string prevLine = null; while ((line = sr.ReadLine()) != null) { if (prevLin ...
-
难道你不能摆脱stage.setChildIndex(this, 0)并添加这样的图像? var image = new Main(); stage.addChildAt(image, 0); Can't you just get rid of the stage.setChildIndex(this, 0) and add image like this? var image = new Main(); stage.addChildAt(image, 0);
-
我很确定VB6提供了seek()函数来完成这项工作。 否则,如果文件相对较小,您可以将其全部读入内存并使用split()函数将其分隔为行。 然后可以随意访问这些。 显然,如果文件很大,这不是一个好主意。 FSO只允许您向前阅读。 I'm pretty sure VB6 provides a seek() function to do this. Otherwise, if the file is relatively small you could read it all into memory and u ...
-
为什么readline()将文件指针放在Python的文件末尾?(Why does readline() put the file pointer at the end of the file in Python?)[2022-03-22]
默认情况下,写入始终发生在文件的末尾。 调用file.readline()不会改变这种行为,尤其是因为readline()调用可以使用缓冲区来读取较大的块。 你可以通过显式使用file.seek()来覆盖一行的末尾; 你只是读了一行,你知道的长度,寻求这一点: x = file.readline() file.seek(len(x), 0) file.write(text) #write the text 请注意,您不能插入直线,也不能轻松更换直线。 文件是单个字节的流,而不是行,因此如果您以10个字符( ...