How efficient is your Push and Pop?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How efficient is your Push and Pop?

sakumar
This post was updated on .
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 be tweaked.
Reply | Threaded
Open this post in threaded view
|

Re: How efficient is your Push and Pop?

cadet1620
Administrator
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
Reply | Threaded
Open this post in threaded view
|

Re: How efficient is your Push and Pop?

sakumar
Mark, thanks for the link. You are right -- I should probably get it functionally correct before focusing on optimization.