DATA statement not accepted, ROM bug ??

Hello
I have a problem with entering a simple DATA statement
i want to optimize in size
10 DATA CHR$ 22 + CHR$ 0 + CHR$ 0

but those WONT be accepted by the syntax check !!

10 DATA CHR$ VAL"22"+ CHR$ NOT PI + CHR$ NOT PI
10 DATA CHR$ VAL"22"+ CHR$ NOT PI + CHR$ 0
10 DATA CHR$ VAL"22"+ CHR$ NOT PI + CHR$ VAL"0"
10 DATA CHR$ VAL"22"+ CHR$ NOT PI + CHR$ n

while these ARE accepted
10 DATA CHR$ VAL"22"+ CHR$ NOT PI
10 DATA CHR$ VAL"22"+ CHR$ 0 + CHR$ NOT PI
10 DATA CHR$ VAL"22"+ CHR$ VAL"0" + CHR$ NOT PI
10 DATA CHR$ VAL"22"+ CHR$ n + CHR$ NOT PI


i checked in both fuse(157) and RVMv2-beta
is it a known bug?
my old website http://home.hccnet.nl/c.born/ has changed to http://www.cborn.nl/zxfiles/ so just click it and select a file

Comments

  • edited June 26
    I created a .tap file using zmakebas with these and macOS Fuse v1.5.6 accepted and ran them no problem

    I then manually typed in the first of your lines that were not accepted and it indeed was not accepted.

    So I can verify your issue is possibly a ROM bug and suggest you use zmakebas (or similar) as a workaround.

    I also found that

    10 DATA CHR$ VAL"22"+ CHR$ (NOT PI) + CHR$ (NOT PI)
    
    is accepted so maybe that is a workaround and it's a problem with the NOT keyword grabbing all the keywords after it.

    Regards,
    Derek.
    Post edited by dbolli on
    1985: ZX Spectrum+ 48K Interface 1 ZX81 16KB ASZMIC/SP ROM Philips 12" B/W TV Epson Dot Matrix Printer ZX Printer Now: Late 2015 iMac 5K 27" 4GHz i7 32GB RAM macOS 10.15.6 beta 2 1TB Ext SSD USB C Drive Ext 4TB 3TB and 2TB USB 3 Hard Disks Ext USB 3 Blu-Ray iPad R7 32GB iPhone 6s 64GB iOS 13.5.1 Apple TV Gen 2
  • edited June 26
    dbolli wrote: »
    (..)
    I also found that
    10 DATA CHR$ VAL"22"+ CHR$ (NOT PI) + CHR$ (NOT PI)
    
    Regards,
    Derek.

    Thank you!
    i did not concider (NOT PI), thats a good one.
    I made my own work around with N since i use NOT PI quite often. AND i did not yet use N so
    10 DATA NOT PI, CHR$ VAL"22"+ CHR$ n + CHR$ n
    20 READ n,a$
    30 PRINT #0;a$;n

    thanks for testing!!
    Post edited by Crisis on
    my old website http://home.hccnet.nl/c.born/ has changed to http://www.cborn.nl/zxfiles/ so just click it and select a file
  • If you look at the table of priorities on page 155 of the 48k manual you should see why the ROM is right and emulators which accept the second group of expressions are wrong.

    In all four cases you are asking it to evaluate NOT (PI + a character value), which plainly requires the response of a flashing '?'
  • If you look at the table of priorities on page 155 of the 48k manual you should see why the ROM is right and emulators which accept the second group of expressions are wrong.

    In all four cases you are asking it to evaluate NOT (PI + a character value), which plainly requires the response of a flashing '?'

    Hi BB
    does that mean that
    while these ARE accepted
    10 DATA CHR$ VAL"22"+ CHR$ NOT PI
    10 DATA CHR$ VAL"22"+ CHR$ 0 + CHR$ NOT PI
    10 DATA CHR$ VAL"22"+ CHR$ VAL"0" + CHR$ NOT PI
    10 DATA CHR$ VAL"22"+ CHR$ n + CHR$ NOT PI
    
    are wrongly accepted anyway? so it wont run on a real ZX?

    my old website http://home.hccnet.nl/c.born/ has changed to http://www.cborn.nl/zxfiles/ so just click it and select a file
  • In all four cases you are asking it to evaluate NOT (PI + a character value), which plainly requires the response of a flashing '?'

    That's what I thought but interestingly

    100 PRINT PI + CHR$ 0
    110 PRINT PI + CHR$ NOT PI
    120 PRINT NOT PI + CHR$ 0
    130 PRINT NOT PI + CHR$ NOT PI
    
    all work when in a .tap created with zmakebas or similar

    So it's interesting what works when you sneak it past the syntax checker :)

    Regards,
    Derek.

    1985: ZX Spectrum+ 48K Interface 1 ZX81 16KB ASZMIC/SP ROM Philips 12" B/W TV Epson Dot Matrix Printer ZX Printer Now: Late 2015 iMac 5K 27" 4GHz i7 32GB RAM macOS 10.15.6 beta 2 1TB Ext SSD USB C Drive Ext 4TB 3TB and 2TB USB 3 Hard Disks Ext USB 3 Blu-Ray iPad R7 32GB iPhone 6s 64GB iOS 13.5.1 Apple TV Gen 2
  • edited June 26
    On a real Spectrum, the first line and the last four lines work, lines 2,3,4,5 don't work, due to the order of evaluation of the various elements, determined by their respective priorities as previously explained.
    Those lines can be made to work by using '()' to change the precedence of evaluation; eg.
    10 DATA CHR$ VAL"22"+ CHR$ (NOT PI) + CHR$ (NOT PI)
    but that rather defeats the original intent of saving space.
    Post edited by Battle Bunny on
  • edited June 28
    dbolli wrote: »
    100 PRINT PI + CHR$ 0
    110 PRINT PI + CHR$ NOT PI
    120 PRINT NOT PI + CHR$ 0
    130 PRINT NOT PI + CHR$ NOT PI
    
    all work when in a .tap created with zmakebas or similar

    So it's interesting what works when you sneak it past the syntax checker :)

    Regards,
    Derek.
    But all those don’t make any sense, the result of PI is a number: 3.1415 etc, but the result of CHR$ is a character.
    If you try
    PRINT CHR$ 65
    The computer will print the letter A

    It’s not valid to add a number to a character!

    So what happens if you do shoehorn your program past the syntax checker and run the program? What does it actually print?

    Me thinks too many Wossers have been in lockdown for too long!

    Mark
    Post edited by 1024MAK on
  • edited June 28
    1024MAK wrote: »
    But all those don’t make any sense, the result of PI is a number: 3.1415 etc, but the result of CHR$ is a character.
    If you try
    PRINT CHR$ 65
    The computer will print the letter A

    It’s not valid to add a number to a character!

    Mark

    Well, then don't do a CHR$ 65 , since thats the number of the chr$ and in my case its CHR$ 0 by the NOT statement. but further, it has not much use to jump over the syntax checker for a normal basic line.
    so if
    10 DATA CHR$ VAL"22"+ CHR$ NOT PI + CHR$ 0
    is true or false
    then why is
    10 DATA CHR$ VAL"22" + CHR$ 0+ CHR$ NOT PI
    NOT the same true or false ???
    which points to that syntax checker, hence my question about bigs and Battle Bunny's answer about page 155 from a book i appear not to have in my directory colmn. In fact i cant find it in wos, archive.org nor spectrumcomputing, a real pitty. I found the +2 version of armstrad but that page 155 is the ascii list.
    the 2017_mirror file apears to have quite some ZERO byte files an board. just a title aint enough......

    search
    "zx spectrum manual"

    https://archive.org/details/sinclair-zx-spectrum

    https://spectrumcomputing.co.uk/entry.php?id=2001344
    alll EMPTY
    https://spectrumcomputing.co.uk/entry.php?id=2000438

    https://archive.org/download/World_of_Spectrum_June_2017_Mirror/World of Spectrum June 2017 Mirror.zip/World of Spectrum June 2017 Mirror/sinclair/books/z/ZXSpectrum+2Manual.pdf

    https://worldofspectrum.org/infoseek?q=zx+spectrum+manual&filter[]=books


    edit, this one: but the page is still wrong
    http://www.retro8bitcomputers.co.uk/Downloads/ZXSpectrumBASICProgramming
    Post edited by Crisis on
    my old website http://home.hccnet.nl/c.born/ has changed to http://www.cborn.nl/zxfiles/ so just click it and select a file
  • My earlier post was only about what Derek had written...

    In regards to the reference to page 155, that’s APPENDIX C (Part 2), see here (scroll down the page till you get to the section headed “Functions”.

    Highly priority operations or functions are calculated first.
    So for example PRINT 2+3*4 will print 14 and not 20 because first the multiplication is carried out before the addition.

    The function NOT has a low priority of 4, the only lower priority functions are AND and OR. Everything else is a higher priority including add (+). Hence the expression CHR$ NOT PI + CHR$ 0 is seen by the BASIC syntax checker as PI + CHR$ 0 first, only after this has been worked out will it then consider the NOT. However going back to my earlier post, the BASIC syntax checker will not be happy with PI + CHR$ 0 because PI is a number and CHR$ 0 is a character (even though it’s not printable and if you try the ZX Spectrum will instead print a question mark ?).

    To get the machine to do what you want, you have to use brackets () to tell the BASIC which bit to work out first. Hence CHR$(NOT PI) + CHR$ 0 will now pass the check by the syntax checker, as (NOT PI) will work out as 0, the expression becomes CHR$(0) + CHR$ 0 which is fine, as you are concentrating two characters together to make a string :)

    Mark
  • edited June 29
    Thanks, i did find https://worldofspectrum.org/ZXBasicManual/ but i did not see the page numbers,
    Next time i will dive into the apendexus first1
    Functions and operations have the following priorities:
    Operation 	Priority
    Subscripting and slicing 	12
    All functions except NOT and unary minus 	11
    To the power of.. 	10
    Unary minus (i.e. minus just used to negate something) 	0
    *, / 	8
    +, - (minus used to subtract one number from another) 	6
    =, >, <, <=, >=, <> 	5
    NOT 	4
    AND 	3
    OR 	2
    
    Post edited by Crisis on
    my old website http://home.hccnet.nl/c.born/ has changed to http://www.cborn.nl/zxfiles/ so just click it and select a file
  • edited June 29
    1024MAK wrote: »

    So what happens if you do shoehorn your program past the syntax checker and run the program? What does it actually print?
    For
    100 PRINT PI + CHR$ 0
    110 PRINT PI + CHR$ NOT PI
    120 PRINT NOT PI + CHR$ 0
    130 PRINT NOT PI + CHR$ NOT PI
    
    You get
    1728.1416
    1728.1416
    0
    0
    

    But then if you add
    140 PRINT (PI + CHR$ 0)
    150 PRINT (PI + CHR$ NOT PI)
    160 PRINT (NOT PI + CHR$ 0)
    170 PRINT (NOT PI + CHR$ NOT PI)
    

    You get
    317.14159
    317.14159
    0
    0
    317.14159
    317.14159
    0
    0
    

    very strange...

    Regards,
    Derek.
    Post edited by dbolli on
    1985: ZX Spectrum+ 48K Interface 1 ZX81 16KB ASZMIC/SP ROM Philips 12" B/W TV Epson Dot Matrix Printer ZX Printer Now: Late 2015 iMac 5K 27" 4GHz i7 32GB RAM macOS 10.15.6 beta 2 1TB Ext SSD USB C Drive Ext 4TB 3TB and 2TB USB 3 Hard Disks Ext USB 3 Blu-Ray iPad R7 32GB iPhone 6s 64GB iOS 13.5.1 Apple TV Gen 2
Sign In or Register to comment.