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

Improved GOTO

Postby wimoos » Fri Mar 12, 2010 3:46 am

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

Postby Diddl » Fri Mar 12, 2010 6:58 am

Very nice!

Mr. Dripke and Mr. Krause would be very astonished how many improvments are done 27 years later ...

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 » Fri Mar 26, 2010 3:43 am

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

New version coming up

Postby wimoos » Wed May 19, 2010 4:02 am

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: 3017
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: New version coming up

Postby Mike » Wed May 19, 2010 4:24 am

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 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 » Wed May 19, 2010 10:49 am

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

Postby wimoos » Mon Jun 14, 2010 1:52 am

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

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

Postby Diddl » Wed Jun 16, 2010 3:24 am

Great!

Especially the MID$() = function!!!! :D

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

Just when you thought it wouldn't be possible

Postby wimoos » Fri Jul 16, 2010 11:03 am

A new version of WimBasic is available.

Lo and behold, I fixed some small bugs (one in INSTR), did some space savings (UNNEW is now called OLD), and found room to put Mike's SQR routine back in !

Regards,

Wim.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic

User avatar
nbla000
Salmon Run
Posts: 2426
Joined: Thu Oct 13, 2005 8:58 am

Postby nbla000 » Fri Jul 16, 2010 11:11 am

It seems that the UNNEW command doesn't work, I'm wrong ?
Mega-Cart: the cartridge you plug in once and for all.

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 » Fri Jul 16, 2010 12:06 pm

While scraping the last few bytes, amongst others I changed the UNNEW command into OLD (see HELP).
When the quest was ended, I still had three bytes to play with, so I changed OLD back to UNNEW and posted a new version online.

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

Postby wimoos » Thu Aug 05, 2010 7:01 am

To give you an example of the improvements I'm doing from Exbasic into Wimbasic, I show you a code fragment "before" and "after". "Before" is 73 bytes, "after" is 69.
This is about the function ROUND(var [,prec]). When [,prec] is specified, the parameter is <prec> times multiplied by 10, 0.5 is added, the integer is taken and the result is divided by 10, <prec> times.
"Before", the multiplications and divisions are done iteratively. "After", this is done recursively. To prevent stack overflow, <prec> is now limited to 7, but hey, who would want more precision ? Do not round off, then.

All in all, I've brought the entire Wimbasic, with all its features, down to 8152 bytes now, without losing any functionality...

Code: Select all

LAF3A   JSR  $CEFA        ; AF3A 20 FA CE
   JSR  $CD8A        ; AF3D 20 8A CD
   JSR  $0079        ; AF40 20 79 00
   CMP  #$29         ; AF43 C9 29   
   BEQ  LAF7A        ; AF45 F0 33   
   JSR  $CE33        ; AF47 20 33 CE
   JSR  $D7F1        ; AF4A 20 F1 D7
   STX  $83          ; AF4D 86 83   
   STX  $84          ; AF4F 86 84   
   LDX  #$00         ; AF51 A2 00   
LAF53   PLA               ; AF53 68       
   STA  $61,X        ; AF54 95 61   
   INX               ; AF56 E8       
   CPX  #$05         ; AF57 E0 05   
   BNE  LAF53        ; AF59 D0 F8   
   BEQ  LAF60        ; AF5B F0 03   
LAF5D   JSR  $DAE2        ; AF5D 20 E2 DA
LAF60   DEC  $83          ; AF60 C6 83   
   BPL  LAF5D        ; AF62 10 F9   
   JSR  $D849        ; AF64 20 49 D8
   JSR  $DCCC        ; AF67 20 CC DC
   JMP  LAF70        ; AF6A 4C 70 AF
LAF6D   JSR  $DAFE        ; AF6D 20 FE DA
LAF70   DEC  $84          ; AF70 C6 84   
   BPL  LAF6D        ; AF72 10 F9   
   PLA               ; AF74 68       
   STA  $66          ; AF75 85 66   
   JMP  $CEF7        ; AF77 4C F7 CE
LAF7A   JSR  $D849        ; AF7A 20 49 D8
   JSR  $DCCC        ; AF7D 20 CC DC
   JMP  $CEF7        ; AF80 4C F7 CE

----

Code: Select all

LAF3A   JSR LGETFLOAT       ; Perform ROUND
   JSR $0079       ;
   CMP #$29       ;
   BEQ LAF7A       ;
   JSR $CE33       ; Put acc.1 on the stack
   JSR $D7F1       ; Check comma and read byte
   CPX #$08
   BCS LAD72
   STX $83       ;
   LDX #$00       ; Pull acc.1 from stack
LAF53   PLA        ;
   STA $61,X       ;
   INX        ;
   CPX #$05       ;
   BNE LAF53       ;
   JSR LAF60       ; do the rounding off
   PLA
   STA $66                   ; pull sign from stack
   JMP $CEF7                ; check closed paranthesis
           
LAF60   DEC $83       ; decrement recursion counter
   BMI LAF5D       ; branch if finished
   JSR $DAE2                ; multiply by 10
   JSR LAF60                 ; recurse
   JMP $DAFE                ; divide by 10

LAF5D   JSR $D849       ; add 0.5
   JMP $DCCC       ; take integer

LAF7A   JSR LAF5D       ; round off once
   JMP $0073       ; parenthesis already checked
           
LAD72   JMP $D248       ; ILLQUANT when precision >7
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic

TNT
Vic 20 Hobbyist
Posts: 120
Joined: Wed Apr 29, 2009 5:46 am

Postby TNT » Thu Aug 05, 2010 5:50 pm

wimoos wrote:

Code: Select all

   LDX #$00       ; Pull acc.1 from stack
LAF53   PLA        ;
   STA $61,X       ;
   INX        ;
   CPX #$05       ;
   BNE LAF53       ;

Code: Select all

   LDX #$FB       ; Pull acc.1 from stack
LAF53   PLA        ;
   STA $66,X       ;
   INX        ;
   BNE LAF53       ;

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 » Fri Aug 06, 2010 12:53 am

Great ! I love bytesavers like that ! Sometimes they're just staring in your face.

:lol:
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 4:45 am

I have been playing around with Wimbasic for a bit and noticed that the color values are 1-8 instead of 0-7. Is that right? Also it gives an illegal quantity error if you go past 8, so multicolor characters are out(or at least have to be done the old fashioned way). I'm assuming that the colors 1-8 go along with the way ExBasic was in its original form.

Later,
Rob


Return to “Programming”

Who is online

Users browsing this forum: toby405 and 4 guests