Fix command symbols
This commit is contained in:
parent
4e49913808
commit
91dd0bb102
24
README.md
24
README.md
|
@ -94,7 +94,6 @@ Counting number of instructions by `wc -l $file.hack`
|
|||
|
||||
Final hack instruction set count in brackets. Calculated by running:
|
||||
|
||||
|
||||
```
|
||||
php file.vm > file.asm
|
||||
ruby assembler.rb file.vm > file.hack
|
||||
|
@ -103,11 +102,24 @@ wc -l file.hack
|
|||
|
||||
### Arithmetic Commands
|
||||
|
||||
- [x] SimpleAdd.vm (21)
|
||||
- [x] StackTest.vm (334)
|
||||
- [x] `SimpleAdd.vm` (21)
|
||||
- [x] `StackTest.vm` (334)
|
||||
|
||||
### Memory Access Commands
|
||||
|
||||
- [x] BasicTest.vm (228)
|
||||
- [x] PointerTest.vm (127)
|
||||
- [ ] StackTest.vm
|
||||
- [x] `BasicTest.vm` (228)
|
||||
- [x] `PointerTest.vm` (127)
|
||||
- [x] `StackTest.vm` (73)
|
||||
|
||||
## [Project 7: Virtual Machine II - Program Control](https://www.nand2tetris.org/project07)
|
||||
|
||||
### Program Flow Commands
|
||||
|
||||
- [ ] `BasicLoop.vm`
|
||||
- [ ] `Fibonacci.vm`
|
||||
|
||||
## Function Calling Commands
|
||||
|
||||
- [ ] `SimpleFunction.vm`
|
||||
- [ ] `FibonacciElement.vm`
|
||||
- [ ] `StaticsTest.vm`
|
||||
|
|
|
@ -29,7 +29,7 @@ class CodeWriter {
|
|||
]);
|
||||
}
|
||||
|
||||
function writeArithmetic(String $command ) {
|
||||
function writeArithmetic(String $command) {
|
||||
$stackDecrease=true;
|
||||
// Read top of stack to D
|
||||
$this->write([
|
||||
|
|
|
@ -3,16 +3,18 @@
|
|||
namespace captn3m0\NandToTetris;
|
||||
|
||||
class CommandType {
|
||||
const CALL = 0;
|
||||
const PUSH = 1;
|
||||
const POP = 2;
|
||||
// Program Flow Commands
|
||||
const LABEL= 3;
|
||||
const GOTO= 4;
|
||||
const IF= 5;
|
||||
// Function Calling Commands
|
||||
const FUNC= 6;
|
||||
const RETURN= 7;
|
||||
const ARITHMETIC= 8;
|
||||
const CALL = 0;
|
||||
|
||||
const ARITHMETIC= 8;
|
||||
const ARITHMETIC_COMMANDS = ['add', 'sub', 'neg', 'eq', 'gt', 'lt', 'and', 'or', 'not'];
|
||||
|
||||
public static function fromName(String $name) {
|
||||
|
@ -25,8 +27,8 @@ class CommandType {
|
|||
"pop",
|
||||
"label",
|
||||
"goto",
|
||||
"if",
|
||||
"func",
|
||||
"if-goto",
|
||||
"function",
|
||||
"return"
|
||||
];
|
||||
return array_search($name, $map);
|
||||
|
|
|
@ -58,7 +58,6 @@ class VMTranslator {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if(isset($argv[1])) {
|
||||
$vmt = new VMTranslator($argv[1]);
|
||||
$vmt->translate();
|
||||
|
|
Loading…
Reference in New Issue