ehBasic on 65816
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.
8BIT wrote:
The FP issue is corrected. Now, a FOR/NEXT loop will only execute the first pass and then locks up.
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.
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.
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:
Quote:
There may be other routines that depend on ZP wrap around
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.
-
leeeeee
- In Memoriam
- Posts: 347
- Joined: 30 Aug 2002
- Location: UK
- Contact:
- GARTHWILSON
- Forum Moderator
- Posts: 8774
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
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 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:
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.
Guess I'll have to do it again.
Lee.
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'll test more code to ensure I don't have anything else obviously wrong.
Thanks for pointing those out!!!
Daryl
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
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
- BigDumbDinosaur
- Posts: 9427
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re:
faybs wrote:
I'm sorry if this is a dumb question, but why can't one do a pc-relative jsr like this?
That's 100% position independent and takes only 10 cycles, 6 for PER plus 4 for BRL.
Code: Select all
.macro BSR ; Branch to Subroutine
per *+6
brl \0
.endmacroThat'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!