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
TCB02 - Tiny Compiled Basic for the 6502
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
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
Last edited by CurtisP on Fri Feb 11, 2011 10:25 pm, edited 1 time in total.
-
Nightmaretony
- In Memoriam
- Posts: 618
- Joined: 27 Jun 2003
- Location: Meadowbrook
- Contact:
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
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
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.
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"
Re: TCB02 - Tiny Compiled Basic for the 6502
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
cjb wrote:
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
CurtisP wrote:
It's only closed source for now. The eventual goal is to rewrite the compiler in the compiled language itself.
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.
I need to get my code into a reasonable directory structure so I can upload it.