6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu May 30, 2024 2:38 am

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Sat May 15, 2021 2:01 am 
Offline

Joined: Thu May 13, 2021 12:53 pm
Posts: 16
Location: Fargo, North Dakota
I am struggling with trying to get SYM BASIC to run on my custom board and am looking for suggestions.

My board has:
- 6502 at 1 Mhz
- RAM at $0000-$1FFF
- EEPROM for monitor at $E000-$FFFF
- 6551 for serial IO at $8000
- EEPROM for 8K BASIC at $C000-$DFFF

The monitor program is a very simplified version of the SYM-1 monitor.
It has simple commands for viewing/editing memory and for starting execution at an address.
The board/monitor seem to work fine with a terminal emulator TERATERM (serial-USB converter).
I can view and edit memory fine as well as run small hand assembled programs.

I looked at the disassembly listing for SYM BASIC (from Davidson) and found the SYM monitor routines it uses.

Code:
LAB_8275   = $8275      ; ASCNIB convert chr to binary, Cb=0 if valid hex chr
LAB_8386   = $8386      ; INSTAT - see if key down, result in carry,  waits for release
LAB_8A1B   = $8A1B      ; INCHR - scan input device
LAB_8A47   = $8A47      ; OUTCHR - byte to output device
LAB_8B86   = $8B86      ; ACCESS - un write protect system RAM
LAB_8C78   = $8C78      ; LOAD routine ; LOADT ENTER W/ID IN PARM 2, MODE IN [Y]
LAB_8E87   = $8E87      ; SAVE routine


I added routines in my monitor program to perform the same functions.
I have not implemented the LOAD and SAVE yet though.
And since I do not have write protection on any RAM, the ACCESS routine is not needed.

I located the spots in the BASIC ROM image where the routines are called as follows:

Code:
$C38F   JSR INCHR
$C98B   JSR OUTCHR
$C619   JSR INSTAT
$CE2B   JSR ASCNIB
$CE34   JSR ASNIB
$DE6D     JSR ACCESS


I loaded the BASIC ROM image into a hex editor and put in the addresses of my monitor routines at the appropriate spots.
The EEPROM was then programmed and installed in my board.

Doing a G C000 results in the printing of MEMORY SIZE ? as it should.
Hitting enter at that point results in printing ? SN ERROR and it prompts for MEMORY SIZE again.
It will accept other chars until you press enter, then it throws the same error.

From my monitor I can view the memory of the BASIC EPROM and it appears that it has the correct contents.

I'm wondering what exactly BASIC expects from the monitor routines.

Currently my routines are:
INCHR - waits for an input char and returns (RTS) with the character in A.
INSTAT - checks to see if there is a char available. If no char is available it returns (RTS) with carry clear.
If there is a char, it returns with carry set and character in A.
ASCNIB - converts ASCII char in A to a hex nibble and returns (RTS) with value in A.
OUTCHR - sends out the character in A.
ACCESS - just set to NOPs in the EEPROM.

Since it seems to print output ok I believe the OUTCHR routine is working.
It appears that something is not quite right with INCHR.
Even though the input works when in the monitor.
I've tried about everything I can think of but can't seem to get past the MEMORY SIZE prompt.

My INCHR routine
Code:
Inchar:   lda UARTStatus
   and #$08
   beq Inchar      // wait for receive buffer to be full
   lda UARTData      // get char
   rts


Has anyone been successful in getting SYM BASIC to run on their board?

Any tips would be appreciated, thanks.


Top
 Profile  
Reply with quote  
PostPosted: Sat May 15, 2021 4:10 am 
Offline

Joined: Sun Apr 26, 2020 3:08 am
Posts: 357
When trouble shooting, it is sometimes easier to find the error when following the code backwards. Look at the code that branches to the Syntax Error and find what is forcing the branch or jump.

List the part of INCHAR that branches to the Syntax Error.


Top
 Profile  
Reply with quote  
PostPosted: Sat May 15, 2021 7:37 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10808
Location: England
Good suggestion. Also, might be worth checking to see if the original routines preserve any registers which your new ones don't.


Top
 Profile  
Reply with quote  
PostPosted: Sat May 15, 2021 12:05 pm 
Offline
User avatar

Joined: Tue Mar 05, 2013 4:31 am
Posts: 1373
Also, perhaps it's worth looking at the Page Zero usage of SymBasic... and compare it to any Page Zero usage your monitor is using. It's also possible that SymBasic might be using some Stack space memory for pointers, variables, etc., which may result in some corruption if the Stack pointer isn't initialized.

_________________
Regards, KM
https://github.com/floobydust


Top
 Profile  
Reply with quote  
PostPosted: Sat May 15, 2021 3:22 pm 
Offline

Joined: Wed Nov 11, 2020 10:42 pm
Posts: 96
Location: Kelowna Canada
Not sure if this will help but I came across this comparison of Page Zero references for Basics and hex dump for SYM Basic. It's been a while since I looked seriously but I still have my SYM-1 and while I have removed the BASIC ROM to be replaced by SYMbiosys for a CF card Storage system I could replace it and check things out.


Attachments:
sym-basic.txt [65.96 KiB]
Downloaded 43 times
Top
 Profile  
Reply with quote  
PostPosted: Sat May 15, 2021 10:15 pm 
Offline

Joined: Thu May 13, 2021 12:53 pm
Posts: 16
Location: Fargo, North Dakota
Thanks for the suggestions everyone, I have it somewhat solved.

I changed the way I was entering BASIC from my monitor program.
Originally I was using some code from the SYM monitor that would take an address and start execution there, after some stack manipulation, with an RTI.
For now I just put in a simple jmp $C000 and I'm able to get past the MEMORY SIZE, WIDTH prompts and get into the interpreter.
So it must be something stack related, even though it looks like BASIC sets the stack to $FF as one of the first things.

There is still some goofy stuff going on, but I got past the first hurdle.

Thanks again!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 17 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron