According to the test scripts my computer.hdl is working perfectly fine but when i try to run the pong.asm file from the next chapter it fails to do so. Its working fine in the CPU emulator but even after giving it more than an 30minutes the code just keeps getting executed without the screen changing. I know i have been warned about running this on the emulator, let alone my computer.hdl file but in theory given enough time this should work right? Has anybody been successful in getting this to run on their computer.hdl? or is there something wrong with my version of the CPU.
Nothing's wrong with your Computer.hdl; you're just impatient...
Hack is not a very efficient instruction set. That wasn't one of its design goals. It takes a lot of instructions to accomplish what you see the Pong game do. I decided to profile Pong by running a .tst file that output the PC every 100 instructions for a total runtime of 10 million instructions. Here's what I found out.
3928200: 9311 memory.alloc + 668
3928300: 3961 ponggame.new + 31
First hit in Pong application
ponggame.newinstance called from main.main+15
ponggame.new called from ponggame.newinstance+11
The first sample in the Pong application occurred after 3.9 million instructions. Initializing the VM operating system took a bit over 3,928,200 instructions. The first thing the Pong game does is its own initialization. This takes another 1.1 million instructions.
5024000: 4418 ponggame.new + 488
5024100: 3859 main.main + 22
Back to main.main
After more than 5 million instructions, Pong is now ready to play the game.
At the end of 10 million instructions with no key presses, the bat has made it to the right side of the screen and the ball is about 7/8 of the way to the right. Here's the screenshot.
The HW simulator on my system runs at about 300 instructions per second, so it took at least 4.6 hours before anything appeared on the screen. I didn't wait for it to happen 8^) -- I started the test run before I left for work and it was done when I got home 12 hours later.
I ran the test with the simulator iconized, figuring that it would run faster if it didn't need to do all the screen drawing. I took the screenshot right after I restored it. I suspect this is why none of the artifacts showed up.
I see drawing artifacts in all the tools and suspect that one of the myriad Java updates since they were written has broken them. It's a shame that there is no active development occurring. I'm guessing that the grad student who wrote the tools has long since moved on.
Iconizing and restoring seems to redraw correctly.
Interesting to dig this old thread up, going through the same issues myself. The really intriguing part is that my GPU (i.e. one of those $200+ ones for modern 3D gaming) is being utilized 85% while the Hardware Simulator is working. If I minimize the Simulator applet, then it reduces to around 70%. Pretty funny that my RADEON can't handle Pong. Although it is interesting to me that the GPU is doing the calcs in addition to the CPU (which has 1 core maxed out). I don't know much about hardware (hence why I started this book, duh), but I guess these days GPU's are able to do more than just graphics!