Page 1 of 1
TCB02 - Tiny Compiled Basic for the 6502
Posted: Thu Feb 10, 2011 3:32 am
by CurtisP
I have been working on a Tiny Compiled BASIC for the 6502, which I have named TCB02.
It's now functional enough to be released for Alpha testing.
Currently, the Assembly code generated is targeted to the 6502 Macro Assembler and Simulator by Michal Kowalski.
You can find it here
https://docs.google.com/leaf?id=0BxwERm ... NGFj&hl=en
Posted: Fri Feb 11, 2011 4:23 pm
by CurtisP
I've updated the compiler. Added FOR/NEXT and MACRO definitions to allow code that is more BASIC like.
I also coded a fully working Hangman game to show that the compiler is fully usable.
Edit I forgot the link to the new version
https://docs.google.com/leaf?id=0BxwERm ... NTc1&hl=en
Posted: Fri Feb 11, 2011 6:15 pm
by Nightmaretony
Posted: Mon Feb 14, 2011 3:29 am
by CurtisP
Another major enhancement.
Added macros and improved the include capabilities.
TCB02 now allows targeting a single program to different machines using properly named configurstion and library files.
It will also create code for different assemblers by using configuration files.
https://docs.google.com/leaf?id=0BxwERm ... ZTQ1&hl=en
Posted: Wed Feb 16, 2011 2:36 am
by CurtisP
To give you an idea of the syntax and possibilities of TCB02, here is the source code for the Hangman game.
By specifying the apropriate Import and Include Files, this source code can be compiled for multiple target machines. I have so far compiled versions the 6502 Simulator, and the Vic 20.
Code: Select all
REM Hangman Game for TCB02
REM (C) 2011 Curtis F Kaylor
IMPORT "LIB"
INCLUDE "MACROS"
DIM C, I, J, Found
DIM Word[8]
DIM Right, Wrong, Pick[15]
LABEL Start
LOCATE 0,10
PRINT "PRESS ANY KEY TO BEGIN"
REM Set Random Seed Value
LET I = 0
REPEAT
INCR I
GET C
UNTIL C <> 0
RANDOM I
REM Draw Screen
CLS
PUT #CDNRT
FOR I = 1 TO 5
PUT #HLINE
NEXT I
PUT #CDNLT
LOCATE 6,1
PUT ':'
FOR I = 1 TO 6
LOCATE 0, I
PUT #VLINE
NEXT I
LOCATE 0,7
PRINT " WORD ********"
PRINT " MISS"
LOCATE 0,10
PRINT "PRESS A LETTER "
REM Pick Word
LET Word = 8
LET I = RND() & $F8
FOR J = 1 TO 8
LET I = I + 1
LET Word[J] = WordList[I]
NEXT
REM Initialize Variables
LET Pick = 0
LET Right = 0
LET Wrong = 0
LABEL Main
REM Input Character and Convert to Uppercase
INP C
IF C>='a' AND C<='z' THEN LET C=C-32
REM Check For Break
IF C = 3 THEN STOP
REM Make sure it's a Letter
IF C<'A' OR C>'Z' THEN GOTO Main
REM See if Letter Was Already Picked
FOR I = 1 TO Pick
IF Pick[I] = C THEN GOTO Main
NEXT
REM See if Letter is in Word
LET Found = 0
FOR I = 1 to Word
IF Word[I] = C THEN
LET Right = Right + 1
LOCATE I+5,7
PUT C
GOSUB Repos
LET Found = 1
ENDIF
NEXT
REM Letter Was Not In Word
IF Found = 0 THEN
LET Wrong = Wrong + 1
LOCATE Wrong+5,8
PUT C
GOSUB BodyPart
GOSUB Repos
ENDIF
REM Add to List of Picked Letters
INCR Pick
LET Pick[Pick] = C
IF Right > 7 THEN
LOCATE 5,9
PRINT "YOU WIN!"
GOTO Start
ENDIF
IF Wrong > 6 THEN
LOCATE 5,9
PRINT "YOU LOSE!"
GOTO Start
ENDIF
GOTO Main
LABEL BodyPart
IF Wrong = 1 THEN
LOCATE 6,2
PUT 'O'
ENDIF
IF Wrong = 2 THEN
LOCATE 5,3
PUT #DLLUR
ENDIF
IF Wrong = 3 THEN
LOCATE 7,3
PUT #DULLR
ENDIF
IF Wrong = 4 THEN
LOCATE 6,3
PUT #VLINE
ENDIF
IF Wrong = 5 THEN
LOCATE 6,4
PUT #VLINE
ENDIF
IF Wrong = 6 THEN
LOCATE 5,5
PUT #DLLUR
ENDIF
IF Wrong = 7 THEN
LOCATE 7,5
PUT #DULLR
ENDIF
RETURN
LABEL Repos
LOCATE 15,10
RETURN
DIM WordList = "ABDICATE"
DATA "BACHELOR", "CALZONES", "DINOSAUR", "DUMPSTER"
DATA "DYSTOPIA". "EMPHATIC", "FATIGUED", "GERMANIC"
DATA "HARMONIC", "IGNORANT", "JEALOUSY", "KILOBYTE"
DATA "LAUGHTER", "MAGNETIC", "NOTARIZE", "ORDINARY"
DATA "PERILOUS", "QUACKERY", "REACTION", "SCROUNGE"
DATA "TAPESTRY", "VIRULENT", "BACTERIA", "AQUIFERS"
DATA "BIFOCALS", "ABNORMAL", "CAMISOLE", "DOLPHINS"
DATA "BRITCHES", "ARGUMENT", "BESTIARY"
Posted: Thu Feb 17, 2011 7:06 am
by flaith
Hi,
i tried with 6502 Simulator, it's ok, no problems so far, thanks for your program

Re: TCB02 - Tiny Compiled Basic for the 6502
Posted: Sat Mar 05, 2011 11:57 am
by cjb
Just what the world needs, another closed-source 6502 compiler that's binary-only for an anachronistic computer operating system. This can go into the same pile as the Windows98 GCC6502.EXE I picked off an Oric forum.
Re: TCB02 - Tiny Compiled Basic for the 6502
Posted: Sat Mar 05, 2011 7:13 pm
by CurtisP
Just what the world needs, another closed-source 6502 compiler that's binary-only for an anachronistic computer operating system. This can go into the same pile as the Windows98 GCC6502.EXE I picked off an Oric forum.
It's only closed source for now. The eventual goal is to rewrite the compiler in the compiled language itself.
Re: TCB02 - Tiny Compiled Basic for the 6502
Posted: Sun Mar 06, 2011 7:20 pm
by BigEd
It's only closed source for now. The eventual goal is to rewrite the compiler in the compiled language itself.
Please do open-source it! Even a work in progress is a benefit to others, who might be able to learn from it, or help you fix things or add things - or even test, or document.
Posted: Mon Mar 07, 2011 5:17 am
by CurtisP
I created a project on Google Code at
http://code.google.com/p/tcb02/.
I need to get my code into a reasonable directory structure so I can upload it.