instead of IF A < 0 then A = 63 : N = N - 1 that will not work, you should use:


IF A.7 = 1 Then A = 63

When A = 0 and you sutract 1 (A = A -1), A will overflow to 255. Since your count is limited to 63, you will never use bit 7 that can be used a flag.

Al.