Simpletron机器和间接寻址 [英] Simpletron machine and indirect addressing

查看:89
本文介绍了Simpletron机器和间接寻址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近进行了Simpletron任务 来自Deitel和Deitel教科书.

I recently made the Simpletron assignment from the Deitel and Deitel textbook.

Simpletron机器语言只有一种寻址模式,即直接寻址.
(也就是说,您必须在指令的操作数部分中指定要访问的地址.)

The Simpletron machine language has only one addressing mode which is direct addressing.
(That is, you have to specify the address you want to access in the operand part of the instruction.)

因此,我认为无法在运行时计算地址并对其进行访问.

So I think there is no way of computing an address at run time and access it.

所以要做这样的事情:

[pseudo-c]

int a[10];

...  

int i = 0;

while(a[i] > 100)  
{  

i++;

}  

..

需要一些自我修改的代码或扩展循环,对吗?
所以我的问题是:

would require some self modifying code or expanding the loop, am I correct?
So my question is:

教科书中介绍的Simpletron与早期计算机非常相似.

The textbook presents Simpletron as very similar to early computers.

在后续体系结构中是否引入了间接寻址模式(例如寄存器寻址)以简化编程?

Were indirect addressing modes (such as register addressing) introduced in subsequent architectures to make programming easier?

推荐答案

我认为这是正确的.但是Simpletron是如此琐碎,以至于自我修改代码仅是三个指令:

I believe that's correct. But Simpletron is so trivial that self-modifying code is only three instructions:

// address to load is in accumulator
ADD loadinstruction // construct load instruction
STORE $ + 1         // write instruction to next word of memory
...                 // placeholder filled in by write instruction
// value is in accumulator

loadinstruction: .data 2000

这是唯一可能的,因为Simpletron的程序与其数据共享内存.某些计算机体系结构无法做到这一点.例如,微控制器的PIC系列. (在RAM为8位宽而程序存储器为14位宽的情况下!)如果程序位于ROM中,也显然不能修改它.

This is only possible because Simpletron's program shares memory with its data. Some computer architectures don't do this; the PIC line of microcontrollers, for example. (Where the RAM is 8 bits wide but the program memory is 14 bits wide!) You also can't modify the program if it's in ROM, obviously enough.

我不知道这是否是开发间接寻址模式的特定原因,但这当然是一个重要的原因.

I don't know if this was the specific reason why indirect addressing modes were developed, but it's certainly an important one.

这篇关于Simpletron机器和间接寻址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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