Using and improving Exbasic

Basic and Machine Language

Moderator: Moderators

wimoos
Vic 20 Devotee
Posts: 245
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

Postby wimoos » Sun Sep 26, 2010 4:52 am

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.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic

User avatar
GreyGhost
Vic 20 Nerd
Posts: 515
Joined: Wed Oct 05, 2005 11:10 pm

Postby GreyGhost » Sun Sep 26, 2010 7:48 am

Code: Select all

5 a=0
10 coke a, 81, a
20 a = a + 1
30 if a > 255 then end
40 goto 10


I was expecting the wrap around effect as with normal basic. I guess it doesn't work like that in WimBasic. It throws the error message immediately.
Rob

wimoos
Vic 20 Devotee
Posts: 245
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

Postby wimoos » Sun Sep 26, 2010 8:21 am

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.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic

User avatar
GreyGhost
Vic 20 Nerd
Posts: 515
Joined: Wed Oct 05, 2005 11:10 pm

Postby GreyGhost » Sun Sep 26, 2010 9:25 am

Understood, that's not a problem. Keep up the great work.
Rob

wimoos
Vic 20 Devotee
Posts: 245
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

New version with SuperNumbers

Postby wimoos » Tue Sep 28, 2010 3:28 am

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.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic

User avatar
Mike
Herr VC
Posts: 3026
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: New version with SuperNumbers

Postby Mike » Tue Sep 28, 2010 10:59 am

wimoos wrote:- They may not be used as a loopcounter in FOR..NEXT

... 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
Vic 20 Devotee
Posts: 245
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

Postby wimoos » Mon Oct 04, 2010 8:05 am

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.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic

Diddl
Vic 20 Afficionado
Posts: 425
Joined: Wed Jun 10, 2009 3:18 am

Postby Diddl » Mon Oct 04, 2010 11:51 am

Very nice!! I missed this always since I know QuickBasic.

wimoos
Vic 20 Devotee
Posts: 245
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

New version

Postby wimoos » Fri Oct 08, 2010 12:32 pm

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.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic

wimoos
Vic 20 Devotee
Posts: 245
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

Supportsite

Postby wimoos » Tue Oct 26, 2010 5:35 am

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.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic

wimoos
Vic 20 Devotee
Posts: 245
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

Speed test

Postby wimoos » Sun Nov 07, 2010 9:24 am

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.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic

User avatar
Mike
Herr VC
Posts: 3026
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Speed test

Postby Mike » Sun Nov 07, 2010 10:43 am

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.

I don't know how your implementation looks like in CBM BASIC, here's mine:

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

139 ticks.

wimoos
Vic 20 Devotee
Posts: 245
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

oops..

Postby wimoos » Sun Nov 07, 2010 12:33 pm

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.

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$



Thanks for the feedback

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

User avatar
Mike
Herr VC
Posts: 3026
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Postby Mike » Sun Nov 07, 2010 3:26 pm

wimoos wrote:I think I must have built the string from the other end, so an L-I expression was executed unneccesarily 255 times.

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.

Using Left-MID$ makes it possible to reuse stringspace, thus saving memory and costly garbage collections.

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).

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:
wimoos wrote:

Code: Select all

40 FORI=0TOL/2:£X=PEEK(£R-I):POKE£R-I,PEEK(£Q+I):POKE£Q+I,£X:NEXT

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
Vic 20 Devotee
Posts: 245
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

New version available

Postby wimoos » Sun Jan 16, 2011 9:00 am

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.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests