Using and improving Exbasic

Basic and Machine Language

Moderator: Moderators

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

Post by Mike »

Pedro Lambrini wrote:Is all this work on Exbasic simply an academic excercise (not to diminish your work!) or is there real benefits to using this instead of Basic 2.0? As I'm starting to write Basic programs after decades in the wilderness I'm just a little curious. :)
In principle, you can express every program idea within BASIC 2.0.

BASIC extensions shine, where that algorithm either would run too slow in BASIC, or would need comparatively a lot of statements. If that function could be expressed with a short name, maybe with some parameters, BASIC extensions add this to the pool of available commands.

The speed advantage is there, because the same algorithm now is executed in machine language within the extension. The space advantage is a two-folded sword - within the BASIC listing you now only see the new command, with arguments as necessary. Of course the ML translation within the extension now needs space as well, typically in the same order is if the command had been expressed as subroutine within the BASIC program.

Some BASIC extensions try to be all-rounders, remedying many (sometimes only perceived) deficiencies of BASIC 2.0 regarding program flow structures (adding IF ... THEN ... ELSE, REPEAT ... UNTIL, DEF PROC, CALL: like Waterloo BASIC), easing screen manipulation, and sound (ExBASIC has some commands there), programming help (RENUMBER, AUTO, function keys: Programmers' Aid), or bitmapped graphics (Super Expander).

Others gain their usefulness by being specialised on a single task, but within small and compact code, like MINIGRAFIK does for hires graphics. :)

Greetings,

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

Post by wimoos »

Yes, I need a drink, academic of course, after all these hours...

But seriously, I keep two versions:

- one is Exbasic for VIC, with a lot of bugs fixed
- the other is Wimbasic, where I develop my own adaptions

If you need Exbasic.prg please let me know. I have regenerated a source file through disassembly, so in theory this can be assembled on a location other than $A000.

@Anders: it's 1983 ! Who is Britney Spears ?
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
wimoos
Vic 20 Afficionado
Posts: 346
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

Bug in MAX() and MIN()

Post by wimoos »

Talk about academic...

In Exbasic, MIN() and MAX() are not recursive. That is, an expression like: A=MIN(4,MIN(8,9)) should give 4, but it gives 8.
Of course, in this case the error can be prevented by using: A=MIN(4,8,9).

But, when an expression like A=MIN(4,MAX(8,9)) is used, the result will be 9, where it should be 4. This can only be prevented by splitting it up in two statements.

In Wimbasic I have now solved this by keeping the running value, together with the operator, on the stack.

A working example could be: A=MAX(0,MIN(16,A)) to limit A in the range 0..16.


Regards,

Wim.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
wimoos
Vic 20 Afficionado
Posts: 346
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

New version available

Post by wimoos »

A new version of Wimbasic is now available at

http://home.kpn.nl/oost4231/wimbasic.zip

I brought it back to 8131 bytes and this version contains the following improvements:

; FIXED MIN AND MAX TO BE RECURSIVE
; HELP SCROLLS ONE LINE INSTEAD OF FOUR
; PARAMETER CHECKING ON CEEK AND COKE (0..511)

Regards,

Wim.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
Diddl
Vic 20 Afficionado
Posts: 425
Joined: Wed Jun 10, 2009 3:18 am

Post by Diddl »

Thank you wimoos, wimbasic is great! :D
wimoos
Vic 20 Afficionado
Posts: 346
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

Full support for hexbased and binary entry

Post by wimoos »

Found some more optimizations and I built in full support for hexbased and binary based value entry.

Wimbasic now can deal with the following expression:

X=XOR($4DEF,%1101)

Regards,

Wim.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
wimoos
Vic 20 Afficionado
Posts: 346
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

New version available

Post by wimoos »

This new version has more code improvements and the following fixes:

; FIXED DEEK AND CEEK TO BE RECURSIVE
; IMPROVED '.' HANDLING FOR GOTO, THEN, ELSE, RUN AND LIST

Regards,

Wim.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
Diddl
Vic 20 Afficionado
Posts: 425
Joined: Wed Jun 10, 2009 3:18 am

Re: New version available

Post by Diddl »

wimoos wrote:This new version has more code improvements and the following fixes:

; FIXED DEEK AND CEEK TO BE RECURSIVE
; IMPROVED '.' HANDLING FOR GOTO, THEN, ELSE, RUN AND LIST

Regards,

Wim.
Could you explain more detailed about tthis improvements. Is this a better coding with same results or did you make a faster GOTO or another implementation?
wimoos
Vic 20 Afficionado
Posts: 346
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

Improved GOTO

Post by wimoos »

I found that in the original Exbasic implementation a GOTO. would go to the line specified in OLDLIN. Though, after the GOTO executed, OLDLIN contains the number of the line following the line that contains the GOTO.

Are you following ? I found that, when in a loop, the second time GOTO. jumped to the next line instead of the current.

I fixed this by referencing CURLIN and only when in direct mode (CURLIN+1 contains $FF), reference OLDLIN.

Also, at some other point, OLDLIN is synced with CURLIN. But when there are no Exbasic statements used in the loop, the sync is not done. I removed the sync (to save bytes and cycles), because my fix works flawlessly.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
Diddl
Vic 20 Afficionado
Posts: 425
Joined: Wed Jun 10, 2009 3:18 am

Post by Diddl »

Very nice!

Mr. Dripke and Mr. Krause would be very astonished how many improvments are done 27 years later ...
wimoos
Vic 20 Afficionado
Posts: 346
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

Post by wimoos »

Leeeeee wrote:
The FE3 Wedge can evaluate HEX values preceeded by a $:

Code: Select all

 A=$1B00:B=$22+$1A+345
It looks nicer than DEC("1B00") for me
That should be do-able along with the % prefix for binary values. It's juat a case of some new code and changing the address for the get value from BASIC line vector.

It would also be a lot faster than performing DEC("1B00").

Lee.
I did some testing for speed on this. A=$7F is almost twice as fast as A=127. For any decimal integer value over 99, the hex equivalent is faster.
I also tested A=$ and A=% against A=. but the latter is still quicker.

The only use for DEC("1B00") is when you want to use it with an arbitrary string. In that case you'd have to use EVAL("$"+A$), which is definitely slower, but it works.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
wimoos
Vic 20 Afficionado
Posts: 346
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

New version coming up

Post by wimoos »

I will make a new version of Wimbasic available shortly.

In this version I will remove Mike's optimized SQR routine, in favor of the "leftside MID$-function" !

A pièce de resistance that was the one missing thing from the Level 2 Basic that I knew from the TRS-80.

What it does is replace (part of) an existing string with another string. Example:

10 A$="LEFTSIDE"
20 MID$(A$,5,4)="HAND"
30 PRINT A$

Result: LEFTHAND

How 'bout that ?

Wim.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
User avatar
Mike
Herr VC
Posts: 4831
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: New version coming up

Post by Mike »

wimoos wrote:In this version I will remove Mike's optimized SQR routine, in favor of the "leftside MID$-function"!
:cry:

But then, MID$(A$,M,N)=B$ surely is more compact to write than A$=LEFT$(LEFT$(A$,M-1)+LEFT$(B$,N)+MID$(A$,M+LEN(LEFT$(B$,N))),LEN(A$))

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

New version available

Post by wimoos »

I'm sorry to leave your routine out, Mike. But as it doesn't provide extra functionality it was the easiest thing to do.

Another advantage of the left MID$ function is that the replacement is done "in-place", so there'll be less garbage collections (!)

Anyways, I have put the new version online and I'll leave it like this for a while. Maybe next winter I'll have more time to put into this thing.

Regards,

Wim.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
wimoos
Vic 20 Afficionado
Posts: 346
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

Post by wimoos »

To recap what Wimbasic actually is:

Revived Exbasic L2 CBM Basic extension for VIC20, with:
- More than a dozen bugs fixed
- A lot of code improvements
- Removed HARDCOPY and DEC()
- Added UNNEW and XOR()
- Added support for hexadecimal and binary radix
- Added the left-MID$() function

ASM and PRG are available at http://home.kpn.nl/oost4231/wimbasic.zip
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
Post Reply