65C02 Version of EhBasic

A forum for users of EhBASIC (Enhanced BASIC), a portable BASIC interpreter for 6502 microcomputers written by Lee Davison.
User avatar
floobydust
Posts: 1394
Joined: 05 Mar 2013

65C02 Version of EhBasic

Post by floobydust »

I finally got around to finishing up some new updates to my previous CMOS only version of EhBasic. It's based on the latest 2.22p4 from Klaus. To keep it short, some stuff removed, like all IRQ/NMI code, added an EXIT command, streamlined startup code for a RAM test (no user input) and added LOAD/SAVE using the Xmodem-CRC functions in my C02Monitor. The finished code is exactly 9.75KB in size (9984 bytes) and has a few other nice updates as well, like Mike Barry's change to the CHRGET (equivalent) routine, which is a measurable performance improvement. I'll get around to posting my latest version 2.03 C02BIOS and C02Monitor code shortly, which is what this version of EhBasic works with.

If anyone would like to use it with a different BIOS/Monitor, modifications should be very minimal. Hope others find it useful. Enjoy!
EhBasic.zip
(210.04 KiB) Downloaded 467 times
User avatar
drogon
Posts: 1671
Joined: 14 Feb 2018
Location: Scotland
Contact:

Re: 65C02 Version of EhBasic

Post by drogon »

floobydust wrote:
I finally got around to finishing up some new updates to my previous CMOS only version of EhBasic. It's based on the latest 2.22p4 from Klaus. To keep it short, some stuff removed, like all IRQ/NMI code, added an EXIT command, streamlined startup code for a RAM test (no user input) and added LOAD/SAVE using the Xmodem-CRC functions in my C02Monitor. The finished code is exactly 9.75KB in size (9984 bytes) and has a few other nice updates as well, like Mike Barry's change to the CHRGET (equivalent) routine, which is a measurable performance improvement. I'll get around to posting my latest version 2.03 C02BIOS and C02Monitor code shortly, which is what this version of EhBasic works with.

If anyone would like to use it with a different BIOS/Monitor, modifications should be very minimal. Hope others find it useful. Enjoy!
EhBasic.zip
Thanks! Been using your earlier version without issues on my Ruby 65C02 system - might find time to test this, but I'm quite far down the 65816 route now with BBC Basic being my preferred "BASIC" for now.

Cheers,

-Gordon
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/
User avatar
floobydust
Posts: 1394
Joined: 05 Mar 2013

Re: 65C02 Version of EhBasic

Post by floobydust »

Thanks Gordon.

Simple changes... modified memory test, Load and Save vectors handle everything sans the actual Xmodem transfer and Mike Barry’s change makes it a tiny bit quicker. Can’t see having anything broken from the previous version, albeit some of the error messages are shorter, i.e., without goes to w/o.
jgharston
Posts: 181
Joined: 22 Feb 2004

Re: 65C02 Version of EhBasic

Post by jgharston »

All the updates to ehBasic are sub-sub-versions of 2.22: 2.22, 2.22patch, 2.22patch2, 2.22patch3, 2.22patch4variantC. Shouldn't there be a co-ordinated rollover to 2.23? or 2.30?
User avatar
floobydust
Posts: 1394
Joined: 05 Mar 2013

Re: 65C02 Version of EhBasic

Post by floobydust »

jgharston wrote:
All the updates to ehBasic are sub-sub-versions of 2.22: 2.22, 2.22patch, 2.22patch2, 2.22patch3, 2.22patch4variantC. Shouldn't there be a co-ordinated rollover to 2.23? or 2.30?
That's likely a good idea, however, I don't consider myself an owner and/or maintainer of any of the Enhanced Basic versions.

The CMOS version I've done is more for my own use, which is limited. It doesn't really contain any new commands, sans the EXIT command that goes back to my Monitor. I've also deleted some of the code which, according to Klaus, didn't really work properly, like the IRQ and NMI functions. All of the other changes are to reduce code size, gain a slight performance advantage and make it easier to move between 65C02 systems.

Perhaps some of the other players out here could chime in on a possible version change, I simply added the "C" to the version to specify that it's a CMOS only version.
jgharston
Posts: 181
Joined: 22 Feb 2004

Re: 65C02 Version of EhBasic

Post by jgharston »

floobydust wrote:
jgharston wrote:
All the updates to ehBasic are sub-sub-versions of 2.22: 2.22, 2.22patch, 2.22patch2, 2.22patch3, 2.22patch4variantC. Shouldn't there be a co-ordinated rollover to 2.23? or 2.30?
That's likely a good idea, however, I don't consider myself an owner and/or maintainer of any of the Enhanced Basic versions.

The CMOS version I've done is more for my own use, which is limited. It doesn't really contain any new commands, sans the EXIT command that goes back to my Monitor. I've also deleted some of the code which, according to Klaus, didn't really work properly, like the IRQ and NMI functions. All of the other changes are to reduce code size, gain a slight performance advantage and make it easier to move between 65C02 systems.

Perhaps some of the other players out here could chime in on a possible version change, I simply added the "C" to the version to specify that it's a CMOS only version.
By removing the tokens related to IRQ and NMI, you've made almost all the token numbers change, so a program saved on p4C won't load on non-p4C and vice versa. If you're going to remove the functionality of IRQ, RETIRQ, NMI, RETNMI, OFF you should do it by removing the code, not by removing the token numbers. So, your code should still have:

Code: Select all

TK_RESTORE        = TK_IF+1         ; RESTORE token
TK_GOSUB          = TK_RESTORE+1    ; GOSUB token
TK_RETIRQ         = TK_GOSUB+1      ; RETIRQ token
TK_RETNMI         = TK_RETIRQ+1     ; RETNMI token
TK_RETURN         = TK_RETNMI+1     ; RETURN token
and the dispatch table something like:

Code: Select all

      .word LAB_GOSUB-1       ; GOSUB
      .word SYNTAX_ERROR
      .word SYNTAX_ERROR
      .word LAB_RETURN-1      ; RETURN
Otherwise, for example, a program with PRINT "Hello" saved from non-p4C when loaded to p4C will say LIST "Hello".
jgharston
Posts: 181
Joined: 22 Feb 2004

Re: 65C02 Version of EhBasic

Post by jgharston »

floobydust wrote:
jgharston wrote:
The CMOS version I've done is more for my own use, which is limited. It doesn't really contain any new commands, sans the EXIT command that goes back to my Monitor.
In BASICs EXIT typically exits a program structure, you exit the BASIC itself with QUIT. Eg:

Code: Select all

FOR A=1 TO 10
  IF A=5 THEN EXIT:REM Drop out of FOR/NEXT loop
  PRINT A
NEXT A
QUIT:REM Quit BASIC, return to caller/monitor/etc
User avatar
floobydust
Posts: 1394
Joined: 05 Mar 2013

Re: 65C02 Version of EhBasic

Post by floobydust »

jgharston wrote:
floobydust wrote:
jgharston wrote:
All the updates to ehBasic are sub-sub-versions of 2.22: 2.22, 2.22patch, 2.22patch2, 2.22patch3, 2.22patch4variantC. Shouldn't there be a co-ordinated rollover to 2.23? or 2.30?
That's likely a good idea, however, I don't consider myself an owner and/or maintainer of any of the Enhanced Basic versions.

The CMOS version I've done is more for my own use, which is limited. It doesn't really contain any new commands, sans the EXIT command that goes back to my Monitor. I've also deleted some of the code which, according to Klaus, didn't really work properly, like the IRQ and NMI functions. All of the other changes are to reduce code size, gain a slight performance advantage and make it easier to move between 65C02 systems.

Perhaps some of the other players out here could chime in on a possible version change, I simply added the "C" to the version to specify that it's a CMOS only version.
By removing the tokens related to IRQ and NMI, you've made almost all the token numbers change, so a program saved on p4C won't load on non-p4C and vice versa. If you're going to remove the functionality of IRQ, RETIRQ, NMI, RETNMI, OFF you should do it by removing the code, not by removing the token numbers. So, your code should still have:

Code: Select all

TK_RESTORE        = TK_IF+1         ; RESTORE token
TK_GOSUB          = TK_RESTORE+1    ; GOSUB token
TK_RETIRQ         = TK_GOSUB+1      ; RETIRQ token
TK_RETNMI         = TK_RETIRQ+1     ; RETNMI token
TK_RETURN         = TK_RETNMI+1     ; RETURN token
and the dispatch table something like:

Code: Select all

      .word LAB_GOSUB-1       ; GOSUB
      .word SYNTAX_ERROR
      .word SYNTAX_ERROR
      .word LAB_RETURN-1      ; RETURN
Otherwise, for example, a program with PRINT "Hello" saved from non-p4C when loaded to p4C will say LIST "Hello".
All valid points... but again, the changes made were for my own use. Also, as LOAD and SAVE were never really implemented in the base code, Lee suggested that intercepting the LIST command for SAVE would be his preferred method as it would be an ASCII file, which would be easier to examine, edit and LOAD into other BASIC implementations. But I understand your points and they're completely valid.

Also, on the EXIT vs QUIT (another valid point). As EhBasic doesn't have an EXIT command, picking EXIT was a choice, which can be easily changed.

Adding in the older tokens to preserve the original token numbers can be easily done of course. It's unclear how valuable it would be, beyond declaring full token compatibility with the original 2.22 source.
User avatar
barrym95838
Posts: 2056
Joined: 30 Jun 2013
Location: Sacramento, CA, USA

Re: 65C02 Version of EhBasic

Post by barrym95838 »

I have been running into the same quandary regarding version numbers (or letters) on my VTL02. I have been intermittently fiddling with version C, squeezing a few bytes here and there, but I haven't added any new features, so I don't want to release anything as version D until I have enough space inside 1K to add something noticeable to the end user. Also, many of my source changes have been untested, because SBASM3 uses Python, and assembling stuff with it isn't as fun as I thought it would be on Windoze.
Got a kilobyte lying fallow in your 65xx's memory map? Sprinkle some VTL02C on it and see how it grows on you!

Mike B. (about me) (learning how to github)
jgharston
Posts: 181
Joined: 22 Feb 2004

Re: 65C02 Version of EhBasic

Post by jgharston »

barrym95838 wrote:
I have been running into the same quandary regarding version numbers (or letters) on my VTL02. I have been intermittently fiddling with version C, squeezing a few bytes here and there, but I haven't added any new features, so I don't want to release anything as version D until I have enough space inside 1K to add something noticeable to the end user. Also, many of my source changes have been untested, because SBASM3 uses Python, and assembling stuff with it isn't as fun as I thought it would be on Windoze.
My parallel fork I've ended up having to call it v2.22p4a !
User avatar
drogon
Posts: 1671
Joined: 14 Feb 2018
Location: Scotland
Contact:

Re: 65C02 Version of EhBasic

Post by drogon »

floobydust wrote:
All valid points... but again, the changes made were for my own use. Also, as LOAD and SAVE were never really implemented in the base code, Lee suggested that intercepting the LIST command for SAVE would be his preferred method as it would be an ASCII file, which would be easier to examine, edit and LOAD into other BASIC implementations. But I understand your points and they're completely valid.
For my use, I ignored SAVE (and LOAD) and treated it as write-only, to the point that I use a text editor to write the small ehBasic programs I've written so-far, then *EXEC them into ehBasic. This is a command borrowed from Acorn land which allows keyboard input to come from a file. similarly, when I've made a few changes, then *SPOOL then list, then tweak it in a text editor...
floobydust wrote:
Also, on the EXIT vs QUIT (another valid point). As EhBasic doesn't have an EXIT command, picking EXIT was a choice, which can be easily changed.
Or *REBOOT in my system... (sorry - the advantages of having what might be considered an operating system vs. a "monitor")

-Gordon
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/
User avatar
floobydust
Posts: 1394
Joined: 05 Mar 2013

Re: 65C02 Version of EhBasic

Post by floobydust »

drogon wrote:
floobydust wrote:
All valid points... but again, the changes made were for my own use. Also, as LOAD and SAVE were never really implemented in the base code, Lee suggested that intercepting the LIST command for SAVE would be his preferred method as it would be an ASCII file, which would be easier to examine, edit and LOAD into other BASIC implementations. But I understand your points and they're completely valid.
For my use, I ignored SAVE (and LOAD) and treated it as write-only, to the point that I use a text editor to write the small ehBasic programs I've written so-far, then *EXEC them into ehBasic. This is a command borrowed from Acorn land which allows keyboard input to come from a file. similarly, when I've made a few changes, then *SPOOL then list, then tweak it in a text editor...
floobydust wrote:
Also, on the EXIT vs QUIT (another valid point). As EhBasic doesn't have an EXIT command, picking EXIT was a choice, which can be easily changed.
Or *REBOOT in my system... (sorry - the advantages of having what might be considered an operating system vs. a "monitor")

-Gordon
I've also been using a text editor for simple basic programs. Using the Serial terminal program (OSX), I just can just copy and paste the program into the terminal window for loading. Doing a LIST, then copy/paste also allows saving a program as text. Enabling LOAD and SAVE seemed like a nice idea...

While my Monitor isn't considered an OS, it does provide a RESET function (does a cold start). It also has a large amount of function for a Monitor... which is pretty handy at times.

************************************************************
Memory Ops: [C]ompare, [D]isplay, [E]dit, [F]ill, [G]o Exec,
[H]ex Find, nput Text, [M]ove, [T]ext Find

Register Ops: R,A,X,Y,S,P

Counter/Timer Ops: ,= set ms|mult, .= exe ms, /= exe ms*mult, \= exe (?)*ms*mult
enchmark clear/start, [Q]uit benchmark/display elapsed time

Macro: (= Init )= Run

CTRL[?]: [A]ssemble, asic, [D]isassemble, [E]dit EEPROM, [L]oad, [P]rogram,
[Q]uery Cmds ,[R]eset, [S]ave, [T]ime up, [V]ersion, [Z]ero RAM/Reset

************************************************************
Unfortunately, the Assembler isn't finished yet.... actually, I haven't started working on it yet, so that one is a place holder :shock:
User avatar
floobydust
Posts: 1394
Joined: 05 Mar 2013

Re: 65C02 Version of EhBasic

Post by floobydust »

As Klaus has implemented some updates to EhBasic (resulting in 2.22p5), I've added these updates to my CMOS version as well. Attached is a zip file with the updated version.
EhBasic-222p5c.zip
(209.24 KiB) Downloaded 311 times
User avatar
barrym95838
Posts: 2056
Joined: 30 Jun 2013
Location: Sacramento, CA, USA

Re: 65C02 Version of EhBasic

Post by barrym95838 »

Hey, thanks for the shout-out on line 7440! :) Your assembler is going to have the Rockwell BBSx/BBRx/RMBx/SMBx stuff too, right?
Got a kilobyte lying fallow in your 65xx's memory map? Sprinkle some VTL02C on it and see how it grows on you!

Mike B. (about me) (learning how to github)
User avatar
floobydust
Posts: 1394
Joined: 05 Mar 2013

Re: 65C02 Version of EhBasic

Post by floobydust »

barrym95838 wrote:
Hey, thanks for the shout-out on line 7440! :) Your assembler is going to have the Rockwell BBSx/BBRx/RMBx/SMBx stuff too, right?
Hey, thanks for the code update, it does save some execution time! I use the WDC Tools package. The WDC W65C02 supports all of the Rockwell enhancements plus STOP (STP) and WAIT (WAI) opcodes. I use a lot of those instructions in my current BIOS and Monitor versions.

Adding this line to the source code enables ALL of the extended opcodes and addressing modes:

CHIP W65C02S ;Enable WDC 65C02 instructions
Post Reply