Is Sinclair Basic 100% compatible with ZX Boriel BASIC compiler?

The place for codemasters or beginners to talk about programming any language for the Spectrum.
Post Reply
firelord
Manic Miner
Posts: 557
Joined: Wed Nov 03, 2021 10:57 am
Location: Greece - Thessaloniki

Is Sinclair Basic 100% compatible with ZX Boriel BASIC compiler?

Post by firelord »

Sinclair Basic is 100% compatible with ZX Boriel BASIC compiler? I mean can Boriel compiler be used as a replacement for zmakebas or bas2tap?
If I send any working Sinclair Basic program to ZX Boriel compiler will it work ?
I remember I read somewhere that it wasn't 100% compatible.
User avatar
PeterJ
Site Admin
Posts: 6882
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Re: Is Sinclair Basic 100% compatible with ZX Boriel BASIC compiler?

Post by PeterJ »

@firelord,

Whilst not perfect, the Wiki is very good and highlights where there are differences to Sinclair BASIC.

https://zxbasic.readthedocs.io/en/docs/syntax/
User avatar
1024MAK
Bugaboo
Posts: 3123
Joined: Wed Nov 15, 2017 2:52 pm
Location: Sunny Somerset in the U.K. in Europe

Re: Is Sinclair Basic 100% compatible with ZX Boriel BASIC compiler?

Post by 1024MAK »

No compiler can ever be 100% compatible with an interpreted language. With an interpreted language like ZX Spectrum BASIC, the interpreter has information available at run time (when the instructions are processed) that is not available at compile time (when a compiler processes the instructions and converts to machine language/code).

Mark

PS although the term “SInclair BASIC” is spoken about, it’s not really a thing. Sinclair did not write it, and the BASIC on the ZX80, ZX81 and QL are all different to that on the ZX Spectrum. Yes, there are some parts that are similar or the same, but then that applies to most BASICs.
Last edited by 1024MAK on Wed Dec 06, 2023 9:06 am, edited 1 time in total.
:!: Standby alert :!:
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :dance
Looking forward to summer later in the year.
User avatar
+3code
Manic Miner
Posts: 435
Joined: Sat Mar 19, 2022 7:40 am

Re: Is Sinclair Basic 100% compatible with ZX Boriel BASIC compiler?

Post by +3code »

In short: no. Boriel BASIC syntax is more like QBASIC.
User avatar
+3code
Manic Miner
Posts: 435
Joined: Sat Mar 19, 2022 7:40 am

Re: Is Sinclair Basic 100% compatible with ZX Boriel BASIC compiler?

Post by +3code »

1024MAK wrote: Wed Dec 06, 2023 9:01 am PS although the term “SInclair BASIC” is spoken about, it’s not really a thing. Sinclair did not write it, and the BASIC on the ZX80, ZX81 and QL are all different to that on the ZX Spectrum.
The QL's SuperBASIC is highly different, but the ZX80, ZX81 and etc. are almost the same, I think. Here is a short description of all the ZX's BASICs: https://en.wikipedia.org/wiki/Sinclair_BASIC
User avatar
1024MAK
Bugaboo
Posts: 3123
Joined: Wed Nov 15, 2017 2:52 pm
Location: Sunny Somerset in the U.K. in Europe

Re: Is Sinclair Basic 100% compatible with ZX Boriel BASIC compiler?

Post by 1024MAK »

+3code wrote: Wed Dec 06, 2023 9:32 am The QL's SuperBASIC is highly different, but the ZX80, ZX81 and etc. are almost the same, I think. Here is a short description of all the ZX's BASICs: https://en.wikipedia.org/wiki/Sinclair_BASIC
Almost the same, no. With similarities, yes. But like I said, also with similarities to say the various Microsoft 8 bit BASICs that were available at the time. And yes, I’m aware of that Wikipedia article (complete with numerous errors).

ZX80 BASIC is only 4K bytes in size, it doesn’t have floating point numbers and has lots of limitations. This BASIC uses it’s own unique character set.

ZX81 BASIC is an evolution of ZX80 BASIC, but with a lot of rewriting of the code. It’s 8K bytes in size, so double in size compared to ZX80 BASIC. Not all the commands and functions are the same. The syntax may be different for example. The number of functions were expanded and there was changes to string handling. This BASIC uses it’s own unique character set.

ZX Spectrum (16K/48K/+) BASIC is 16K bytes is size, so double that of a ZX81. Again, it’s an evolution of ZX81 BASIC with almost all the ZX81 code having been altered or rewritten. Again, many of the commands and functions may have different syntax. Plus there are many more commands and functions that did not previously exist. This BASIC uses the ASCII character set and has character control codes.



With all these versions, when just using a standard machine with no extra software, you can’t LOAD BASIC programs written and SAVEd from a different machine, as the tape format is different for each of them.

Mark
Last edited by 1024MAK on Wed Dec 06, 2023 10:28 am, edited 1 time in total.
:!: Standby alert :!:
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :dance
Looking forward to summer later in the year.
firelord
Manic Miner
Posts: 557
Joined: Wed Nov 03, 2021 10:57 am
Location: Greece - Thessaloniki

Re: Is Sinclair Basic 100% compatible with ZX Boriel BASIC compiler?

Post by firelord »

1024MAK wrote: Wed Dec 06, 2023 9:01 am No compiler can ever be 100% compatible with an interpreted language. With an interpreted language like ZX Spectrum BASIC, the interpreter has information available at run time (when the instructions are processed) that is not available at compile time (when a compiler processes the instructions and converts to machine language/code).
I mean can Boriel compiler be used as a replacement for zmakebas or bas2tap? I want the exact functionaluty of zmakebas. textfile input (with basic commands), TZX/TAP output
1024MAK wrote: Wed Dec 06, 2023 9:01 am PS although the term “SInclair BASIC” is spoken about, it’s not really a thing. Sinclair did not write it, and the BASIC on the ZX80, ZX81 and QL are all different to that on the ZX Spectrum. Yes, there are some parts that are similar or the same, but then that applies to most BASICs.
I use the term Sinclair Basic because I mean the Basic that supports color commands like PAPER,FLASH and BRIGHT. Also, ZX Basic and spectrum Basic returned results for Boriel ZX Basic. I haven't found any other term that can separate ZX Spectrum Sinclair basic from other Basic's.
User avatar
uglifruit
Manic Miner
Posts: 703
Joined: Thu Jan 17, 2019 12:41 pm
Location: Leicester
Contact:

Re: Is Sinclair Basic 100% compatible with ZX Boriel BASIC compiler?

Post by uglifruit »

It's worth noting that a compiler is never going to be able to deal with things like calculated line numbers.

This is a favourite of mine for level data.

Code: Select all

10 LET Level=1
20 GOSUB 2000:REM draw the level
30 ...

2000 RESTORE (8000+Level*100)
2010 FOR A=1 TO 4
2020 READ A$:PRINT A$
2030 NEXT A
2040 RETURN

8100 REM level 1
8101 DATA "this","is","level","one"
8200 REM level 2
8201 DATA "level","two","is","this"
CLEAR 23855
User avatar
1024MAK
Bugaboo
Posts: 3123
Joined: Wed Nov 15, 2017 2:52 pm
Location: Sunny Somerset in the U.K. in Europe

Re: Is Sinclair Basic 100% compatible with ZX Boriel BASIC compiler?

Post by 1024MAK »

But there are no colour or attribute commands (such as INK, PAPER, FLASH and BRIGHT) in ZX80 or ZX81 BASIC.

The term “Sinclair BASIC” or “ZX BASIC” is hence vague. Because the ZX Spectrum was the better known machine in most countries, often when people use “Sinclair BASIC” what they actually mean is “ZX Spectrum BASIC”.

Mark
:!: Standby alert :!:
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :dance
Looking forward to summer later in the year.
firelord
Manic Miner
Posts: 557
Joined: Wed Nov 03, 2021 10:57 am
Location: Greece - Thessaloniki

Re: Is Sinclair Basic 100% compatible with ZX Boriel BASIC compiler?

Post by firelord »

I see your point(s). :)
Thanks all for the information.
The correct term for my searches would be "Basic that ZX Spectrum + 48k uses".
You can try googleing it :) .

I know that Boriel is not compatible with "Sinclair Basic". For some reason I saw some posts these days that made me think that It had backward compatibility.
Spoiler
I'm using zmakebas to convert text files that contain Basic code to TAP files that contain the Basic of the text file. I do that server-side on a php script.

The most appealing commands of "Sinclair ZX Spectrum 48k Basic " for kids are PAPER,INK,FLASH and similar "pretty looking" commands. So my searches are always for this particular variation of Basic. If I don't have those then I could use python.
User avatar
PeterJ
Site Admin
Posts: 6882
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Re: Is Sinclair Basic 100% compatible with ZX Boriel BASIC compiler?

Post by PeterJ »

FLASH is still there @firelord:

https://zxbasic.readthedocs.io/en/docs/flash/
User avatar
+3code
Manic Miner
Posts: 435
Joined: Sat Mar 19, 2022 7:40 am

Re: Is Sinclair Basic 100% compatible with ZX Boriel BASIC compiler?

Post by +3code »

uglifruit wrote: Wed Dec 06, 2023 10:32 am It's worth noting that a compiler is never going to be able to deal with things like calculated line numbers.
Hisoft BASIC Compiler seems to handle some calculated jumps. Maybe others compilers too, no idea. Reading the manual:
REM: GOTO
REM: GOSUB
These two directives are completely equivalent. If you use either of them, then GOTO and GOSUB
expression (e.g. GOTO 100 *N) will be supported and the compiled code will include a list of line numbers and the corresponding addresses in the compiled code. There are two forms: If the GOTO or GOSUB is followed by: (e.g. REM: GOTO:) then all of the program's line numbers within the region being compiled will be included in the list. If the GOTO or GOSUB is followed by a sequence of line numbers (e.g. REM: GOTO 100,200,300) then only those line numbers will be included in the list. In either case, if a line number not in the list is needed, the compiled code will generate a run time error Statement lost.
catmeows
Manic Miner
Posts: 718
Joined: Tue May 28, 2019 12:02 pm
Location: Prague

Re: Is Sinclair Basic 100% compatible with ZX Boriel BASIC compiler?

Post by catmeows »

+3code wrote: Wed Dec 06, 2023 4:25 pm Hisoft BASIC Compiler seems to handle some calculated jumps. Maybe others compilers too, no idea. Reading the manual:
Yes it can be done and basically you could end with something that is in between straight to assembly compilation and transpilation to a bytecode that could cover all constructs available in Basic, including expressions in DATA statements and computed GOTO, RESTORE. But it is harder to do.
Proud owner of Didaktik M
User avatar
+3code
Manic Miner
Posts: 435
Joined: Sat Mar 19, 2022 7:40 am

Re: Is Sinclair Basic 100% compatible with ZX Boriel BASIC compiler?

Post by +3code »

firelord wrote: Wed Dec 06, 2023 11:03 am I know that Boriel is not compatible with "Sinclair Basic". For some reason I saw some posts these days that made me think that It had backward compatibility.
In some cases, you can compile a program with only few changes, like https://zxbasic.readthedocs.io/en/docs/ ... narow.bas/
catmeows
Manic Miner
Posts: 718
Joined: Tue May 28, 2019 12:02 pm
Location: Prague

Re: Is Sinclair Basic 100% compatible with ZX Boriel BASIC compiler?

Post by catmeows »

+3code wrote: Wed Dec 06, 2023 4:38 pm In some cases, you can compile a program with only few changes, like https://zxbasic.readthedocs.io/en/docs/ ... narow.bas/
Doesn't look like Spectrum Basic, there is END IF.
Proud owner of Didaktik M
User avatar
+3code
Manic Miner
Posts: 435
Joined: Sat Mar 19, 2022 7:40 am

Re: Is Sinclair Basic 100% compatible with ZX Boriel BASIC compiler?

Post by +3code »

catmeows wrote: Wed Dec 06, 2023 4:44 pm Doesn't look like Spectrum Basic, there is END IF.
Yes, and FLOAT (and one CONTINUE FOR, I see), these are the "few changes" I said.
User avatar
patters
Manic Miner
Posts: 471
Joined: Thu Apr 11, 2019 1:06 am

Re: Is Sinclair Basic 100% compatible with ZX Boriel BASIC compiler?

Post by patters »

uglifruit wrote: Wed Dec 06, 2023 10:32 am It's worth noting that a compiler is never going to be able to deal with things like calculated line numbers.

This is a favourite of mine for level data.

Code: Select all

10 LET Level=1
20 GOSUB 2000:REM draw the level
30 ...

2000 RESTORE (8000+Level*100)
2010 FOR A=1 TO 4
2020 READ A$:PRINT A$
2030 NEXT A
2040 RETURN

8100 REM level 1
8101 DATA "this","is","level","one"
8200 REM level 2
8201 DATA "level","two","is","this"
It is sort of possible to do this with zmakebas, though not quite as cleanly (so it won't be as fast):
https://github.com/ohnosec/zmakebas/issues/4
User avatar
Jbizzel
Dynamite Dan
Posts: 1537
Joined: Mon May 04, 2020 4:34 pm
Location: Hull
Contact:

Re: Is Sinclair Basic 100% compatible with ZX Boriel BASIC compiler?

Post by Jbizzel »

firelord wrote: Wed Dec 06, 2023 8:23 am Sinclair Basic is 100% compatible with ZX Boriel BASIC compiler? I mean can Boriel compiler be used as a replacement for zmakebas or bas2tap?
If I send any working Sinclair Basic program to ZX Boriel compiler will it work ?
I remember I read somewhere that it wasn't 100% compatible.
No. You can't compile any basic code with zx basic. But I think the website has a guide for the key changes you need to make.

Once you get going zx basic is easier than Sinclair basic imho
Post Reply