I'm surprised it works under XP.
Direct hardware access, like you're program is doing, is something that windows is trying to stop. Each time your program wants to talk to hardware, it has to "ask" the O/S if it's ok. If the O/S is doing something else, say, checking your hard drive for illegal software, or phoning home, or sending spam, it can delay your program from having access to the hardware.
Vista is doing more background tasks than XP apparently.
You could:
a) turn off services that vista is running so that your program runs smoother.
b) try calling the "delay" routine less often, or with a smaller delay
c) change your delay routine to use a time based service instead of more direct hardware access.
d) try your program inside DOSBox, which can help with older 16bit programs that do direct hardware accesses.