neilsf / xc-basic3 Goto Github PK
View Code? Open in Web Editor NEWA BASIC cross compiler for MOS 6502-based machines
License: MIT License
A BASIC cross compiler for MOS 6502-based machines
License: MIT License
re-factoring some C64 Dir code.
Please submit this bug to https://github.com/neilsf/xc-basic3/issues
exit status: 1
cd C:\xcbasic3
C:\xcbasic3\bin\Windows\xcbasic3.exe "disk.bas" "disk.prg"
disk.bas:20.0: WARNING: Downcasting from int to byte truncates value
disk.bas:49.0: WARNING: Downcasting from int to byte truncates value
** ERROR ** There has been an error while trying to execute DASM, please see the bellow message.
Tried to execute: "dasm.exe" "C:\Users\jakeb\AppData\Local\Temp\xcbtmp_9C2A7B4B.asm" -o"disk.prg"
Please submit this bug to https://github.com/neilsf/xc-basic3/issues
exit status: 1
e.g.
FOR t AS INT = 1 TO 128+128
print t
NEXT t
I'm always getting the following error when compiling:
std.file.FileException@std\file.d(4318): Copy from C:\Users\thrak\AppData\Local\Temp\xcbtmp_33677BC2.sym to "test2.symbols.txt": The filename, directory name, or volume label syntax is incorrect.
Please submit this bug to https://github.com/neilsf/xc-basic3/issues
exit status: 1
cd C:\xcbasic3
C:\xcbasic3\bin\Windows\xcbasic3.exe "6.bas" "6.prg"
6.bas:68.0: WARNING: Downcasting from int to byte truncates value
** ERROR ** There has been an error while trying to execute DASM, please see the bellow message.
Tried to execute: "dasm.exe" "C:\Users\jakeb\AppData\Local\Temp\xcbtmp_7C5995A0.asm" -o"6.prg
6.zip
"
Hello, any plans to port to C264 series computers?
At the moment you have to set the length of a string, and then give a value:
dim myString as string * 9
myString = "some text"
It would be a nice feature if it could be done in one line, something like
dim myString as string = "some text"
Or possibly even dim myString as "some text
with the compiler detecting it's a string, and setting the length automatically.
Grabbed the latest version to compile. Seems we have a new input bug
exit status: 0
cd C:\xcbasic3
C:\xcbasic3\bin\Windows\xcbasic3.exe "main.bas" "main.prg"
** ERROR ** There has been an error while trying to execute DASM, please see the bellow message.
Tried to execute: "dasm.exe" "C:\Users\jakeb\AppData\Local\Temp\xcbtmp_98165EC8.asm" -o"main.prg
main.zip
"
If you try and set an array size using a byte constant, you receive an error.
const SIZE! = 10
dim myArray[SIZE!]
Throws the error core.exception.SwitchError@source\language\number.d(28): No appropriate switch clause found
It works fine with normal integer constants though.
Those routines (built-in routines, procedures and functions) that are never called should be excluded from the output in order to make the compiled program as compact as possible.
Using Mac Monterey 12.1
So I created a symbolic link to xcbasic3 as directed
$ sudo ln /Users/x/source/xc-basic3/bin/macOS/xcbasic3 /usr/local/bin/xcbasic3
$ ls -la /usr/local/bin/xcbasic3
-rwxr-xr-x 2 d staff 16329472 Jan 4 23:01 /usr/local/bin/xcbasic3
/usr/local/bin is in my path.
However when I execute xcbasic complains about the lib folder missing
$ xcbasic3
XC=BASIC library was not found in "/usr/lib". Please make sure the directory exists and contains the library files.
I've left the lib folder in the original location as advised here https://xc-basic.net/doku.php?id=v3:installation_and_usage
To run properly, XC=BASIC needs the lib/ directory as well and it must be in the same folder where the bin/ directory is. Just leave them as they are.
Is /usr/lib hardcored as xc basic appears to be expecting the libs there?
Please submit this bug to https://github.com/neilsf/xc-basic3/issues
exit status: 1
cd C:\xcbasic3
C:\xcbasic3\bin\Windows\xcbasic3.exe "6.bas" "6.prg"
6.bas:39.0: WARNING: Downcasting from int to byte truncates value
** ERROR ** There has been an error while trying to execute DASM, please see the bellow message.
Tried to execute: "dasm.exe" "C:\Users\jakeb\AppData\Local\Temp\xcbtmp_F9CFF990.asm" -o"6.prg
6.zip
"
After entering the example given here, I get the following:
C:\Users\chris\Projects\XCBasic\unicopter>xcbasic3 test-error.bas test-error.prg
test-error.bas:10.0: ERROR: Variable "ERR" does not exist or is unknown in this scope
Am I doing something wrong?
Compiling and running the example from here it looks like it doesn't work perfectly.
Similarly to https://wiki.qb64.org/wiki/INSTR
According to documentation inside a proc i can usa a global variable with modifier ''
But whit arrays the compiler doesn't seem that careful.
the following piece of code does not emit compile error "undefined variable" that i excpected.
Rem Test
data yFires![] = 0,0,0
let count! = 0
proc foo
if \yFires![\count!] > 0 then :Rem removing global modifier Compiler emit Compile-error
yFires![\count!] = 0: Rem No global modifier \ - Compiler have does not emit error in compile time
endif
endproc
BAS files with Windows CRLF will fail to compile. Converting them to LF and all works good.
EXIT FOR will not compile. If I REM it out it compiles fine
strhelper.zip
.
It would be a useful feature to be able to seed the random number generator, possibly by putting the seed value as an argument of the rnd function.
Also, how is the initial random number seed selected? I always get the same sequence of numbers when running my code in an emulator.
e.g.
DIM a AS LONG
a = $7fffff AND $000000
print a
outputs: 8388607
(Sorry, I originally posted this to XC-Basic project -> wrong one)
c64 consistently crashes when executing this code (I tried to isolate the problem into small snippet):
DIM i AS INT
SUB calc_mod(s0 AS INT, s1 AS INT) STATIC
i = s0 MOD s1
END SUB
CALL calc_mod(0, 255)
String functions should be added that implement a lot of the standard BASIC string functions without having to do workarounds with array buffers.
TYPE coordinates
x AS LONG
y AS LONG
END TYPE
DIM position(10) AS coordinates
DIM a1 AS WORD
DIM a2 AS WORD
DIM i AS BYTE
i = 5
a1 = @position(i).x
a2 = @position(i).y
print a1, a2
REM output is 2629 2629 <- WRONG
a1 = @position(5).x
a2 = @position(5).y
print a1, a2
REM output is 2629 2632 <- CORRECT
I am not sure if this is intended, but fyi
CONST PORT_1 = $DC01
CONST PORT_2 = $DC00
_PORTS:
DATA AS WORD 0, PORT_1, PORT_2
FOR t AS INT = 250 to 260
print t MOD 256
NEXT
prints all zeros.
DIM t AS STRING*12
t = " hello! "
DIM length AS BYTE: length = len(t)
t = MID$(t, 1, length - 1)
PRINT t
I'm not sure exactly what is causing corruption, but this program does something bad causing the C64 in VICE to crash.
** Wonder if we still have a bug in the drive commands. Or... Just me being stupid.
Converted this code to xc-basic and its not working.
I just downloaded the repo (git clone
) and compiled the following as test.bas:
rem ** fibonacci series **
let max = 32767
let t1 = 0
let t2 = 1
print "fibonacci series:"
loop:
print t1, " "
let nx = t1 + t2
let t1 = t2
let t2 = nx
if nx < max then goto loop
end
The build fails with:
C:\code\Fun\C64\XCBasic\xc-basic3\bin\Windows>xcbasic3.exe test.bas test.prg
test.bas:2.0: NOTICE: Variable "max" implicitly defined as int
test.bas:3.0: NOTICE: Variable "t1" implicitly defined as byte
test.bas:4.0: NOTICE: Variable "t2" implicitly defined as byte
test.bas:8.0: NOTICE: Variable "nx" implicitly defined as byte
C:\Users\thrak\AppData\Local\Temp\xcbtmp_B1F1E3D.asm (22): error: Unknown Mnemonic 'xbegin'.
C:\Users\thrak\AppData\Local\Temp\xcbtmp_B1F1E3D.asm (24): error: Unknown Mnemonic 'pint'.
C:\Users\thrak\AppData\Local\Temp\xcbtmp_B1F1E3D.asm (27): error: Unknown Mnemonic 'plintvar'.
C:\Users\thrak\AppData\Local\Temp\xcbtmp_B1F1E3D.asm (30): error: Unknown Mnemonic 'pbyte'.
C:\Users\thrak\AppData\Local\Temp\xcbtmp_B1F1E3D.asm (33): error: Unknown Mnemonic 'plbytevar'.
C:\Users\thrak\AppData\Local\Temp\xcbtmp_B1F1E3D.asm (36): error: Unknown Mnemonic 'pbyte'.
C:\Users\thrak\AppData\Local\Temp\xcbtmp_B1F1E3D.asm (39): error: Unknown Mnemonic 'plbytevar'.
C:\Users\thrak\AppData\Local\Temp\xcbtmp_B1F1E3D.asm (40): error: Unknown Mnemonic 'pstringvar'.
C:\Users\thrak\AppData\Local\Temp\xcbtmp_B1F1E3D.asm (41): error: Unknown Mnemonic 'printstring'.
C:\Users\thrak\AppData\Local\Temp\xcbtmp_B1F1E3D.asm (42): error: Unknown Mnemonic 'printnl'.
C:\Users\thrak\AppData\Local\Temp\xcbtmp_B1F1E3D.asm (46): error: Unknown Mnemonic 'pbytevar'.
C:\Users\thrak\AppData\Local\Temp\xcbtmp_B1F1E3D.asm (49): error: Unknown Mnemonic 'printbyte'.
C:\Users\thrak\AppData\Local\Temp\xcbtmp_B1F1E3D.asm (50): error: Unknown Mnemonic 'printtab'.
C:\Users\thrak\AppData\Local\Temp\xcbtmp_B1F1E3D.asm (51): error: Unknown Mnemonic 'pstringvar'.
C:\Users\thrak\AppData\Local\Temp\xcbtmp_B1F1E3D.asm (52): error: Unknown Mnemonic 'printstring'.
C:\Users\thrak\AppData\Local\Temp\xcbtmp_B1F1E3D.asm (53): error: Unknown Mnemonic 'printnl'.
C:\Users\thrak\AppData\Local\Temp\xcbtmp_B1F1E3D.asm (56): error: Unknown Mnemonic 'opt_pbytevar_pbytevar_addbyte'.
C:\Users\thrak\AppData\Local\Temp\xcbtmp_B1F1E3D.asm (59): error: Unknown Mnemonic 'plbytevar'.
C:\Users\thrak\AppData\Local\Temp\xcbtmp_B1F1E3D.asm (62): error: Unknown Mnemonic 'pbytevar'.
C:\Users\thrak\AppData\Local\Temp\xcbtmp_B1F1E3D.asm (65): error: Unknown Mnemonic 'plbytevar'.
C:\Users\thrak\AppData\Local\Temp\xcbtmp_B1F1E3D.asm (68): error: Unknown Mnemonic 'pbytevar'.
C:\Users\thrak\AppData\Local\Temp\xcbtmp_B1F1E3D.asm (71): error: Unknown Mnemonic 'plbytevar'.
C:\Users\thrak\AppData\Local\Temp\xcbtmp_B1F1E3D.asm (73): error: Unknown Mnemonic 'pbytevar'.
C:\Users\thrak\AppData\Local\Temp\xcbtmp_B1F1E3D.asm (74): error: Unknown Mnemonic 'F_cint_byte'.
C:\Users\thrak\AppData\Local\Temp\xcbtmp_B1F1E3D.asm (75): error: Unknown Mnemonic 'pintvar'.
C:\Users\thrak\AppData\Local\Temp\xcbtmp_B1F1E3D.asm (77): error: Unknown Mnemonic 'cmpintlt'.
C:\Users\thrak\AppData\Local\Temp\xcbtmp_B1F1E3D.asm (80): error: Unknown Mnemonic 'cond_stmt'.
C:\Users\thrak\AppData\Local\Temp\xcbtmp_B1F1E3D.asm (83): error: Unknown Mnemonic 'xend'.
C:\Users\thrak\AppData\Local\Temp\xcbtmp_B1F1E3D.asm (84): error: Unknown Mnemonic 'xend'.
Unrecoverable error(s) in pass, aborting assembly!
Complete.
This is the list of planned features for version 3.1. Please add your thoughts and wishes.
(Highly inspired by Hesware's Graphics BASIC)
SPRITE n ON|OFF
AT x, y
COLOR c
HIRES|MULTI
ON|UNDER BACKGROUND
SHAPE s
XYSIZE xs, ys
SPRITE CLEAR HIT
SPRITE MULTICOLOR c1, c2
SPRITEHIT(n)
SPRITEHITBG(n)
JOY(n)
JOYUP(n)
JOYDOWN(n)
JOYLEFT(n)
JOYRIGHT(n)
JOYFIRE(n)
ON INTERRUPT n GOTO label
INTERRUPT ON|OFF
WITH|WITHOUT KERNAL
(Highly inspired by Hesware's Graphics BASIC)
SOUND CLEAR
VOICE n
[ON|OFF]
[ADSR a, d, s, r]
[TONE f]
[WAVE SAW|TRI|PULSE|NOISE]
[PULSE p]
FILTER [f]
[LOW|BAND|HIGH]
[VOICE 1]
[VOICE 2]
[VOICE 3]
VOLUME v
disk.bas:16.0: ERROR: Only strings are allowed in INPUT statement, got diskio
exit status: 1
Implement SELECT ... CASE ... ENDSELECT blocks in the style of QB or similar, for example:
SELECT <expression>
CASE expression1
[statements]
CASE expression2
[statements]
DEFAULT
[statements]
ENDSELECT
A compiler option should be added to halt compilation if the program exceeds a certain size to be able to define user memory space in the high area, e. g.
REM This would protect the RAM from C000-CFFF
PRAGMA memory_limit = $BFFF
Test code:
DIM l AS LONG
l = 0
l = l + 256
print hex(l)
outputs: $46e1e9 (value after zero assignment is correctly $000000)
I believe that this problem affects most of the operators +, -, *, / but I have tested only addition.
I can't seem to adjust the return string directly. In the example below, the length of the string is always 0. It seems for the purpose of a poke, you can't reference @str_Strings
. The value always seems to be 0 in the following example.
FUNCTION str_Strings AS STRING*96 (count AS BYTE, character AS BYTE) STATIC SHARED
print peek(@str_Strings)
POKE @str_Strings, count
print peek(@str_Strings)
END FUNCTION
Examples:
DIM i AS INT
i = 1
print NOT (i) <- COMPILE ERROR
print NOT 1 <- COMPILE ERROR
print NOT i <- WRONG RESULT $46E1
I'm not sure if this is a bug or an ER, but code like:
type location
x as int: ' the column
y as int: ' the row
end type
...generates the error:
ERROR: TYPE blocks can only contain field or method definitions
It fails for either ' or REM, and fails whether located at the beginning of the line, or after a ":"
Surely we want to be able to comment the fields and procedures in a TYPE, right?
This is my first test with xc-basic, so there is a high probability that I have misunderstood something ๐
This is the code
GOTO START
ORIGIN 2112
DATA AS BYTE 0,1,2,3,4,5,6,7
START:
DIM values(8) AS BYTE @2112
PRINT values(3)
Compiling and running this in VICE prints 32
, but I would expect it to print 3
. I also find the syntax @2112
a little surprising (the need for @
sign specifically).
...is it like
Sorry for misusing the issue for question, but I was trying to test random floats as a continuation to random integer floats issue.
The current implementation of arrays only support 2 dimensions. At least 3 should be supported.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.