So far I've worked out how to do:
- basic C preprocessor commands (#include #define #ifdef #ifndef #else #endif)
- comments (// /* */
- functions (parameters, local variables, pre-declaring (e.g. if they're in another file))
- inline functions
- handling signed, unsigned, float, ascii values, compile time inline calculations
- do operations with commands to =, +, -, etc (only 1 operation per line)
- structures
- if / else conditions, while and do while loops
- local variables
Here is a dump of my text file while shows my ideas for the language (not really designed to be neat or readable):
Code: Select all
First pass commands: (same a c processor)
---------------------------------------------------------------
#include
#define
#ifdef
#ifndef
#else
#endif
Comments
---------------------------------------------------------------
// comment until the end of the line
; same as //
/* comment block */
Functions
---------------------------------------------------------------
// predeclare function for later use (
declare function_name(a0, a1, a2);
// v-- parameters
// v--registers to save to stack
// v--temporary name for register
func function_name(a0, a1, a2 = myReg) : (a3,a4,a5)
{
} // return
// cannot predefine these
inline func function_name(a0, a1, a2) : (a3,a4,a5)
{
}
// calling functions:
function_name(a0, 483s, @3.0f) // @ means do not push the
// register that parameter is
// using to the stack
Values
---------------------------------------------------------------
48923423 - raw number, unsigned
438238s - signed number
433838u - unsigned number
49312.f - float
0x3434 - hexidecimal unsigned number
'a' - ascii character converted to unsigned number
*493 - converts to [493]
can do inline calculations - e.g. 5s * 10s / 100s ONLY if all
types are the same type (unsigned, signed, or float)
Operations
---------------------------------------------------------------
= move
t++ increment
t-- decrement
t+= add
t-= subtract
where t is u(unsigned), s(signed), or f(float)
e.g.:
c5 += c7
c5 = 50.0f
Structures:
---------------------------------------------------------------
struct struct_name
{
membername : 2; // 2 = size of member in bytes
membername2 : 1;
}
struct struct2
{
struct1 : struct_name;
anothervar : 1;
}
to access it you would do something like:
address = 0x550 + struct2.struct1.membername
address = struct2.struct1.memername
Conditions and loops:
----------------------------------------------------------------
// first register is to test, second register stores temporary
// value of address (at least 32-bit register recommended)
// e.g.
// (@b5) - use register b5 but don't push old value to stack
// (b5) - use register b5 and temporarily push it's old
// value to the stack
if(a0) : (b5) // if it's not zero
{
}
else // if it's zero
{
}
if(!a0) : (b5) // if it's zero
{
}
else // if it's not zero
{
}
while(a0) : (b5) // loop while not zero
{
}
while(!a0) : (b5) // loop while zero
{
}
do
{
}
while(a0) : (b5) // do while not zero
do
{
}
while(!a0) : (b5) // do while zero
Scoping:
----------------------------------------------------------------
local(a0, a1 = myReg, @a3 = myReg2) // pushes those registers to
// the stack so they can be
// temporarily used (myReg is
// a keyword for the register)
{
}