Difference between revisions of "K65 Syntax"
m |
m |
||
Line 1: | Line 1: | ||
+ | [[Category:K65]] | ||
''This page is still under construction - much of the infrmation is still to be filled'' | ''This page is still under construction - much of the infrmation is still to be filled'' | ||
Revision as of 00:09, 16 December 2014
This page is still under construction - much of the infrmation is still to be filled
Contents
Comments
K65 uses C-like comments.
// this is a line comment /* this is a block comment */
Variable declaration
Variables in K65 are names given to chosen memory addresses.
Examples of variabl declaration:
var foo=0x80 // declares 'foo' at address 0x80 var foo2 // declares 'foo2' at address 0x81 (next after previous var) var foo3, foo4 // multiple declarations per line allowed var bar[10], bar2[10] // [] specifies variable size in bytes (address increment for next var) var bar3 ? // adding '?' at the end of var declaration makes compiler print var addresses
Constant declaration
The best way of defining constants is using the evaluator. Constants defined this way can be changed at any moment during compilation. Constants can be any value of floating point type. When used within 6502 instruction, they are converted to single byte by rounding to nearest integer and AND'ing with 0xFF (this way negative values are represented in U2 form).
Examples:
[ // square brace starts evaluator expression MY_CONSTANT = 5, // define constants SOME_NUMBER = 0x13 ] // end of evaluator expression
Bank selection
While default bank can be chosen in file list for each file, a file can span across multiple banks. Active bank can be changed at any point in the file.
Example:
bank my_bank // from now on all code and data will go to 'my_bank'
Data block definition
Data blocks are defined using data keyword. Defining data block at the same time defines a label to its first element, so the block is accessibl using simple indexing (like MyData,x). Datablocks can have optional alignment or no-page-crossing restrictions enabled.
Examples:
data MyData { align 16 // align to 16 byte boundary 1 2 3 4 5 6 7 8 // data bytes folow } data MyData2 { align 256 + 8 // align to 8 bytes after page boundary (lower address byte will be 0x08) 1 2 3 4 5 6 7 8 // data bytes folow } data MyData3 { nocross // the data will fit completely inside single page, but can be at any offset within it 1 2 3 4 5 6 7 8 // data bytes folow }