我真的很难过这个问题,有人可以帮我这个吗? ITEC [英] I'm really stumped on this question can someone help me with this? ITEC

查看:101
本文介绍了我真的很难过这个问题,有人可以帮我这个吗? ITEC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设在LMC内存中加载了以下程序:

Suppose that the following program is loaded in the LMC memory:

Memory address	Instruction	Address
00              Input           01
01              Store	        20
02              Input	        01
03              Store	        21
04              Input	        01
05              Store	        22
06              Subtract        21
07              Branch Positive	10
08              Load	        21
09              Branch	        11
10              Load	        22
11              Subtract        20
12              Output	        02
13              Halt	        00







假设程序提供以下十进制数:23,20和15(按此顺序)。十进制输出是什么?如果提供数字15,18和32(按此顺序)将输出什么?




Suppose that the program is supplied with the following decimal numbers: 23 , 20 and 15 (in this order). What will be the output in decimal? And what will be the output if the numbers 15, 18 and 32 are supplied (in this order)?

推荐答案

确定 - 只需通过工作

Fist指令输入一个数字 - 你被告知数字将是23.所以我们的处理器累加器的值为23

下一条指令将数字存储在累加器(23)中记忆位置20 - 所以,把它写在一张纸上......

OK - just work it through
Fist instruction inputs a number - you're told that number is going to be 23. So our processor's accumulator has a value of 23
Next instruction stores the number in the accumulator (23) in memory location 20 - so, write that on a bit of paper...
A            23
20           23


下一条指令输入一个数字

接下来存储位置21(你被告知这个数字是20,所以把它写在你的纸上


Next instruction inputs a number
Next stores that in location 21 (you're told the number will be 20, so write that down on your bit of paper

A            20
20           23
21           20



下一条指令获得另一个数字

下一条指令存储在22

你需要记下哪些(你被告知这个数字是15)


Next instruction gets another number
Next instruction stores that in 22
Which you need to write down (you're told the number is 15)

A             15
20            23
21            20
22            15



现在你减去21的内容 - 这是唯一棘手的一点 - 你从中减去21的值累加器 - 即输入数字的处理器内存 - 在我们的例子中是值15(我们知道因为我们写下来了!)



所以 - 15 - (内存位置21的值)

这是15 - 20

这是-5


Now you subtract the contents of 21 - here's the only tricky bit - you are subtracting 21 from the value in the Accumulator - i.e. the processor memory into which the number was input - which in our case is the value 15 (we know because we wrote it down!)

So - 15 - (the value at memory location 21)
which is 15 - 20
which is -5

A             -5
20            23
21            20
22            15









下一条指令说,如果结果是积极的去内存位置10 - 但事实并非如此我们只是继续...

下一条指令说将值加载到21 - 仍然是20(我们从未存储过减法的结果)







Next instruction says that, if the result is positive to go to memory location 10 - but it is not so we just carry on...
Next instruction says load the value at 21 - which is still 20 (we never stored the result of the subtraction)

A             20
20            23
21            20
22            15





N ext指令是11的无条件分支 - 所以我们分支到11处的指令(减去20)

该指令从累加器中的值中减去20的内容(当前为23)目前是20)

20 - 23 = -3





Next instruction is an unconditional branch to 11 - so we branch to the instruction at 11 (subtract 20)
This instruction subtracts the contents of 20 (which is currently 23) from the value in the accumulator (which is currently 20)
20 - 23 = -3

A             -3
20            23
21            20
22            15





现在输出指令令人费解 - 但我认为它只是输出累加器中的值 - 在这种情况下我们将输出-3



希望你可以跟随你给出的其他值。



(借口格式化问题 - 网站反应不灵活,所以我看不出它会是什么样子!)



Now the output instruction is puzzling - but I assume it just outputs the value in the accumulator somewhere - in which case we will output -3

Hopefully you can follow along with the other values you have been given.

(Excuse formatting problems - the web site isn't being very responsive so I can't see what it will look like!)


这篇关于我真的很难过这个问题,有人可以帮我这个吗? ITEC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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