Thanks, I tried out the code but it doesn't address the speed issue... it runs about the same speed.
I do appreciate the suggestions for writing better code.
For whatever reason yy isn't initializing properly the way you have it set up... if I set a breakpoint on the very first line, yy is always some random large number. It seems like the code is ignoring the value that was set. I tried changing yy to yyy, same problem. If I hardcode yyy := 0; on the line before the breakpoint, then the value is set properly. I don't understand why it is ignoring the value being set in the var section.