Unless the compiler optimizes your code, any code written in a high level language is going to be slower than a single function or procedure call for that high level language. Something like the HSEROUT function is probably written in assembly. And as Darrel points out, there are other things HSEROUT is doing that your replacement code does not.