TL/1 is a pascal like one pass compiler for 8bit cpu, which is implented by Hiroshi Ohnishi in 1980. It has very fast compilation speed, but only supports 8bit variable and array. 16bit addressed memory can be accessed by MEM variable.
% TEST PROGRAM ** PROC WAIT,TIME %--- MAIN --- VAR I BEGIN WRITE(1:"Do ") FOR I:=1 TO 10 DO [ WRITE(1:I,CRLF) TIME ] WAIT END %-- PROCEDURE WAIT -- WAIT VAR I,J,K BEGIN FOR I:=0 TO 1 DO [ FOR J:=0 TO 255 DO [ FOR K:=0 TO 255 DO []]] END %-- PROCEDURE TIME -- TIME VAR I,J BEGIN FOR I:=0 TO 10 DO [ FOR J:=0 TO 150 DO []] ENDt2.tl1 t3.tl1
This document is a summary of the language specification of the programming language TL/1. Based on the explanation in magazines and the web etc., it is what I reorganized into the format of the specification with the addition of my interpretation and the indication of ambiguous parts.
We may use terms that are not in the original document for the purpose of explanation.
The places in this text that are referred to as "undefined" are explicit indications that the original source material can not be judged.
Although syntax diagrams are prepared, it is better to read the sentences first and then refer to the syntax diagrams because there is a unique part in the interpretation of identifiers.
The percent sign (%) to the next newline is ignored, and it is treated as whitespace. Use it to describe the program description etc.
It consists of zero or more alphanumeric characters, beginning with an alphabetic character. The word continues up to just before a character (space or symbol) that does not form an identifier. Uppercase and lowercase letters are not distinguished. There is no upper limit on the identifier length.
Reserved words, procedure names, function names, global single variable names, global array names, small area single variables, and small area array names may have the same spelling. It is not checked at the time of declaration if it is identical to the existing name. Except where in the declaration, the implementation tries the name search in the following order and interprets it as the identifier of the first attribute found.
There are 4 types of expressions.
The numbers that can be handled directly with TL/1 are byte sizes, so the numeric representations that appear in a program are always in the range of 0-255.
In places where a boolean value is required in the syntax, 255 is interpreted as true, and other values are interpreted as false. A function that returns a boolean value returns 255 as true and 0 as false.
One or more of the characters 0-9 can be numbers in the range 0-255.
Behavior is not defined if you add an extra 0 at the beginning (such as 02).
Symbols beginning '$' which follows 0 to 9 or a to f represent 0 to 255 in hexadecimal notation. The letters a to f have the same meaning even if they use uppercase letters (A to F).
Do not put a space character after the symbol $.
It is permissible to add an extra 0 (for example $0A) to make two digits in hexadecimal, but if you add more 0 (for example $002) The behavior of) is undefined.
Expressed by a single character between quotes. It is considered that the same numerical value as the one-letter ASCII code is written.
'A' has the same meaning as 65.
represented by TRUE or FALSE . TRUE is equivalent to $FF and FALSE is equal to 0.
Others, symbols are used for operators and syntax, but they will be covered in the syntax description below.
It can be inserted between words. One word is sufficient for word separation, but the meaning does not change even if it continues several times. Please use it to adjust the appearance. The following characters are interpreted as whitespace characters.
There are also habitual meanings to how to use, which will be described later.
Programs are organized in the following order.
The contents of each are as follows.
Comma separated list of the procedure names to be used in the program following the reserved word PROC .
PROC , , ...
The declaration can be ommited if there are zero procedures.
Comma separated list of the function name to be used in the program following the reserved word FUNC .
FUNC , , ...
If the number of functions is zero, the declaration is omitted.
Comma separated list of scalar variable names used throughout the program following the reserved word VAR .
VAR , , ...
The declaration can be ommited if there are zero global scalar variables.
The variables must be within 256 bytes in total with the global array described below. Furthermore, if you call subprogram , you need room for 2 bytes (the sum of global single variable and global array needs to be less than 254 bytes) .
Camma separated list of an array name and its size to be used throughout the program following the reserved word ARRAY . The size of the array is indicated by the numerical value enclosed by square brackets after the array name.
ARRAY [ ] , [ ] , [ ] ...
The size of the array is the maximum value of array subscripts. For example, for arrays declared as A[10], it means that they can be safely referenced with an index of 0-10. It is not the number of elements of the array such as C.
0 or more statements between BEGIN and END .
A subprogram is a procedure or a function. It is organized in the following order:
This is repeated by the number of subprograms.
The definition of a subprogram does not have to match the order of declaration.
The name must be delcared in the procedure or the function name declaration part of the program.
Multiple identifiers enclosed in parentheses. Separate multiple identifiers with commas.
(, , .. .)
Arguments are passed by values. These are local sacalar variables which are initialized with the actual argument at the time of invocation. (Implicit local scalar variable declaration)
If there are no arguments, you can omit the parentheses.
Declare single variables that can be referenced only in the relevant subprogram. The format is the same as a global single variable.
Omit the declaration if there are zero subregion single variables.
Similar to global single variables and global arrays, the combined size of the subregion single variables and the subregion array must be 256 bytes or less.
Declare an array that can be referenced only in the subprogram. The format is the same as for a global array.
You can combine 0 or more statements with one or more statements into one statement.
BEGIN END
{
} [
] (
) Compound sentences behave as if they were one statement, so they can appear anywhere the statement can appear in the following explanation. A compound statement with 0 enclosed execution statements is called a blank statement.
Any parenthesis means the same thing, but it must be closed with the corresponding closing parenthesis. For example, it is not possible to start with "{" and close it with "]".
It is customary to write a semicolon (;) which is ignored as a space character to separate each statement in a compound statement.
The main program and sub program text is also a kind of compound sentence, but as shown above, there must be in BEGIN and END . You can not use other parentheses.
Stop the execution and jump to the monitor.
It is inserted automatically at the end of the main program, so it does not have to be written, but it can be written anywhere in the main program / subprogram.
Returns from a procedure or function.
RETURN
RETURN
When returning from a procedure, write in a format without an expression, and when returning from a function, write in a format followed by one expression.
It is inserted automatically at the end of the procedure, so it does not have to be written, but it can be used anywhere in the procedure. (Do not use it in FOR loop in some implementations).
At least one must be used in the function definition. (Note that it is not checked at compile time. Also, should not be used in a FOR loop)
The behavior when hit is undefined when it reached to the end ( END , which represents the end of the function definition) without passing RETURN statement in a functionRepeats statements while changing the value of a single variable.
FOR : = TO DO
FOR : = DOWNTO DO> Assign the value of the expression to for
counting, and increment or decrease
The increment of by 1 at a time, repeat executing the statements.TO is used, DOWNTO When using it is -1. ( DOWNTO can not use DOWNTO on some implementations.)
is +1 whenREPEAT UNTILis repeated until the value of
becomes true. is a sequence of zero or more execution statements.
WHILE DOIf the value of
is false, it will move to the next processing without executing .
If the value of the expression is true, execute
to return to the evaluation of again.IF THEN
IF THEN ELSEIf the value of
is true, is executed.
ELSE clause is not omitted .
If the value of the is false and theexpression is false and the ELSE clause is omitted, the process proceeds to the next process without doing anything. (In some implementations, ELSE clause Can not be used. )
CASE OF ... ELSEIf the value of
is compared with the value of and it matches . After that, it moves on to the next processing of .
If it does not match, it compares with the expression one after another until it matches in the same way, and executes the execution statement corresponding to the matched expression.
If there is a reserved word ELSE in thepart of the expression, it is regarded as unconditional and
The ELSE clause in theCASE statement is the end of the CASE statement There is also a marker indicating that it is a condition, so it can not be omitted. If there is no statement to be executed in the ELSE clause, write a blank statement.
WRITE ( : )Outputs the contents of the output list to the output device represented by the value of
expression. Although the correspondence between numbers and output devices is undefined, it is generally assumed that 0 is the console screen.
The output list consists of the following output elements, separated by commas if more than one.
Write an expression. Output with decimal number left justified.
# (Outputs the value of , )
with the number of digits of with decimal right justification.
"
"
Output a string enclosed in double quotes.
ASCII ( )
.
SPACE ( )
. If the value of is 0, nothing is output.
CRLF ( )
CRLF
. If the value of is 0, nothing is output.
is omitted form 1 newline output.
HEX ( )
in 2 hexadecimal digits.
Not available on some implementations.
: =
Assign the value of , , ..., : =
to .
If the variable is a comma separated list, assign the value of
to all variables on the left side.Because the assignment symbol consists of two words, colon and equal, even if there is a space character between colon and equal, it is recognized as an assignment symbol, but in general it writes without a space.
Call a procedure.
( , , ... )
A procedure with arguments is called with an actual argument. When calling a procedure that does not have an argument, you can call it with parentheses omitted, but it is an error if you write a procedure without an argument without omitting the parentheses.
FOO ()% such a call is an error
Since the method of passing actual arguments is limited to so-called value passing, even if the actual argument is a variable, the value does not change when returning from the procedure.
Call a machine language subroutine.
CALL ( , , , , )
CALL ( , , , )
CALL ( , , )
CALL ( , )
Each parameter has the following meaning.
upper 8 bits of address | |
lower 8 bits of address | |
value given to accumulator | |
The value given to the H register in the 80th series CPU and the value given to the X register in the 6502 series CPU / tr> | |
Value given to L register in 80 series CPUs, Value given to Y register in 6502 series CPUs |
, , may be abbreviated However, if omitted, each value will be undefined.
This procedure can not be used on some implementations.
The PC detects whether the STOP key has been pressed, and APPLE has detected whether the cont-C has been pressed. If the key has been pressed, it returns to the monitor mode.
Variables are all 1 byte long. There are 4 types below.
VAR An alphanumeric string that begins with a declared letter.
There is a distinction between global and small areas.
[ ]
ARRAY The 's element of a declared array.
There is a distinction between global and small areas.
MEM ( , )
PORT ( )
PC version only.
Corresponds to INP and OUT of N-BASIC. If it is on the left side of the assignment statement, it acts the same as OUT. If it is on the right side, it acts the same as INP.
Numbers .
( , , ..., )
Calls a function declared by a declaration or a system function (described later) provided by the processing system. When calling a function without arguments only the function name You can call It is an error if you try to call a function without arguments in parenthesized form.
FOO: = BAR ()% Such a call is an error
The result of multiplication by 1 byte can be 2 bytes, but only the lower 1 byte is represented in the expression. The upper one byte is stored in a dedicated location, and can be fetched with the MHIGH function.
The division returns the quotient, but at the same time the remainder is calculated and stored in a dedicated location, and can be retrieved using the MOD function.
RND ( )
1 or more
Returns a uniform random number below.GET ( )
and returns the value of its ASCII code.
The correspondence between numbers and input devices is undefined, but in general 0 seems to be a keyboard.
READ ( )
and return that value. The RUBOUT code is considered as a delimiter.
NOT ( )
Returns 1's complement. Same as COM below.
NEG ( )
Returns 2's complement.
COM ( )
Returns 1's complement.
LSR ( )
Shift right by 1 bit. The most significant bit contains 0 and the least significant bit enters the carry.
ASR ( )
Shift right by 1 bit. The most significant bit does not change and the least significant bit goes into carry.
ASL ( )
Shift left by 1 bit. The least significant bit contains 0 and the most significant bit enters the carry.
ROR ( )
Shift right by 1 bit. The carry is in the most significant bit and the least significant bit is in the carry.
ROL ( )
Shift left by 1 bit. The carry is in the least significant bit and the most significant bit is in the carry.
USR ( , , , , )
USR ( , , , )
USR ( , , )
USR ( , )
The function is the same as the CALL statement, but the value of the accumulator after the execution of the machine language subroutine is returned as the return value.
It can not be used depending on the processing system.
RDHEX ( )
Enter one hexadecimal digit from the input device.
It can not be used depending on the processing system.
RRC ( )
Shifts the value of the expression one bit to the right without going through carry. The least significant bit is the most significant.
It can not be used depending on the processing system.
RLC ( )
Shifts the value of the expression one bit to the left without going through carry. The most significant bit is in the least significant bit.
It can not be used depending on the processing system.
This is an operator that calculates two terms on the left and right.
The precedence of
operators is as shown in the table. Operators with the same precedence are left coupled.
1 | multiplication and division operator |
2 | addition-subtraction operator |
3 | relational operators |
4 | logical operators |
5 | carry with addition / subtraction operator |
Use expression brackets if you want to change the priority. The following three types of parentheses can be used as expression brackets, but in the standard case we will use parentheses.
{
} [
] (
It is customary to put periods on both sides that are interpreted as whitespace for the operator of the identifier rather than the ) symbol. In my opinion, it is thought to be a device that makes it easier to distinguish from function calls.
. AND .
* | multiplication |
/ | quotient of division |
+ | addition |
- | subtraction |
Compares two values and returns a boolean value. GT and LT compare and compare left and right numbers as signed binary numbers in 2's complement representation. Other operators interpret numbers as unsigned binary.
> | large |
< | small |
# | not equal |
= | equal |
GT | large |
LT | large |
AND | logical product |
OR | disjunction |
EOR | exclusive OR |
An operator that adds two terms and adds the carry value, or subtracts two terms and subtracts the carry value.
ADC | Add with Carry |
SBC | subtraction with borrow |
While it is specified that part of the system function changes the flag, it is undefined which process changes the flag. In general, addition and subtraction seem to change the flag, but depending on the processing system, it may be changed when accessing an array element. It is considered safe to use carry addition / subtraction only immediately after addition / subtraction.