Sunday, April 23, 2017

Jack Tokenizer : Block Comments - Tougher Than You Thought

// my first program in C++
/* checking if this 
// */
// terminates a comment
// answer : yes, it does - so block comments are more powerful :)
// if I had something above after the */, it would mess things up

#include

int main()
{
  std::cout << "Hello World!";
}


Moral of the story - don't just throw away everything after the //

Saturday, April 22, 2017

Nand2Tetris : Terminal and Non-Terminal Rules

My opinion is that a separate function for each statement type is not necessary. Having worked in perl for so long, I'm sure there's an easy way to whack this out. But, being committed to py just for the sake of learning it (why?)



Sunday, April 16, 2017

Nand2Tetris : Problem with the Jack Programming Language

Programs are *very* hard to debug. There is no debugger.

Now, if they had made it easy to do debugging - tracing variables and adding breakpoints, then it would be a different story.

Saturday, April 15, 2017

Nand2Tetris Ponderables

Have you noticed that the painting of the screen is slower with the CPUemulator running assembly language code than with the VMemulator running compiled jack code?

How on earth did they do a drawCircle function with only integer support. Awesome work..

Nand2Tetris Common Issues

../../tools/JackCompiler.bat Fraction/

Compiling "C:\Users....\09\Fraction\"
Could not find file or directory: C:\Users..

Problem - the '/' provided along with directory name. Yes, lame, I know :) Shimon's response : our purpose is didactic, not production :)

while( 1 ) {

}

use while( true ) ...

Aha - API claims drawCircle can handle radius of 181... Nice try there. I just found out you have to stay below 128 (127 is ok)

In Circle.jack (line 23): In subroutine PlotCircle: Expected (

Most likely reason - you used a "do" when you meant to use "let" :) Don't you miss Perl's errors/warnings :) ?

Gotcha - you HAVE to declare ALL variables before any "action".

var int xyz;
let xyz = 0;
var int pqr;

won't fly :)

Thursday, April 13, 2017

Sunday, April 9, 2017

The Real Lesson in Nand2Tetris Part 2 Deux

Since you know how to generate machine code, what you need to be thinking about is how to disassemble machine code - that is, can you spit out vm (virtual machine) code from the machine code. Then, once you have the machine code, can you decompile it into high-level source code?

That's what the top-notch guys will be thinking about. Not me of course. I'm just a back-bencher.