sakumar wrote
I am able to do Push in 6 asm/hack instructions and Pop in 5 asm/hack instructions. I was wondering if it is possible to do better. Obviously, correctness trumps efficiency but the memory-to-memory and multiple-destination operations make some optimizations possible so I am curious as to how far that can we tweaked.
Those are good implementations. More complex segment accesses are, of course, longer. My "push D" primitive is 4 instructions, so add whatever it takes to get the value into the D register. My "pop into D" primitive is 3, but once the data's there it need to be stored somewhere...
There are some threads where we've been discussing code generation optimization. Here's a
good one if you are interested.
I'd suggest that you finish project 8 before you worry much about optimization.
--Mark