Author Topic: Some resources.  (Read 8652 times)

E.K.Virtanen

  • Guest
Some resources.
« on: September 08, 2010, 07:03:32 AM »
I think we all know Chipmunk BASIC, but incase you havent studied the website for more, there is nice amount of resources linked too.
http://www.nicholson.com/rhn/basic/#2

MRBCX

  • Guest
Re: Some resources.
« Reply #1 on: September 10, 2010, 06:44:29 AM »
And speaking of CHIPMUNK ...

The original PASCAL source code by Dave Gillespie, upon which Ron Nicholson derived Chipmunk, is indeed
interesting.  Unfortunately, because it was not covered by GPL or the like, Ron is not obligated (or inclined)
to share any of the source code from his derived works from it.

Back in 2005, I pulled the (original) basic.p file from the P2C package, converted it to C, and set about
trying to make sense of it.  I was initially quite interested in it.  I added basic file handling, killed a few
bugs, and added many string functions from the BCX run time library.  The initial result was a 32-bit
Windows console program that was considerably more powerful than the original.  

Then I lost interest in it for 5 years ... until about a month ago (what a coincidence that I am discussing
this on this forum).  I made a few more improvements like adding simple binary file access to the language.
For example: OPEN "filename.bin" for BINARY AS 1 : Get 1, A$, 255 : CLOSE 1

I was feeling pretty smug with my efforts until I stumbled onto the fact that it is leaking memory.  
The magnitude of the leak is a function of the currently loaded BASIC program and the consecutive
number of times that program has been run in memory.  It is obviously not freeing memory correctly,
especially in BASIC programs containing arrays.  Programs with large arrays reveal the problem quickly.

Wayne Halsdorf was kind enough to take an initial look but I don't believe he has the time or inclination
to immerse himself into one of my on-again, off-again, hobby projects at this time.  

I've been calling my version "GILLESPIE BASIC", in honor of the man who did the heavy lifting.  It really
is a neat implementation, bordering on genius in my opinion.  It starts up in a windows console window
waiting for commands to be entered from the keyboard, just like in the old days.  It can load and save
files, and I've added the Windows OpenFile dialog to make navigating to source files a little easier.
The current executable is a tiny 114kb (uncompressed)

Okay - here's the part you've been waiting for ... if anyone wants to take up the cause, I've zipped up
my current efforts for you to download, explore, improve, and SHARE.

Download link: http://www.bcxgurus.com/GillespieBasic.zip

Be sure to skim through the file BASIC.TXT for a quick overview.

« Last Edit: September 10, 2010, 07:46:17 AM by MRBCX »

E.K.Virtanen

  • Guest
Re: Some resources.
« Reply #2 on: September 10, 2010, 07:13:30 AM »
Hi MRBCX.

Your post for sure did woke my interest. However, that is for windows only? Any idea would it be hard to port for linux? I dont have windows here at all, and using wine is..err...irritating.

Steve A.

  • Guest
Re: Some resources.
« Reply #3 on: September 10, 2010, 07:20:49 AM »
Hey Kevin,

That's pretty good.
I haven't seen a recent port of GWBasic before. Not like that.
I still have and use GWBasic, for testing purposes and running old code.

Good to see you still dabble in some of this fun stuff like interpreters.
I haven't conversed with you in years, not since the early days when we up started the QDepartment Yahoo Group.

Good to see you take an interest in this group.

Steve A. <QDepartment>

MRBCX

  • Guest
Re: Some resources.
« Reply #4 on: September 10, 2010, 07:28:26 AM »
Hi MRBCX.

Your post for sure did woke my interest. However, that is for windows only? Any idea would it be hard to port for linux? I dont have windows here at all, and using wine is..err...irritating.

Hi E.K.

Less than 5% of the source code is Win32 specific. 

Porting to another OS should not be difficult for one who speaks 'C'.


codeguy

  • Guest
Re: Some resources.
« Reply #5 on: September 26, 2010, 07:55:16 PM »
hey guys, we could use a power assist on qb64. maybe if one of you c gurus can write a compelling enough and thoroughly coded source for galleon to implement api calls in qb64, we could take qb64 to the next level. it is already a really excellent project (international keyboard support and FIELD statement are the latest additions). we could really use somebody who can do compilers and interpreters.

JRS

  • Guest
Re: Some resources.
« Reply #6 on: September 26, 2010, 09:36:13 PM »
Quote
we could really use somebody who can do compilers and interpreters.

For those that haven't heard about QB64 yet, it's a QB45 on steroids and runs on 32/64 bit platforms. (Windows, Linux and Mac) I feel the author's first goal was to get beyond the limitations imposed with QB45 as OSs matured. It does have socket support but lacks DLL/static library linking. QB64 is a Basic to C translator and uses (MinGW-) gcc to create it's executables.

I offered the ScriptBasic DYC extension module code as a quick way to add DLL support but I don't know the QB64 internals well enough to implement it. I think the QB64 group is looking for a more robust solution that would allow both dynamic and static libraries to be linkable to the compiled source and use C header files.

Well, that's my pitch for the QB64 group. I hope this posts generates some interest in expanding on the QB64 language.


JRS

  • Guest
Re: Some resources.
« Reply #7 on: September 26, 2010, 10:34:39 PM »
Quote from: MrBcx
Okay - here's the part you've been waiting for ... if anyone wants to take up the cause, I've zipped up my current efforts for you to download, explore, improve, and SHARE.

Thanks for sharing Kevin!

I tried the GB sieve.bas program in SB and it ran in about the same time as GB.

Code: [Select]
' 10 '**********************************************
' 20 ' "sieve.bas" , a prime number sieve benchmark
' 30 '**********************************************
40 T =  NOW
' 50 DIM F(8194)
C = 0
60 FOR  I = 0 TO 8191
70 F[I] = 1
80 NEXT I
90 S = 8191
100 FOR  I = 0 TO S
110 IF  F[I] = 0 THEN GOTO 170
120 P = I + I + 3
130 FOR  K = I + P TO S STEP P
140 F[K] = 0
150 NEXT K
160 C = C + 1
170 NEXT I
180 PRINT  C, " primes found in "
190 T =  NOW  - T
200 PRINT  T, " seconds\n"
210 END

C:\scriptbasic\test>sieve.sb
1899 primes found in 2 seconds

C:\scriptbasic\test>

Update

Creating and initializing an array with a FOR/NEXT loop is painfully slow in SB. (no need to dimension them, linked list under the covers) I used SPLITA to create and initialize my array and you can see the difference.

Code: [Select]
' 10 '**********************************************
' 20 ' "sieve.bas" , a prime number sieve benchmark
' 30 '**********************************************
40 T =  NOW
C = 0
' 50 DIM F(8194)
' 60 FOR  I = 0 TO 8191
' 70 F[I] = 1
' 80 NEXT I
SPLITA STRING(8192,49) BY "" TO F
90 S = 8191
100 FOR  I = 0 TO S
110 IF  F[I] = 0 THEN GOTO 170
120 P = I + I + 3
130 FOR  K = I + P TO S STEP P
140 F[K] = 0
150 NEXT K
160 C = C + 1
170 NEXT I
180 PRINT  C, " primes found in "
190 T =  NOW  - T
200 PRINT  T, " seconds\n"
210 END

C:\scriptbasic\test>sieve.sb
1899 primes found in 0 seconds

C:\scriptbasic\test>

I was determined to reach a second so I multiplied 8191 times 10. Success!

Code: [Select]
SPLITA STRING(81920,49) BY "" TO F
90 S = 81919

C:\scriptbasic\test>sieve.sb
14999 primes found in 1 seconds

C:\scriptbasic\test>

FYI:

The SPLITA function works for filling out any dimension of an array.  (previously defined or not)  :o

You could SPLITA a delimited string of variable length text to an array in the same manor. Add the REF feature to the mix and you can quickly define complex structures easily. (standard numeric elements definitions, associative element definitions or a combination of both)

Code: [Select]
SPLITA "zero,one,two,three,four,five,six,seven,eight,nine" BY "," TO F[5]

FOR x = 0 TO 9
  PRINT F[5,x],"\n"
NEXT x

PRINT LBOUND(F),"\n"
PRINT UBOUND(F),"\n"
PRINT LBOUND(F[5]),"\n"
PRINT UBOUND(F[5]),"\n"

F[1] = 1

FOR x = LBOUND(F) TO UBOUND(F)
  PRINT F[x],"\n"
NEXT x

C:\scriptbasic\test>testsa.sb
zero
one
two
three
four
five
six
seven
eight
nine
5
5
0
9
1
undef
undef
undef
ARRAY@#0048004C

C:\scriptbasic\test>
I reran the "GILLESPIE BASIC" version of sieve.bas with 81919 iterations. (see attached) I guess we can say that SB is at least 20 times faster then GB.
« Last Edit: September 28, 2010, 01:50:02 AM by JRS »

Pjot

  • Guest
Re: Some resources.
« Reply #8 on: September 27, 2010, 01:03:32 PM »
The original program slightly modified for BaCon.

Code: [Select]
' 10 '**********************************************
' 20 ' "sieve.bas" , a prime number sieve benchmark
' 30 '**********************************************
T = NOW
DECLARE F[8194]
C = 0
FOR I = 0 TO 8191
F[I] = 1
NEXT I
S = 8191
FOR I = 0 TO S
IF F[I] IS 0 THEN GOTO _170
P = I + I + 3
FOR K = I + P TO S STEP P
F[K] = 0
NEXT K
C = C + 1
LABEL _170: NEXT I
PRINT  C, " primes found in ";
T = NOW - T
PRINT T, " seconds\n"
END

Result is:

Quote
peter@host# ./sieve2
1899 primes found in 0 seconds

Using the Linux 'time' utility:

Quote
peter@host# time ./sieve2
1899 primes found in 0 seconds

real   0m0.003s
user   0m0.000s
sys   0m0.000s

JRS

  • Guest
Re: Some resources.
« Reply #9 on: September 27, 2010, 01:16:34 PM »
WOW! BaCon is a screamer. Thanks for the post!

FYI: I'm running my tests on an Intel P4 1.8 ghz @ 330 bus speed
« Last Edit: September 27, 2010, 11:47:42 PM by JRS »