Hello all,
I am implementing EhBasic on my 65C02 board, and all went well, until...
I hit a snag, of course.
After some testing, I found out that when I types somewhat longer lines of BASIC, weird stuff was happening.
A line like:
580 FOR I=1 TO 12: FOR J=1 TO 12: PRINT P$(I,J);: NEXT J
got corrupted when i LISTed it back.
The PRINT command was replaced by a byte 0x9f, the P$(I,J);: was OK again, then the NEXT command was again a single byte 0x82
(580 FOR I=1 TO 121: FOR J=1 TO 121: <0x9f> P$(I,J);: <0x82> J)
The HEX values between < > did not print like that, but I figured them out using my terminal program
Then I did some testing and I tried (not a runnable program, obviously!):
10 PRINT:PRINT:PRINT:PRINT:PRINT:<0x9f>:<0x9f>:<0x9f>:<0x9f>:<0x9f>
20 REM:REM:REM:REM:REM:REM:REM:REM:REM:REM
30 REM:REM:REM:REM:REM:REM:REM:REM:REM:REM:REM:REM:REM:REM:REM:REM:REM
40 BEEP:BEEP:BEEP:BEEP:BEEP:BEEP:<0xab>:<0xab>:<0xab>:<0xab>:<0xab>:<0xab>:<0xab>:<0xab>
50 END:END:END:END:END:END:END:END:END:END:END:END:END:END:END
60 CLS:CLS:CLS:CLS:CLS:CLS:CLS:CLS:CLS:CLS:CLS:CLS:CLS:CLS:CLS:CLS:CLS
70 LOOP:LOOP:LOOP:LOOP:LOOP:LOOP:<0x9e>:<0x9e>:<0x9e>:<0x9e>:<0x9e>:<0x9e>:<0x9e>:<0x9e>
80 RETURN:RETURN:RETURN:RETURN:RETURN:RETURN:RETURN:RETURN:RETURN:RETURN
90 WAIT:WAIT:WAIT:WAIT:WAIT:WAIT:<0x96>:wair:<0x96>:<0x96>:<0x96>:<0x96>:<0x96>:<0x96>
100 GOTO:GOTO:GOTO:GOTO:GOTO:GOTO:<0x98>:<0x98>:<0x98>:<0x98>:<0x98>
110 PRINT:prinit:PRINTn:PRINTn:PRINT:PRINT:PRINT:PRINT:prinint:PRINT
120 PRINT:PRINT:PRINT:PRINT:PRINT:<0x9f>:<0x9f>:<0x9f>:<0x9f>:<0x9f>:<0x9f>:<0x9f>
130 INC:INC:INC:INC:INC:INC:INC:INC:INC:INC:INC:INC:INC:INC:INC:INC
140 NULL:NULL:NULL:NULL:NULL:NULL:<0x94>:<0x94>:<0x94>:<0x94>:<0x94>:<0x94>:<0x94>
150 ON:ON:ON:ON:ON:ON:ON:ON:ON:ON:<0x93>:<0x93>:<0x93>:<0x93>:<0x93>:<0x93>:<0x93>
160 STOP:STOP:STOP:STOP:STOP:STOP:<0x92>:<0x92>:<0x92>:<0x92>:<0x92>:<0x92>
From this I concluded:
- Only affects recognised tokens (See line 90 and 110)
- Not all tokens; i.e. REM, END, CLS, RETURN, INC (and others?) are okay / PRINT, BEEP, LOOP, WAIT, GOTO, NULL, ON, STOP (and others?) are bad.
- Line numbering is not the problem; when using line number 100, the error point gets shifted 1 position to the right too (See line 110-120)
- When deliberately introducing some typo's in the keywords, the problem isn't the same (see line 110), but not gone (see line 90)
- HEX code is linked to the token (PRINT = $9F, BEEP = $AB, LOOP = $9E, WAIT = $96, GOTO = $98)
- HEX codes are in order and related to the Token list (TK_) and Decode table (at LAB_KEYT)
I cannot figure out for the life of me what is going on here!
Is someone familiar with this phenomenon?
Please help me out here, I have been banging my head over this for 3 whole days now...
Thanks in advance!
Jacco
P.S., BEEP and CLS are tokens that I added myself, and are working fine
Here is some info about my system:
- WDC 65C02 @ 4 MHz
- Serial connection @ 115200 baud
- User RAM from $0000-$7FFF ($0600-$6FFF available for BASIC programs)
- ROM from $C000-$FFFF
- EhBasic assembled in RAM from $8000-$BFFF
In EhBasic, I have set
MEMBOT =$0600 ; Bottom of user memory
MEMTOP =$7000 ; Top of user memory
ZPSTART =$00 ; Start of zero page workspace
WSSTART =$0500 ; Start of vector and input buffer workspace
CODESTART=$8000 ; Start of program code
ccflag = WSSTART ; BASIC CTRL-C flag, 00 = enabled, 01 = disabled
ccbyte = ccflag+1 ; BASIC CTRL-C byte
ccnull = ccbyte+1 ; BASIC CTRL-C byte timeout
VEC_CC = ccnull+2 ; CTRL-C check vector
VEC_IN = VEC_CC+2 ; input vector
VEC_OUT = VEC_IN+2 ; output vector
VEC_LD = VEC_OUT+2 ; load vector
VEC_SV = VEC_LD+2 ; save vector
Ibuffs = VEC_SV+4 ; aligned to $xx10
Ibuffe = Ibuffs+$7B ; end of input buffer
Ram_base = MEMBOT ; start of user RAM
Ram_top = MEMTOP ; end of user RAM+1
Stack_floor = 16 ; bytes left free on stack for background interrupts