Using and improving Exbasic
Moderator: Moderators
-
- Vic 20 Afficionado
- Posts: 352
- Joined: Tue Apr 14, 2009 8:15 am
- Website: http://wimbasic.webs.com
- Location: Netherlands
- Occupation: farmer
Hello Rob,
The colorcodes are indeed biased by 1, so they correspond to the keys 1-8.
In Exbasic the accepted range was 1-8, but in an early version of WimBasic I already expanded this to 1-16. Multicolor does work. Please show me what you tested.
Regards,
Wim.
The colorcodes are indeed biased by 1, so they correspond to the keys 1-8.
In Exbasic the accepted range was 1-8, but in an early version of WimBasic I already expanded this to 1-16. Multicolor does work. Please show me what you tested.
Regards,
Wim.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
Code: Select all
5 a=0
10 coke a, 81, a
20 a = a + 1
30 if a > 255 then end
40 goto 10
Rob
-
- Vic 20 Afficionado
- Posts: 352
- Joined: Tue Apr 14, 2009 8:15 am
- Website: http://wimbasic.webs.com
- Location: Netherlands
- Occupation: farmer
The memory area where VIC keeps the colors per character ($9400-$97FF) is only 4 bits wide, so only values 0..15 are actually valid.
Biased with 1, in order to match the keys, is the best I can do in WimBasic.
To make your program work, you'd have to mask out the last 4 bits of A and add 1.
coke a, 81, (a and 15)+1
Regards,
Wim.
Biased with 1, in order to match the keys, is the best I can do in WimBasic.
To make your program work, you'd have to mask out the last 4 bits of A and add 1.
coke a, 81, (a and 15)+1
Regards,
Wim.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
-
- Vic 20 Afficionado
- Posts: 352
- Joined: Tue Apr 14, 2009 8:15 am
- Website: http://wimbasic.webs.com
- Location: Netherlands
- Occupation: farmer
New version with SuperNumbers
I am proud to announce that there is a new version available of WimBasic at http://home.kpn.nl/oost4231/wimbasic.zip
In this version there is support for SuperNumbers.
- They process about 20% faster than regular float variables
- They remain between Basic programs
They are addressed using an alphabetic letter, prefixed by a pound sign.
- There are only 26 SuperNumbers available
- They may not be used as a loopcounter in FOR..NEXT
- They take up 130 bytes from the top of RAM.
The following commands are available to manage SuperNumbers:
- DUMP* to display all non-zero SuperNumbers
- CLR* to clear all SuperNumbers to zero.
Regards,
Wim.
In this version there is support for SuperNumbers.
- They process about 20% faster than regular float variables
- They remain between Basic programs
They are addressed using an alphabetic letter, prefixed by a pound sign.
- There are only 26 SuperNumbers available
- They may not be used as a loopcounter in FOR..NEXT
- They take up 130 bytes from the top of RAM.
The following commands are available to manage SuperNumbers:
- DUMP* to display all non-zero SuperNumbers
- CLR* to clear all SuperNumbers to zero.
Regards,
Wim.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
- Mike
- Herr VC
- Posts: 4941
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
Re: New version with SuperNumbers
... which is not as dramatic as it sounds. FOR stores a pointer to the value of the loop variable, so at least NEXT can access it with a speed comparable to SuperNumbers, anyway. And if the loop variable is used often enough within the loop to make a difference, one still can copy it to a SuperNumber right after the FOR instruction.wimoos wrote:- They may not be used as a loopcounter in FOR..NEXT
-
- Vic 20 Afficionado
- Posts: 352
- Joined: Tue Apr 14, 2009 8:15 am
- Website: http://wimbasic.webs.com
- Location: Netherlands
- Occupation: farmer
The most recent version of WimBasic now also supports
INPUTLINE#<file>,A$
where it takes all characters, including colon, comma etcetera up to CR.
The maximum recordlength is limited to 88 characters, because the keyboard buffer is used.
Regards,
Wim.
INPUTLINE#<file>,A$
where it takes all characters, including colon, comma etcetera up to CR.
The maximum recordlength is limited to 88 characters, because the keyboard buffer is used.
Regards,
Wim.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
- Diddl
- Vic 20 Afficionado
- Posts: 426
- Joined: Wed Jun 10, 2009 3:18 am
- Website: https://oe7twj.at/
- Location: Austria
- Occupation: software engineer
-
- Vic 20 Afficionado
- Posts: 352
- Joined: Tue Apr 14, 2009 8:15 am
- Website: http://wimbasic.webs.com
- Location: Netherlands
- Occupation: farmer
New version
The most recent version now also supports throwing an error, as in
IF T>40 THEN ERROR 14
or
IF LEN(A$)>10 THEN ERROR 24
Regards,
Wim.
IF T>40 THEN ERROR 14
or
IF LEN(A$)>10 THEN ERROR 24
Regards,
Wim.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
-
- Vic 20 Afficionado
- Posts: 352
- Joined: Tue Apr 14, 2009 8:15 am
- Website: http://wimbasic.webs.com
- Location: Netherlands
- Occupation: farmer
Supportsite
Hello all,
I have raised a support site at http://wimbasic.webs.com.
There is still a few loose ends to fix, but before years' end, this will be done.
Regards,
Wim.
I have raised a support site at http://wimbasic.webs.com.
There is still a few loose ends to fix, but before years' end, this will be done.
Regards,
Wim.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
-
- Vic 20 Afficionado
- Posts: 352
- Joined: Tue Apr 14, 2009 8:15 am
- Website: http://wimbasic.webs.com
- Location: Netherlands
- Occupation: farmer
Speed test
Hello all,
I did some speed testing with CBM Basic and WimBasic using its most optimal features. The case at hand is reversing a string of 255 characters.
In CBM Basic there is only one way to do this and that is to build a new string, taking each of the characters of the original string in the reverse order.
Execution of this program takes 172 ticks,
In WimBasic the same program takes 181 ticks.
Using the left-MID$ function this was brought down to 153 ticks
Applying SuperNumbers to this brings it further down to 148 ticks
And finally, using VARPTR and PEEK/POKE and SuperNumbers scores 110 ticks.
In WimBasic I also tested by not building a new string, but reversing and overwriting the original string:
Using left-MID$ and SuperNumbers this is done in 149 ticks.
Using VARPTR and PEEK/POKE and SuperNumbers this scores 105 ticks
VARPTR and PEEK/POKE scores best, but is a bit tricky when programming.
Left-MID$ and SuperNumbers is safer and beat CBM Basic by 13%. Not bad, eh ?
Regards,
Wim.
I did some speed testing with CBM Basic and WimBasic using its most optimal features. The case at hand is reversing a string of 255 characters.
In CBM Basic there is only one way to do this and that is to build a new string, taking each of the characters of the original string in the reverse order.
Execution of this program takes 172 ticks,
In WimBasic the same program takes 181 ticks.
Using the left-MID$ function this was brought down to 153 ticks
Applying SuperNumbers to this brings it further down to 148 ticks
And finally, using VARPTR and PEEK/POKE and SuperNumbers scores 110 ticks.
In WimBasic I also tested by not building a new string, but reversing and overwriting the original string:
Using left-MID$ and SuperNumbers this is done in 149 ticks.
Using VARPTR and PEEK/POKE and SuperNumbers this scores 105 ticks
VARPTR and PEEK/POKE scores best, but is a bit tricky when programming.
Left-MID$ and SuperNumbers is safer and beat CBM Basic by 13%. Not bad, eh ?
Regards,
Wim.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
- Mike
- Herr VC
- Posts: 4941
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
Re: Speed test
I don't know how your implementation looks like in CBM BASIC, here's mine:wimoos wrote:In CBM Basic there is only one way to do this and that is to build a new string, taking each of the characters of the original string in the reverse order.
Code: Select all
10 Z$="I'M 17 CHARS LONG":Z$=Z$+Z$+Z$+Z$+Z$:Z$=Z$+Z$+Z$
11 T1=TI:FORT=1TOLEN(Z$):A$=MID$(Z$,T,1)+A$:NEXT:T2=TI
12 PRINTT2-T1
-
- Vic 20 Afficionado
- Posts: 352
- Joined: Tue Apr 14, 2009 8:15 am
- Website: http://wimbasic.webs.com
- Location: Netherlands
- Occupation: farmer
oops..
Hello Mike,
Your algorithm is the same as what I tested. I now tried it again and got the same score as you. I think I must have built the string from the other end, so an L-I expression was executed unneccesarily 255 times.
The CBM program is slightly slower in WimBasic, as was to be expected. The other scores are the same as what I first measured and make sense now.
Gaining speed in WimBasic is achieved by using techniques like PEEK/POKE and VARPTR and SuperNumbers (thereby avoiding complex stringhandling and tedious variable search), rather than anything else. This is still 34% better than the CBM version.
Using Left-MID$ makes it possible to reuse stringspace, thus saving memory and costly garbage collections.
Best effort so far is 92 ticks using WimBasic, VARPTR, PEEK/POKE, SuperNumbers and "inplace" reversal.
Thanks for the feedback
Wim.[/code]
Your algorithm is the same as what I tested. I now tried it again and got the same score as you. I think I must have built the string from the other end, so an L-I expression was executed unneccesarily 255 times.
The CBM program is slightly slower in WimBasic, as was to be expected. The other scores are the same as what I first measured and make sense now.
Gaining speed in WimBasic is achieved by using techniques like PEEK/POKE and VARPTR and SuperNumbers (thereby avoiding complex stringhandling and tedious variable search), rather than anything else. This is still 34% better than the CBM version.
Using Left-MID$ makes it possible to reuse stringspace, thus saving memory and costly garbage collections.
Best effort so far is 92 ticks using WimBasic, VARPTR, PEEK/POKE, SuperNumbers and "inplace" reversal.
Code: Select all
10 A$="DIT IS EEN STRING":A$=A$+A$+A$+A$+A$:A$=A$+A$+A$:L=LEN(A$)
20 P=VARPTR(A$):{pound}Q=DEEK(P+1):{pound}R={pound}Q+L-1
30 A=TI
40 FORI=0TOL/2:{pound}X=PEEK({pound}R-I):POKE{pound}R-I,PEEK({pound}Q+I):POKE{pound}Q+I,{pound}X:NEXT
50 PRINT TI-A
60 PRINT A$
Wim.[/code]
Last edited by wimoos on Sun Nov 07, 2010 3:31 pm, edited 1 time in total.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
- Mike
- Herr VC
- Posts: 4941
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
Indeed that variant easily "yields" execution times around 190 ticks, or so. OTOH, the speed limiting factor seems to be the overhead of string concatenation and assignment, so you can't expect the routine to become much faster in BASIC (regardless of pure CBM or slightly enhanced but still general string ops in WimBasic). If string reversal was a cricital bottleneck in a program, that was a candidate for a quick translation to ML, doing an in-place operation.wimoos wrote:I think I must have built the string from the other end, so an L-I expression was executed unneccesarily 255 times.
The string routines in CBM BASIC *are* tuned to quick turn-around times. And still quite compact, with little house-keeping necessary in the average case (without GC).Using Left-MID$ makes it possible to reuse stringspace, thus saving memory and costly garbage collections.
Of course adding a backdescriptor speeds up the GC tremendously with just a small extra memory footprint for each active string (2 bytes). Still, with V2 BASIC you need a least a high 2 figure number of strings for the GC to become easily noticed: in VICtoria Gold for example the fill procedure for the regions in the maps extensively uses data in strings - and stops now and then for 1/2 second in a GC.
If a program needs to handle larger amount of strings, you can always translate those parts to ML, as above. That's what I did with the storage and word-wrap procedures in MG BROWSE. If I had written those routines in BASIC they'd be two orders of magnitude slower, regardless of GC's or not. But string processing in ML is moving data around with no strings attached - much easier to program that in BASIC. And exactly those parts I left in BASIC for the main program of MINIPAINT (preparation of file names for tape/disc access).
Edit:
With an even string length, that FOR loop exchanges the middle two characters twice. The FOR loop should run from 0 to L/2-1 instead.wimoos wrote:Code: Select all
40 FORI=0TOL/2:£X=PEEK(£R-I):POKE£R-I,PEEK(£Q+I):POKE£Q+I,£X:NEXT
-
- Vic 20 Afficionado
- Posts: 352
- Joined: Tue Apr 14, 2009 8:15 am
- Website: http://wimbasic.webs.com
- Location: Netherlands
- Occupation: farmer
New version available
As I couldn't resist, I have made some more improvements to WimBasic. Amongst others:
- Joystick support through the USR() function (as discussed in an earlier post of Mike). USR() returns 0, -1, 1, -22, 22, -23, 23, -21, 21, depending on the position of the joystick. Of course, only as long as the USR vector is unchanged. No support for the fire-button here, unfortunately.
- RESUME <linenumber> now checks for the existence of the line, before processing actually resumes.
Regards,
Wim.
- Joystick support through the USR() function (as discussed in an earlier post of Mike). USR() returns 0, -1, 1, -22, 22, -23, 23, -21, 21, depending on the position of the joystick. Of course, only as long as the USR vector is unchanged. No support for the fire-button here, unfortunately.
- RESUME <linenumber> now checks for the existence of the line, before processing actually resumes.
Regards,
Wim.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic