Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Variable corruption?
#1
Code:
SUB FZXPrintAt(Y as uByte, X as uByte, printData as String)
DIM FZXi as uInteger=0
PRINT INK 0;FZXi: PAUSE 0
FZXPrintAChar(22) 'at
PRINT INK 1;FZXi: PAUSE 0

FZXPrintAChar(Y)
PRINT INK 2;FZXi: PAUSE 0

FZXPrintAChar(X)
PRINT INK 3;FZXi: PAUSE 0

PRINT LEN printData
FOR FZXi=0 to LEN printData-1
PRINT INK 4;FZXi: PAUSE 0
   FZXPrintAChar(CODE printData(FZXi))
PRINT INK 5;FZXi: PAUSE 0
NEXT FZXi  
END SUB

The first 3 calls to FZXPrintAChar work perfectly. Then we get to the loop part. It prints out 0 for FZXi and then prints the first letter of the string. Next time around the loop, FZXi becomes 33633!
But I'm not sure where?

Should I assume FZXPrintAChar does some stack corruption? This is just FZX from Einar Saukas (and friends) - and seems to work perfectly when called to print a single character. Even multiple times. But when looping, strange things happen.

The odd thing is it just seems to happen once. If I change the code to FZXPrintAChar(65) - it happily prints out letter A's in sequence beautifully. Except the first time through the loop, FZXi is set to 33633. It then proceeds to count upwards through 33634 33635 etc, as you'd expect for a loop variable.

Investigating as I type:
If I set the variable type to be a uByte, it gets set to 131 in the loop. (Which makes some sense, as the high byte of 33633 is 131 ) - but it isn't reset each time to 131, but is allowed to count upwards.

2 AM.

Time to quit for the night. Code dumped to <deleted> for the moment. - I fully accept the issue might be with the assembly module from someone else I've used!

EDIT: I think I see it. It's using IX in the routine. That will have to be changed!
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)