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.