我对使用Marie模拟器非常陌生,如果有人可以提供帮助,那就太好了。
the following program:
ORG 200
If, Load X
Subt Y
Skipcond 400
Jump Else
Then, Load Y
Store X
Jump Endif
Else, Load Y
add X
Store Y
Endif, Output
Halt
Two, Dec 2
X, Dec 10
Y, Dec 10
END
从这段代码中,这个特定部分是什么意思?如何向 Y 输入新值?另外,首次加载指令是什么意思?
Two, Dec 2
X, Dec 10
Y, Dec 10
我正在试图弄清楚这个MarieSim,如果有人能帮忙,我将不胜感激
从这段代码中,这个特定部分是什么意思?
Two, Dec 2 X, Dec 10 Y, Dec 10
它声明 3 个变量Two
、X
、Y
,并将它们的初始值分别设置为 2、10、10。Dec
表示指定的数字采用十进制(以 10 为基数(。这些变量可以在程序中的任何位置使用。
如何向 Y 输入新值?
如果要将 Y 的初始值更改为 50,只需更改此行上Dec
后的数字:
Y, Dec 50
如果要在程序执行过程中输入 Y 的值,则必须在程序开始时使用 Input
和 Store
命令:
ORG 200
Input /take user input
Store Y /store in Y
/ rest of program, including declarations, are unchanged
/ ...
另外,首次加载指令是什么意思?
Load X
表示将存储在变量 X 中的值加载到累加器中。如果 X 包含 10,则值 10 将加载到累加器。
为了将来参考,请使用官方的 MARIE 指令集:
Mnemonic | Hex | Description
-----------+-----+-----------------------------------------------
Add X | 3 | Add the contents of address X to AC
AddI X | B | Add indirect: Use the value at X as the actual
| | address of the data operand to add to AC
Clear | A | Put all zeros in AC
Input | 5 | Input a value from the keyboard into AC
Halt | 7 | Terminate program
Jump X | 9 | Load the value of X into PC
JumpI X | C | Use the value at X as the address to jump to
JnS X | 0 | Store the PC at address X and jump to X+1
Load X | 1 | Load contents of address X into AC
LoadI X | D | Load indirect: Use the value at X as the
| | address of the value to load.
Output | 6 | Output the value in AC to the display
Skipcond X | 8 | Skip next instruction on condition
| | (See note below.)
Store X | 2 | Store the contents of AC at address X
StoreI X | E | Store indirect: Use X the value at X as the
| | address of where to store the value.
Subt X | 4 | Subtract the contents of address X from AC
-----------------------------------------------------------------
Note regarding use of SKIPCOND:
The two address bits closest to the opcode field, bits 10 and
11 specify the condition to be tested. If the two address bits
are 00, this translates to "skip if the AC is negative". If the
two address bits are 01, this translates to "skip if the AC is
equal to 0". Finally, if the two address bits are 10 (or 2),
this translates to "skip if the AC is greater than 0".
Example: the instruction Skipcond 800 will skip the
instruction that follows if the AC is
greater than 0.
-----------------------------------------------------------------