-- This is a comment
! This is a comment
! This is a bracketted comment !
STRING - 1 bytes integer 0 to 255, EG STRING(2) x; is a 2 byte ascii string
INT - 2 bytes, 0 to 65,535 or -32,768 to + 32,767. This can also be a string EG: INT twochars := "CH";
INT(32) - 4 bytes
UNSIGNED(1~15) - n bits, 0 thru (2**n - 1)
UNSIGNED(16) - 0 to 65,535, or -32,768 to +32,767. This is your standard address
FIXED - 8 bytes, for FIXED(0) or FIXED(*) the range is -9 kazillion to +9 kazillion
REAL - 4 bytes, precise to 9 digits
REAL(64) - 8 bytes, precise to 17 digits
INT(16) is the same as INT
INT(64) is the same as FIXED(0)
REAL(32) is the same as REAL
Examples:
LITERAL double_word = (4 * 8);
INT (double_word) num; ! num is a INT(32)
INT x := 4 ! x is decimal 4
INT x := %177 ! x is Octal 177
INT x := %B01010 ! x is Binary 01010
INT x := %B0000000000000010 ! x is 2;
INT x := %B1111111111111110 ! x is -2 (using twos compliment);
INT x := %H1A ! x is Hex 1A
FIXED(3) x := 0.642F; ! x is 642000, the 3 shifts the decimal right
FIXED(-3) x := 642945F; ! x is 642000, the -3 shifts the decimal left
FIXED(*) x := 123 ! x is stored, not scaled
BLOCK x ; ! Declare Global Variables
INT flag := TRUE;
INT(32) index := 22 ;
END BLOCK ;
BLOCK PRIVATE ; ! Declare Local Variables
INT myflag := TRUE;
INT(32) myindex := 22 ;
END BLOCK ;
PROC paragraph_x ; FORWARD ; ! Declares that paragraph_x will be out of compile sequence
PROC called_program; EXTERNAL ; ! Declares that a paragraph can be found in a called program
PROC paragraph_x (param) ;
BEGIN
INT param;
END;
PROC paragraphs_nested (param) ;
BEGIN
ENTRY entry_point ; ! Declares a programs entry point
some code
SUBPROC entry_subroutine(x) ; ! Declares a subroutine with a PROC
BEGIN
some code
END;
entry_point:
some more code
END;
PROC myproc;
BEGIN !Local data declarations
SUBPROC some_sub (param); !Declare subprocedure
INT param;
ENTRY sub_entry; ! Declare entry-point identifier
INT var; ! Some code here
sub_entry: ! Apply entry-point
var := var - param; ! identifier to statement
some code ; ! Tal can get ugly very quickly
END; ! End subprocedure
some code
!Local statements
CALL sub_entry (1); !Call entry-point SUB_ENTRY
END;
PROC xx(v1,v2,v3);
BEGIN...END;
...CALL xx(v1, !nothing!, v3) ! Comments help document ommited variables
DEFINETOG omit !
some code
?IF omit
some code
?ENDIF omit
Sample compile statement: suppress octal code after each line, suppress all but header information, compile for syntax only
and puts the errors in a file called xxx, and sets the omit toggle on
TAL/in myprogram/;nocode, suppress, syntax, errorfile xxx,settog omit,
Operators:
x := 2 ! move 2 to a number
x ':=' 'AB' ! move characters to a string
x := @var ! x is the address of var
.x ! convert x from a INT to the word address of another variable
<< ! Signed Left shift
'<<' ! Unsigned Left shift
+ - * ! Signed operators for add, subtract and multiply
'+' '-' '*' ! Unsigned operators for add, subtract and multiply
= <= >= ! comparisons
'=' '<=' ! comparisons (unsigned)
<> ! Not equal
According to the manual, you can do math on a string variable. EG: STRING x; x ':=' 'A"; x := x * 2; Go figure?