0
普林斯頓大學的視覺X-TOY機Simulator- Download link - Document視覺X-TOY機(普林斯頓) - 這意味着第二列的
乘例如:
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)?例如,如何添加這個語言參考新行:
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.
我認爲它的指向的存儲單元。但根據什麼?我如何確定這些值?