Using and improving Exbasic
Moderator: Moderators
-
- Vic 20 Afficionado
- Posts: 348
- Joined: Tue Apr 14, 2009 8:15 am
- Website: http://wimbasic.webs.com
- Location: Netherlands
- Occupation: farmer
Improved GOTO
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.
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
-
- Vic 20 Afficionado
- Posts: 348
- Joined: Tue Apr 14, 2009 8:15 am
- Website: http://wimbasic.webs.com
- Location: Netherlands
- Occupation: farmer
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.Leeeeee wrote: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.The FE3 Wedge can evaluate HEX values preceeded by a $:It looks nicer than DEC("1B00") for meCode: Select all
A=$1B00:B=$22+$1A+345
It would also be a lot faster than performing DEC("1B00").
Lee.
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
-
- Vic 20 Afficionado
- Posts: 348
- Joined: Tue Apr 14, 2009 8:15 am
- Website: http://wimbasic.webs.com
- Location: Netherlands
- Occupation: farmer
New version coming up
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.
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
- Mike
- Herr VC
- Posts: 4842
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
Re: New version coming up
wimoos wrote:In this version I will remove Mike's optimized SQR routine, in favor of the "leftside MID$-function"!
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$))
-
- Vic 20 Afficionado
- Posts: 348
- Joined: Tue Apr 14, 2009 8:15 am
- Website: http://wimbasic.webs.com
- Location: Netherlands
- Occupation: farmer
New version available
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.
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
-
- Vic 20 Afficionado
- Posts: 348
- Joined: Tue Apr 14, 2009 8:15 am
- Website: http://wimbasic.webs.com
- Location: Netherlands
- Occupation: farmer
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
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
-
- Vic 20 Afficionado
- Posts: 348
- 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
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.
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
-
- Vic 20 Afficionado
- Posts: 348
- Joined: Tue Apr 14, 2009 8:15 am
- Website: http://wimbasic.webs.com
- Location: Netherlands
- Occupation: farmer
-
- Vic 20 Afficionado
- Posts: 348
- Joined: Tue Apr 14, 2009 8:15 am
- Website: http://wimbasic.webs.com
- Location: Netherlands
- Occupation: farmer
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...
----
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
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 ;
-
- Vic 20 Afficionado
- Posts: 348
- Joined: Tue Apr 14, 2009 8:15 am
- Website: http://wimbasic.webs.com
- Location: Netherlands
- Occupation: farmer
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,
Later,
Rob