mov cx, 0ffffh

loop short @b

This code is not working properly.

What is the reason

Before looping, loop instruction decrements contains of cx and jumps to @b: (assuming this label) if contains of cx != 0.

Unfortunately, your mov cx, 0ffffh fills cx with bit pattern 1111 1111 1111 1111B what is decimal -1 (2's complement).

Therfore -1 -1 makes -2 etc, what is !=0. Your loop ends only if 0 appears in cx, and that is not until after 65535 cycles what is in almost most cases not the action desired.

Btw the greatest positive value one can store in a 16 bit register is 7FFFH.

- tesu