A2Z Basic is a language invented by myself. I wanted something slightly different from existing languages, primarily for fun, but also to help the compiler. The syntax is closed to C, but much less rich.
Be careful : if you code in A2Z Basic, there are lots of constraints that exist just to make the job easier for the compiler. For example, each instruction must be in a new line, including closing accolades.
If you want to copy the result of a computation in a variable, you must use the instruction “assign” before the formula.
Finally, the compiler is not smart, and it is not able to prioritize math or logic operations inside a complex expression. You must put parenthesis everywhere, in order to split each elementary computation.
if ( ((Xm_pos//4) >= 128 ) & ((Ym_pos//4) >= 32 ) ) {
If you don’t respect these rules, there will probably be no error message from the compiler, but the executable code generated will not work.
You can integrate assembly code directly in the middle of A2Z Basic code. This is used to code low level functions, to access hardware directly (drivers).
The directive #appli_config sets the maximum allowed size for code and variables, and the position of the generated file inside RAM. The RAM portion dedicated to variables can be common (separation = 1) or separated (separation = 2) from the executable code. With option 2, you can use the full range 64kB for variables.
Functions:
There are 3 types of “functions”:
- Subf : these are classic sub-functions which calling is managed on the execution stack.
- ASMf: so called ASM function. They are elementary, low level function that cannot call other functions. The return address is not stored in the stack, but in a specific CACHE position. The calling and return of ASMf are therefore much faster than for Subf. This is useful for repetitive functions called very often.
- Marcos: macros are pieces of repetitive code that are just substituted inside the source code before its parsing
Limitations of the language and the compiler
- Static memory allocation, no dynamic memory allocation (no data stack or heap).
- No recursive functions management : a function cannot call itself, either directly or indirectly, because of the previous limitation (static memory allocation)
- 64kB only of memory range for variables, because of 16bits pointers. But a program can access the whole 2MB range with low level instructions
- 2 dimension tables at maximum
- Only 1 basic source code file at input of the compiler. No “include”, no library (static or dynamic). All functions used in a program must be copied to the source code, even repetitive functions (printf)
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.