Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

READ / DATA reading wrong text #18

Closed
tomxp411 opened this issue Jan 8, 2022 · 3 comments
Closed

READ / DATA reading wrong text #18

tomxp411 opened this issue Jan 8, 2022 · 3 comments

Comments

@tomxp411
Copy link

tomxp411 commented Jan 8, 2022

I am writing a program that uses READ/DATA statements to populate several arrays with code table information, and I keep getting weird results.

I finally wrote a simple test program and came up with a fairly consistent behavior: instead of correctly reading DATA statements, there first element in each DATA statement is replaced by the last statement of the program (usually WEND, in this case.)

Here is an example:

FOR I=1 TO 2
    READ A$
    PRINT A$
NEXT

DATA "HELLO", "WORLD"

WHILE INKEY$=""
  SLEEP
WEND

Output is:
WEND
WORLD

After playing with it more, it seems like the first item on a DATA line will be replaced with the last program statement. So programs with multiple lines of DATA statements will return WEND for the first data item per line, followed by the correct items on that line.

DATA a,b,c,d
DATA e,f,g,h

Would return something like
WEND
b
c
d
WEND
f
g
h

I'm currently using AQB on WinUAE with OS 3.1.4, a 68030 CPU selected, 8MB RAM, 1.5MB Slow RAM, 256MB Z3 Fast 256MB Chip RAM. I am also using the UAE Zorro III RTG module.

I'll try different CPU and memory combinations to see if there's any difference.

@tomxp411
Copy link
Author

tomxp411 commented Jan 8, 2022

Due to the pathology of this bug, this test case works as expected:

FOR I=1 TO 3
   READ A$ : PRINT A$:
NEXT

WHILE INKEY$=""
  SLEEP
WEND

DATA "World","war","iii"

So it looks like each line of data is being encoded with the first statement of the last line. So in this specific case, the first statement of the last line is actually correct ("World"). But if I move the DATA statement up above the WHILE/WEND block, The READ statements end up returning WEND war iii

It looks like this is a compiler and not a runtime issue. I used a hex editor to look at my first example (Hello world), and the data segment actually looks like this in HxD:
00 00 57 45 4E 44 00 77 6F 72 6C 64 00 00 00 00 ..WEND.world....

So the READ statement is probably working. It looks like the compiling of the DATA statement is where the problem lies.

@gooofy gooofy closed this as completed in 49104af Jan 8, 2022
@gooofy
Copy link
Owner

gooofy commented Jan 8, 2022

thanks for your detailed bug report and nice catch! should be fixed now.

I have uploaded a new preview release here that should contain all current fixes (I have more bug reports to go through plus I'd like to get the new UISupport module into a somewhat useable state so it could be a couple of days until the official 0.8.2 release comes out):

http://goofy.zamia.org/aqb-0.8.2preview2.lha

@tomxp411
Copy link
Author

tomxp411 commented Jan 9, 2022

Thanks. This appears to be fixed.

I just want to give a 👍 for how quickly you're hitting these. I'm impressed. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants