BASIC code to test compilers
- 1024MAK
- Bugaboo
- Posts: 3123
- Joined: Wed Nov 15, 2017 2:52 pm
- Location: Sunny Somerset in the U.K. in Europe
Re: BASIC code to test compilers
I think this topic shows why BASIC compilers were not as popular as some may have expected, far too many limitations.
I know it’s an unfair comparison, but using OPL on a Psion in comparison is like being in a different universe.
For comparison purposes, the PCW benchmark programs (Rugg/Feldman benchmarks) are normally used, as mostly they do allow comparisons across various platforms and BASIC versions.
Mark
I know it’s an unfair comparison, but using OPL on a Psion in comparison is like being in a different universe.
For comparison purposes, the PCW benchmark programs (Rugg/Feldman benchmarks) are normally used, as mostly they do allow comparisons across various platforms and BASIC versions.
Mark
Standby alert
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer later in the year.
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer later in the year.
- 1024MAK
- Bugaboo
- Posts: 3123
- Joined: Wed Nov 15, 2017 2:52 pm
- Location: Sunny Somerset in the U.K. in Europe
Re: BASIC code to test compilers
This however is not too difficult to test, run a FOR NEXT routine for long enough (say a minute or two), timing also with a stopwatch, then compare to the Frames counter result.Turtle_Quality wrote: ↑Mon Aug 14, 2023 5:41 pm The only drawback with using Frames as a timer is that you're assuming the interrupts are always enabled. The ROMs BEEP will disable interrupts temporarily, we can't be sure what compilers might do with interrupts, especially compilers with different trace levels like MCoder. Quite likely nothing, I'm probably just displaying nerdy levels of caution
Mark
Standby alert
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer later in the year.
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer later in the year.
Re: BASIC code to test compilers
Thanks. think these are the ones I posted to earlier Mark
viewtopic.php?p=123029#p123029
PS. I think summer has come and gone now...
- 1024MAK
- Bugaboo
- Posts: 3123
- Joined: Wed Nov 15, 2017 2:52 pm
- Location: Sunny Somerset in the U.K. in Europe
Re: BASIC code to test compilers
Currently sunny weather in sunny Somerset, current outside air temperature of 18°C
Yes, the link was earlier in the topic.
Mark
Yes, the link was earlier in the topic.
Mark
Standby alert
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer later in the year.
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer later in the year.
Re: BASIC code to test compilers
What is the fastest compiler that supports decimal numbers ?
Mcoder II gives Nonsense in basic message.
Mcoder II gives Nonsense in basic message.
Re: BASIC code to test compilers
Probably Mcoder 3 @Pegaz,
https://spectrumcomputing.co.uk/entry/8421
Ones that support floating point are slower. Crash issues 19 and 20 have some good articles.
https://spectrumcomputing.co.uk/entry/8421
Ones that support floating point are slower. Crash issues 19 and 20 have some good articles.
Re: BASIC code to test compilers
Did I make a mistake somewhere, its almost 5x slower in the bubble sort example, than Mcoder II?
260ms vs 1180ms
260ms vs 1180ms
Re: BASIC code to test compilers
I'm still learning @Pegaz, but FP compilers are much slower than integer compilers.
Re: BASIC code to test compilers
I'm not an expert either, I just have a some experience with Boriel Basic compiler, but as @1024MAK already said, there are a lot of limitations with all of them and it takes a effort and knowledge to adapt the BASIC program to compile successfully, which is quite frustrating.
btw, Is there a some user manual for ZIP compiler?
Its very fast, but it seems also supports integer numbers only...
Re: BASIC code to test compilers
I have a user manual for ZIP, but I can't distribute it as the author is still selling it. It was originally a listing in Your Sinclair, so you should find some detail there. MCODER 3 should compile the majority of BASIC without alteration.
https://spectrumcomputing.co.uk/page.ph ... 21&page=68
Efit... Sorry, should have read Your Spectrum!
Re: BASIC code to test compilers
Sorry, I thought it was available as a type in.PeterJ wrote: ↑Mon Aug 14, 2023 10:14 pm I have a user manual for ZIP, but I can't distribute it as the author is still selling it. It was originally a listing in Your Sinclair, so you should find some detail there. MCODER 3 should compile the majority of BASIC without alteration.
https://spectrumcomputing.co.uk/page.ph ... 21&page=68
Actually, Mcoder II/III are perfectly fine and easy to use.
Re: BASIC code to test compilers
I tried all 3 available download files of MCoder 2 with permanent Nonsense in BASIC for
Can you be so kind to explain your success with NOT operation?
Was it file from download pages or you have other file?
I have not only trouble with DIM but no success with simple OR instructions - i get the same Nonsense in BASIC.
Moreover NOT instruction has the same result
But using AND operation compiles OK.
It is possible to use AND + NOT to change program logic and get rid of OR operations but i have errors with NOT as you see above.
Code: Select all
10 DIM p$(1000)
@PobulousPobulous wrote: ↑Mon Aug 14, 2023 3:47 pm MCoder II was what I used, too.
Whilst it says it supports AND and OR in IF statements, the version I had was definitely bugged when using them leading to much hair pulling debugging code which then worked if replaced with IF ... THEN IF .... THEN IF .... for AND
OR would be IF NOT .... THEN IF NOT ... THEN IF NOT .... THEN GOTO nomatch.
Can you be so kind to explain your success with NOT operation?
Was it file from download pages or you have other file?
I have not only trouble with DIM but no success with simple OR instructions - i get the same Nonsense in BASIC.
Code: Select all
IF (1<2) OR (2<3) THEN
IF ((1<2) OR (2<3)) THEN
Code: Select all
IF NOT (1<2) THEN
IF (NOT 1<2) THEN
IF (NOT (1<2)) THEN
Code: Select all
IF (1<2) AND (2<3) THEN
Re: BASIC code to test compilers
String arrays are not supported.marenja wrote: ↑Tue Aug 15, 2023 1:14 pm I tried all 3 available download files of MCoder 2 with permanent Nonsense in BASIC forCode: Select all
10 DIM p$(1000)
Re: BASIC code to test compilers
It's possible I misremembered using NOT. You could however invert your logic manually.marenja wrote: ↑Tue Aug 15, 2023 1:14 pm @Pobulous
Can you be so kind to explain your success with NOT operation?
Was it file from download pages or you have other file?
.....
It is possible to use AND + NOT to change program logic and get rid of OR operations but i have errors with NOT as you see above.
So
100 IF a>b OR d=e THEN goto 1000
110 REM do stuff when IF fails
becomes:
100 IF a<=b THEN IF d<>e THEN goto 110
105 GOTO 1000
110 REM do stuff when IF fails
I remember that AND was accepted in IF statements but didn't actually work properly in MCoder II - would be worth running some tests on that.
Re: BASIC code to test compilers
Most of compilers would delegate task of drawing circle to ROM routine. Same for PLOT or DRAW commands.
Proud owner of Didaktik M
Re: BASIC code to test compilers
i used it for my ultra slow 4connectPeterJ wrote: ↑Mon Aug 14, 2023 9:35 pm Probably Mcoder 3 @Pegaz,
https://spectrumcomputing.co.uk/entry/8421
Ones that support floating point are slower. Crash issues 19 and 20 have some good articles.
- dust hill resident
- Dizzy
- Posts: 52
- Joined: Sat Sep 23, 2023 6:05 pm
- Location: London
- Contact:
Re: BASIC code to test compilers
Your post got me intrigued and I thought it'd be a fun challenge so I had a go at it tonight, here is quicksort in Sinclair BASIC:equinox wrote: ↑Sun Aug 13, 2023 10:32 pm Thanks. I actually thought "ok I'll write quicksort, how hard can it be?" and then after writing DIM a(500) and remembering that we don't have either local scope, or bounds checks*, I cried and gave up. (Recursion is enough fun when you have scope.) Haha! The problem of implementing textbook stuff in Spectrum BASIC is absolutely not a problem of memory or CPU, it's just how am I going to use this awful BASIC to code it. We've been spoiled with data structures and templates. [Well, I guess half the people reading this can write assembler, but do you know what you've got, that BASIC hasn't got? PUSH and POP†]
http://dusthillresident.ddns.net/quicksort.tzx
Sorry for the weird URL, I would have posted it as an attachment on the board, but I couldn't see an option for it.
Here's a youtube video of it in action:
- dhr
- dust hill resident
- Dizzy
- Posts: 52
- Joined: Sat Sep 23, 2023 6:05 pm
- Location: London
- Contact:
Re: BASIC code to test compilers
Perhaps this program would also be useful for testing basic compilers? It calculates an approximation of the sine function.
https://dusthillresident.ddns.net/sinapprox.tzx
- dhr
https://dusthillresident.ddns.net/sinapprox.tzx
- dhr
Re: BASIC code to test compilers
Is it sad that I watched the whole quicksort video
- ParadigmShifter
- Manic Miner
- Posts: 670
- Joined: Sat Sep 09, 2023 4:55 am
Re: BASIC code to test compilers
I watched it too. Wonder how "quick" it would be in the pathological worst case (an already sorted array, which is O(n^2) for quicksort - so same sort of performance as a bubble sort (probably worse than that though if it is recursive))? The expected ("amortised") time is O(n log n) though. If you suspect the array may be sorted better to reverse it first