ehBasic on 65816

A forum for users of EhBASIC (Enhanced BASIC), a portable BASIC interpreter for 6502 microcomputers written by Lee Davison.
kc5tja
Posts: 1706
Joined: 04 Jan 2003

Post by kc5tja »

I know the feeling. This is why I no longer write any code without using test-driven development OR apply formal methods to help back me up. I won't even consider software that is not written using at least a modular approach.
DaveK
Posts: 34
Joined: 30 Aug 2008
Location: Kent, UK

Post by DaveK »

I noticed some math issues when I tried Daryl's version earlier in the thread. I made a little program to print a sine wave to the terminal, which worked with the simulator and my own 6502 SBC, but not on the SBC-3- random dots everywhere. On further investigation the variable in which I was counting the angle, that should have been having a certain amount added each time, was coming up with something completely different.
User avatar
dclxvi
Posts: 362
Joined: 11 Mar 2004

Post by dclxvi »

8BIT wrote:
The FP issue is corrected. Now, a FOR/NEXT loop will only execute the first pass and then locks up.
One of the other threads reminded me that the FP routines depend on ZP page boundary wrap around, and native mode has no page boundary wrap around. There may be other routines that depend on ZP wrap around as well -- I haven't looked at the EhBASIC source in a while.

FOR/NEXT uses the stack, so if you didn't disable your native mode TXS fix when you went back to emulation mode, that may be causing some difficulties. Just a thought.
User avatar
8BIT
Posts: 1787
Joined: 30 Aug 2002
Location: Sacramento, CA
Contact:

Post by 8BIT »

Yes, when I tried the emulation mode, I did put the TXS's back in, so the stack operations should have been ok. Its possible there was some zero page wrap, but since it is not documented with the zero page definitions, I don't know for sure. I had also relocated some of the zp variables as they had been conflicting with the System Monitor variables, cause jumps from one to the other to fail.

I think there must be some differences between emulation mode and native mode addressing that are coming into play. When I finish the other projects on my pile, I may revisit this and dig deeper.
leeeeee
In Memoriam
Posts: 347
Joined: 30 Aug 2002
Location: UK
Contact:

Post by leeeeee »

Quote:
There may be other routines that depend on ZP wrap around
I don't think there ever were any routines in EhBASIC that depended on ZP wrap around. There aren't any now, if there were I'm sure it would break on microcontrollers that don't fill ZP with RAM.

The problems may still be stack related. NEXT copies the stack pointer to X and uses absolute indexed addressing, $0100,X, to access the FOR NEXT values on the stack. LOOP and DIM also access the stack like this.

There is also a direct access to the stack used when the stack is flushed during CLEAR.

Lee.
User avatar
8BIT
Posts: 1787
Joined: 30 Aug 2002
Location: Sacramento, CA
Contact:

Post by 8BIT »

Thanks Lee, I'll recheck both of those situations. I believe I found all the absolute, x references, but its worth a second look.

Daryl
DaveK
Posts: 34
Joined: 30 Aug 2008
Location: Kent, UK

Post by DaveK »

Anyone know of a comparable BASIC for 6809/6309? I need something to run on my 6309 board.
leeeeee
In Memoriam
Posts: 347
Joined: 30 Aug 2002
Location: UK
Contact:

Post by leeeeee »

Do you know of a decent Win32 6809 emulator?

Lee.
User avatar
GARTHWILSON
Forum Moderator
Posts: 8775
Joined: 30 Aug 2002
Location: Southern California
Contact:

Post by GARTHWILSON »

Lee, I can't believe you're still using Windows! :wink: I just Yahoo'ed "Linux 6809 simulator" and got 14,000 results.
kc5tja
Posts: 1706
Joined: 04 Jan 2003

Post by kc5tja »

24,500 for Win32 emulator.

But, why not just use a TRS-80 CoCo emulator for your development? That's a 6809-based system ready-made for you. I'm pretty sure there'll be tons of those.
User avatar
dclxvi
Posts: 362
Joined: 11 Mar 2004

Post by dclxvi »

leeeeee wrote:
I don't think there ever were any routines in EhBASIC that depended on ZP wrap around. There aren't any now, if there were I'm sure it would break on microcontrollers that don't fill ZP with RAM.
The STA expneg+1,X instruction near LAB_1238 and the STA FACt_3,X instruction at LAB_2701 both depend on ZP wrap around. I was thinking there were more instances than that, but after grabbing the latest code from the website, those were only two I could find. (I suppose I could've actually looked at the source code before running my mouth, but what's the fun in that? :)) Anyway, those two instructions won't work in native mode, so that should be a fairly easy fix.

The other thing to keep in mind in emulation mode is to make sure that the direct page starts on a page boundary (i.e. the D register = $XX00); if not, there is no ZP wrap around even in emulation mode. I haven't run EhBASIC on a 65816 in emulation mode in quite some time, but I didn't really have any trouble getting it up and running.
leeeeee
In Memoriam
Posts: 347
Joined: 30 Aug 2002
Location: UK
Contact:

Post by leeeeee »

Quote:
The STA expneg+1,X instruction near LAB_1238 and the STA FACt_3,X instruction at LAB_2701 both depend on ZP wrap around.
Oh bother! I fixed both those back in V1.something because neither worked on the GEC version of the 6502 core used in a DMAC conditional access module. I must have neglected to integrate the fixes back into the main source.

Guess I'll have to do it again.

Lee.
User avatar
8BIT
Posts: 1787
Joined: 30 Aug 2002
Location: Sacramento, CA
Contact:

Post by 8BIT »

dclxvi wrote:
The STA expneg+1,X instruction near LAB_1238 and the STA FACt_3,X instruction at LAB_2701 both depend on ZP wrap around. I was thinking there were more instances than that, but after grabbing the latest code from the website, those were only two I could find. (I suppose I could've actually looked at the source code before running my mouth, but what's the fun in that? :)) Anyway, those two instructions won't work in native mode, so that should be a fairly easy fix.
I modified the Native Mode code I created and can now get proper values for x^2 as well as the For/Next loop working.

I'll test more code to ensure I don't have anything else obviously wrong.

Thanks for pointing those out!!!

Daryl
User avatar
8BIT
Posts: 1787
Joined: 30 Aug 2002
Location: Sacramento, CA
Contact:

Post by 8BIT »

I have the completed binary and source files on my website for EhBASIC running in Native mode on my SBC-3.

There is a text file with a list of all the changes made to the original source file.

There is also a readme file with instructions on loading EhBASIC on the SBC-3, cold start, warm start, LOAD and SAVE procedures.

There is a demo file that contains a small program.

Enjoy!

http://sbc.rictor.org/download/EhBASIC.zip

Daryl
User avatar
BigDumbDinosaur
Posts: 9428
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re:

Post by BigDumbDinosaur »

faybs wrote:
I'm sorry if this is a dumb question, but why can't one do a pc-relative jsr like this?

Code: Select all

.macro BSR  ; Branch to Subroutine
  per *+6
  brl \0
.endmacro

That's 100% position independent and takes only 10 cycles, 6 for PER plus 4 for BRL.

It's also incorrect and will cause a return to the wrong place. I happened to see this while looking at something else concerning EhBasic and thought it would be a good idea to correct it. My '816 macros correctly implement BSR.
x86?  We ain't got no x86.  We don't NEED no stinking x86!
Post Reply