Summary of TRSE Syntax

(NOT YET COMPLETE)

Program structure

Program MyProgram;
var
    a,b,c : byte = 0;
 
Procedure Myprocedure(mp_i:byte);
var
  somProcedureVariable : byte;
begin
  // Do someting
end;
 
// This is the main block.
begin
   // Call user-defined procedures etc
   MyProcedure(2);
end.

Types

TRSE supports several data types:

  • byte : values 0-255
  • integer: values 0-65535
  • pointer : 16 address
  • string
  • incbin : include binary file
  • incsid : include SID file

The motorola 68000 as some additional types:

  • long : 32 bit numbers
  • pointer of byte/integer/long : pointer to byte/integer/long array (motorola 68000 only)
  • chipmem specifier: myArray: array[255] of byte chipmem
  •  

Arrays

Arrays of bytes and integers are defined as such:

@define someConstant 25
 
var
   myArray1 : array[128] of byte; // 128 bytes of zeros are declared
   myArray2 : array[4*3] of byte = (0,5,$90, @someConstant);
   myArray3 : array[] of integer = ($1000, $2000, $3000); // unspecified array count
   myArray4 : array[255-55] of byte = (1,2,3); // only 3 values defined, rest will be padded with zeros.

Arrays are accessed as such:

myArray[i]:=someValue*5;

there are no out-of bonds testing in TRSE.

Conditional statements

if

An if-else block in TRSE is defined as such:

if (a=1) then DoSomething();
if (a<>3) then 
begin
   DoSomethingElse();
   IgnoreMe(4);
end;
if (a*2=b*3) then=return() else somethingelse();

Note that an there should be no semicolon “;” before an “else”.
A final note: The “empty” conditional

if (a) then DoSomething() else DoSomethingElse();

is the same as typing “if (a<>0)”

while

While conditionals works similar to if statements:

while (a>0) then do 
begin
  PrintSomething(a);
  dec(a);
end;

Cases

Cases tests a single variable for multiple values as such:

 case i of:
   0: DoSomething();
   1: begin 
        HelloThere();
        b:=b+5;
      end;
   2+i : ThisIsWeird();
  else 
     begin
       PerformElseBlock();
     end;

The else block is optional.

Procedures

Procedures are defined as such:

Procedure NoParameters();
begin
   // .. code here
end;
 
// Procedure with single parameter and variable block
procedure DoSomething(a,b:byte; zp: pointer);
var
  localVar : byte;
 
begin
   zp:=zp+a;
   localVar := a+b; 
   // ...
end;

There are yet no return values for procedures.

For loops

For 6502 systems, only bytes are allowed as counter variables.

for i:=0 to 10 do 
begin
   doSomething(i);
end;
 
for j:=a to b step 2 do 
  someArray[j]:=a+b*j;

Preprocessors

TRSE has a lot of preprocessor directives defined. These can be used to give messages to the compiler before the actual parsing of the program is executed.

Constants

Constants are preprocessors that will be string replaced before compilation occurs.

@define myConstant 4
@define myText "WHOO PARTY"
 
...
a:=@myConstant * 5; // same as 4*5

Ifdef/ifndef