Iāve finally completed my BASIC V2 cross compiler that allows one to compile programs written in Commodore BASIC V2 on the PC for the C64.
Hereās a small example from the C64ās manual:
1 REM UP, UP, AND AWAY!
5 PRINT "{CLEAR}"
10 V = 53248
11 POKE V+21,28
12 POKE 2042,13: POKE 2043,13: POKE 2044,13
20 FOR N = 0 TO 62:READ Q:POKE 832+N,Q:NEXT
25 POKE V+23,12: POKE V+29,12
30 FOR X = 0 TO 200
40 POKE V+4,X
48 POKE V+8,X
50 POKE V+5,X
58 POKE V+9,100
60 NEXT X
70 GOTO 30
200 DATA 0,127,0,1,255,192,3,255,224,3,231,224
210 DATA 7,217,240,7,223,240,7,217,240,3,231,224
220 DATA 3,255,224,3,255,224,2,255,160,1,127,64
230 DATA 1,62,64,0,156,128,0,156,128,0,73,0,0,73,0
240 DATA 0,62,0,0,62,0,0,62,0,0,28,0
The compiler first compiles this into an intermediate language, which looks like this:
http://pastebin.java-gaming.org/afa807560571c
And then it converts this into 6502-assembly language and links the needed runtime routines to it, which looks like this:
http://pastebin.java-gaming.org/a8050976c5e17
ā¦which then gets assembled into actual machine code to be run on the target platform (this binary will run in any C64 emulator): https://jpct.de/download/++example.prg