Visual X-TOY Machine(普林斯顿)- 第二列的含义
Visual X-TOY Machine (Princeton) - Meaning of second column
普林斯顿大学的视觉X-TOY机器模拟器-
Download link -
Document
乘法示例:
program Multiply with stdin/stdout
// Input: integers a and b
// Output: integer c = a * b
// Remarks: inefficient
// -----------------------------------------------------------------------------
10: 8AFF read R[A]
11: 8BFF read R[B]
12: 7C00 R[C] <- 0000
13: 7101 R[1] <- 0001
14: CA18 if (R[A] == 0) goto 18 while (a != 0) {
15: 1CCB R[C] <- R[C] + R[B] c += b
16: 2AA1 R[A] <- R[A] - R[1] a--
17: C014 goto 14 }
18: 9CFF write R[C]
19: 0000 halt
第二列的含义或功能是什么(四位十六进制像CA18)?例如,我如何使用 Language Reference:
添加新行
INSTRUCTION FORMATS
| .... | .... | .... | .... |
Format 1: | op | d | s | t |
Format 2: | op | d | imm |
ARITHMETIC and LOGICAL operations
1: add R[d] <- R[s] + R[t]
2: subtract R[d] <- R[s] - R[t]
3: and R[d] <- R[s] & R[t]
4: xor R[d] <- R[s] ^ R[t]
5: shift left R[d] <- R[s] << R[t]
6: shift right R[d] <- R[s] >> R[t]
TRANSFER between registers and memory
7: load immediate R[d] <- imm
8: load R[d] <- mem[imm]
9: store mem[imm] <- R[d]
A: load indirect R[d] <- mem[R[t]]
B: store indirect mem[R[t]] <- R[d]
CONTROL
0: halt halt
C: branch zero if (R[d] == 0) pc <- imm
D: branch pos. if (R[d] > 0) pc <- imm
E: jump register pc <- R[d]
F: jump and link R[d] <- pc; pc <- imm
R[0] always reads 0.
Loads from mem[FF] come from stdin.
Stores to mem[FF] go to stdout.
我认为它指向记忆细胞。但是根据什么?我如何确定这些值?
第一眼没看出来;
根据Language Reference 例如1CCB指令表示:
| op | d | s | t |
| 1 | C | C | B |
Operation 1: add R[C] <- R[C] + R[B]
最终只有前两列可用。
第一列表示程序计数器。
第二列表示机器指令。
普林斯顿大学的视觉X-TOY机器模拟器- Download link - Document
乘法示例:
program Multiply with stdin/stdout
// Input: integers a and b
// Output: integer c = a * b
// Remarks: inefficient
// -----------------------------------------------------------------------------
10: 8AFF read R[A]
11: 8BFF read R[B]
12: 7C00 R[C] <- 0000
13: 7101 R[1] <- 0001
14: CA18 if (R[A] == 0) goto 18 while (a != 0) {
15: 1CCB R[C] <- R[C] + R[B] c += b
16: 2AA1 R[A] <- R[A] - R[1] a--
17: C014 goto 14 }
18: 9CFF write R[C]
19: 0000 halt
第二列的含义或功能是什么(四位十六进制像CA18)?例如,我如何使用 Language Reference:
添加新行INSTRUCTION FORMATS
| .... | .... | .... | .... |
Format 1: | op | d | s | t |
Format 2: | op | d | imm |
ARITHMETIC and LOGICAL operations
1: add R[d] <- R[s] + R[t]
2: subtract R[d] <- R[s] - R[t]
3: and R[d] <- R[s] & R[t]
4: xor R[d] <- R[s] ^ R[t]
5: shift left R[d] <- R[s] << R[t]
6: shift right R[d] <- R[s] >> R[t]
TRANSFER between registers and memory
7: load immediate R[d] <- imm
8: load R[d] <- mem[imm]
9: store mem[imm] <- R[d]
A: load indirect R[d] <- mem[R[t]]
B: store indirect mem[R[t]] <- R[d]
CONTROL
0: halt halt
C: branch zero if (R[d] == 0) pc <- imm
D: branch pos. if (R[d] > 0) pc <- imm
E: jump register pc <- R[d]
F: jump and link R[d] <- pc; pc <- imm
R[0] always reads 0.
Loads from mem[FF] come from stdin.
Stores to mem[FF] go to stdout.
我认为它指向记忆细胞。但是根据什么?我如何确定这些值?
第一眼没看出来;
根据Language Reference 例如1CCB指令表示:
| op | d | s | t |
| 1 | C | C | B |
Operation 1: add R[C] <- R[C] + R[B]
最终只有前两列可用。
第一列表示程序计数器。 第二列表示机器指令。