# HG changeset patch # User Shinji KONO # Date 1555208367 -32400 # Node ID ce695e5e38d8e9f221cecb9cb814686b3d3bf091 # Parent 7dd634f92ffd47d04099e11e4076e1f4d0af41ac documents diff -r 7dd634f92ffd -r ce695e5e38d8 TL1/tl1.html --- a/TL1/tl1.html Sun Apr 14 00:09:34 2019 +0900 +++ b/TL1/tl1.html Sun Apr 14 11:19:27 2019 +0900 @@ -7,6 +7,46 @@

TL/1 language specification

Introduction

+

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. + +

example TL/1 source

+ + t1.tl1 +
+% 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 []]
+END
+
+ + t2.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.

@@ -23,13 +63,13 @@   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.

    -
  1. Local array name -
  2. Local single variable name -
  3. Global array name -
  4. Global single variable name -
  5. function name -
  6. Procedure name -
  7. reserved words +
  8. Local array name
  9. +
  10. Local single variable name
  11. +
  12. Global array name
  13. +
  14. Global single variable name
  15. +
  16. function name
  17. +
  18. Procedure name
  19. +
  20. reserved words

Number

@@ -38,8 +78,8 @@

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.

decimal constant

-

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). +

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).

Hexadecimal constant

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).

@@ -47,11 +87,11 @@

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.

Character literal constant

-

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.
+

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.

Logical constant

-

represented by TRUE or FALSE . TRUE is equivalent to $FF and FALSE is equal to 0. +

represented by TRUE or FALSE . TRUE is equivalent to $FF and FALSE is equal to 0.

symbol

Others, symbols are used for operators and syntax, but they will be covered in the syntax description below.

@@ -67,7 +107,7 @@

There are also habitual meanings to how to use, which will be described later.

Program configuration

-

Programs are organized in the following order. +

Programs are organized in the following order.

      
  1. Procedure name declaration
  2. @@ -84,31 +124,31 @@

    Comma separated list of the procedure names to be used in the program following the reserved word PROC .

    - PROC   procedure 1 ,  procedure 2 ,  Procedure 3  ...
    -
    -

    The declaration can be ommited if there are zero procedures. + PROC procedure 1 , procedure 2 , Procedure 3 ... +

    +

    The declaration can be ommited if there are zero procedures.

    Function name declaration

    Comma separated list of the function name to be used in the program following the reserved word FUNC .

    - FUNC   function 1 ,  function 2 ,  Function 3  ...
    -
    + FUNC   function 1 ,  function 2 ,  Function 3  ...
    +

    If the number of functions is zero, the declaration is omitted.

    Global scalar variable name declaration

    Comma separated list of scalar variable names used throughout the program following the reserved word VAR .

    - VAR   single variable 1 ,  single variable 2 ,  single variable 3  ...
    -
    + VAR   single variable 1 ,  single variable 2 ,  single variable 3  ...
    +

    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) .

    Global array name / array size declaration

    -

    Camma separated list of an array name and its size to be used throughout the program following the reserved word ARRAY . +

    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.

     
    @@ -120,63 +160,63 @@
     

    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.

    -

    Main program definition -

    0 or more statements between BEGIN and END . +

    Main program definition

    +

    0 or more statements between BEGIN and END .

    Subprogram definitions

    -

    A subprogram is a procedure or a function. It is organized in the following order: +

    A subprogram is a procedure or a function. It is organized in the following order:

    1. Sub-program name
    2. formal argument list
    3. Sub-area single variable name declaration
    4. Small-area array name / array size declaration
    5. Reserved words BEGIN
    6. -
    7. 0 or more executable statements +
    8. 0 or more statements
    9. Reserved words END
    10. - +
    -

    This is repeated by the number of subprograms. +

    This is repeated by the number of subprograms.

    The definition of a subprogram does not have to match the order of declaration.

    Sub program name

    -

    The name must be delcared in the procedure or the function name declaration part of the program. +

    The name must be delcared in the procedure or the function name declaration part of the program.

    Formal argument list

    -

    Multiple identifiers enclosed in parentheses. Separate multiple identifiers with commas. +

    Multiple identifiers enclosed in parentheses. Separate multiple identifiers with commas.

    -( argument 1 ,  argument 2 ,  argument 3  .. .)
    -
    +( argument 1 ,  argument 2 ,  argument 3  .. .)
    +

    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) +(Implicit local scalar variable declaration)

    If there are no arguments, you can omit the parentheses.

    Local scalar variable name declaration

    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. +

    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.

    Local array name declaration

    -

    Declare an array that can be referenced only in the subprogram. The format is the same as for a global array. +

    Declare an array that can be referenced only in the subprogram. The format is the same as for a global array.

    statements

    compound statements

    -

    You can combine 0 or more executable statements with one or more executable statements into one executable statement.

    -
      BEGIN   executable statement list   END  
    -
     { executable statement list } 
    -
     [ executable statement list ] 
    -
     ( executable statement list ) 
    -

    Compound sentences behave as if they were one executable statement, -so they can appear anywhere the executable statement can appear in the following explanation. +

    You can combine 0 or more statements with one or more statements into one statement.

    +
      BEGIN   statement list   END  
    +
     { statement list } 
    +
     [ statement list ] 
    +
     ( statement list ) 
    +

    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 executable statement in a compound statement. +

    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. + BEGIN and END . +You can not use other parentheses.

    STOP

    Stop the execution and jump to the monitor.

    @@ -191,309 +231,318 @@

    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).

    +

    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) +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 function

    +to the end ( END , which represents the end of the function definition) +without passing RETURN statement in a function

    -

    FOR

    -

    単変数の値を変化させながら繰返しする処理を表します。

    -
    -FOR 単変数 :=  TO  DO 実行文
    +

    FOR

    +

    Repeats statements while changing the value of a single variable.

    +
    + FOR   variable : =  expression   TO   expression   DO   statements 
     
    -
    -FOR 単変数 := 式1 DOWNTO 式2 DO 実行文
    -

    カウント用の 単変数 に式の値を代入し、 単変数 を 1 ずつ増加または減少させながら実行文を繰返します。

    -

    単変数 の増分は、 TO を用いたとき +1 、 DOWNTO を用いたときは -1 です。 (一部の処理系では DOWNTO を使えません。)

    +
    + FOR   variable : =  expression 1   DOWNTO   expression 2   DO   statements  
    > +Assign the value of the expression to the scalar variable for

    counting, and increment or decrease scalar variable by 1 at a time, repeat executing the statements.

    +The increment of

    variable is +1 when TO is used, DOWNTO When using it is -1. ( DOWNTO can not use DOWNTO on some implementations.)

    -

    REPEAT

    -
    REPEAT 文リスト UNTIL 
    -

    の値が真値になるまで 文リスト を繰返し実行します。 文リスト は 0 個以上の実行文を並べたものです。

    +

    REPEAT

    +
      REPEAT   statement list   UNTIL   expression  
    + statement list is repeated until the value of

    expression becomes true. statement list is a sequence of zero or more execution statements.

    -

    WHILE

    -
    WHILE  DO 実行文
    -

    の値が偽ならば 実行文 を実行せずに次の処理へ移ります。

    -

    式の値が真の場合は 実行文 を実行して再び の評価に戻ります。

    +

    WHILE

    +
      WHILE   expression   DO   statement  
    +If the value of

    expression is false, it will move to the next processing without executing statement .

    +

    If the value of the expression is true, execute execution statement to return to the evaluation of expression again.

    -

    IF

    -
    IF  THEN 実行文1
    -
    IF  THEN 実行文1 ELSE 実行文2
    -

    の値が真なら 実行文1を実行します。

    -

    の値が偽であり ELSE 節が省略されていないならば 実行文2 を実行します。

    -

    式の値が偽であり ELSE 節が省略されているならば何もせずに次の処理へ移ります。 (一部の処理系では ELSE 節は使えません。)

    +

    IF

    +
      IF   expression   THEN   statement 1  
    +
      IF   expression   THEN   statement 1   ELSE   statement 2  
    +If the value of

    expression is true, execute statement 1 is executed.

    +

    if the value of the expression is false and the ELSE clause is not omitted statement 2 .

    +If the value of the

    expression 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

    -
    +

    CASE

    +
     
    -CASE 式0 OF
    -     式1 実行文1
    -     ...
    -     式k-1 実行文k-1
    -     ELSE 実行文k
    + CASE   expression 0   OF 
    +      expression 1   statement 1 
    +     ...
    +      expression k-1   statement k-1 
    +      ELSE   statement k 
     
    -

    式0 の値を 式1 の値と比較して合致すれば 実行文1 を実行します。 その後は 実行文k の次の処理に移ります。

    -

    合致しなければ、同様にして合致するまで次々と式と比較し、合致した式に対応した実行文を実行します。

    -

    式の箇所に予約語 ELSE が有った場合は無条件に合致したものとみなして 実行文k を実行します。

    -

    CASE 文における ELSE 節は CASE 文の最後の条件であることを示すマーカーでもあるので省略することは出来ません。 ELSE 節に実行すべき実行文がない場合は空文を書いてください。

    -

    WRITE

    -
    -WRITE (  : 出力リスト )
    +If the value of 

    expression 0 is compared with the value of expression 1 and it matches Execution statement 1 . After that, it moves on to the next processing of statement k .

    +

    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 the

    part of the expression, it is regarded as unconditional and statement k

    +The ELSE clause in the

    CASE 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

    +
    + WRITE  ( expression :  output list )
     
    -

    式の値が表す出力装置に対して出力リストの内容を出力します。 数値と出力装置との対応付けについては未定義ですが、一般的に 0 はコンソール画面であるとされています。

    -

    出力リストは以下の出力要素からなり、ひとつ以上の場合はカンマで区切ります。

    -

    -

    式を記述します。 十進数左詰めで出力します。

    -

    右詰め

    -
    -# ( 式1 , 式2 )
    +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.

    +

    expression

    +

    Write an expression. Output with decimal number left justified.

    +

    right justified

    +
    +# ( expression 1 ,  expression 2 )
     
    -

    式2 の値を 式1 の桁数で十進右詰めで出力します。

    -

    文字列

    -
    -" 文字列 "
    +Outputs the value of 

    expression 2 with the number of digits of expression 1 with decimal right justification.

    +

    string

    +
    +"  string  "
     
    -

    ダブルクォーテーションで囲まれた文字列を出力します。

    -

    アスキーコード

    -
    -ASCII (  )
    +

    Output a string enclosed in double quotes.

    +

    ASCII code

    +
    + ASCII  ( expression )
     
    -

    で与えられたアスキーコードに相当する文字を出力します。

    -

    空白

    -
    -SPACE (  )
    +

    Outputs the character equivalent to the ASCII code given by the expression .

    + +

    blank

    +
    + SPACE  ( expression )
     
    -

    で与えられた個数分の空白を出力します。 の値が 0 の場合は何も出力しません。

    -

    改行

    -
    -CRLF (  )
    +

    Outputs the number of blanks given by the expression . If the value of expression is 0, nothing is output.

    +

    Line feed

    +
    + CRLF  ( expression )
     
    -
    -CRLF
    +
    + CRLF 
     
    -

    で与えられた個数分の改行を出力します。 の値が 0 の場合は何も出力しません。

    -

    を省略した形式の場合は 1 個の改行を出力します。

    -

    十六進数

    -
    -HEX (  )
    +

    Outputs the number of line breaks given by the expression . If the value of expression is 0, nothing is output.

    +

    expression is omitted form 1 newline output.

    +

    Hex

    +
    + HEX  ( expression )
     
    -

    で与えられた値を十六進数 2 桁で出力します。

    -

    一部の処理系では使えません。

    +

    output the value given by the expression in 2 hexadecimal digits.

    +

    Not available on some implementations.

    -

    代入

    -
    変数 := 
    -
    変数1 , 変数2 , ... , 変数k := 
    -

    の値を 変数 に代入します。

    -

    変数がカンマで区切られたリストの場合は の値を左辺全ての変数に代入します。

    -

    代入記号はコロンとイコールの 2 語から成っているのでコロンとイコールの間に空白文字が有っても代入記号として認識されますが、一般的には間を空けずに書きます。

    +

    Assignment

    +
      variable : =  expression  
    +
      variable 1 ,  variable 2 , ...,  Variable k : =  expression  
    +Assign the value of

    expression to variable .

    +

    If the variable is a comma separated list, assign the value of expression 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.

    -

    手続き呼出し

    -

    手続きを呼出します。

    -
    -手続き名 (  ,   , ...   )
    +

    Procedure call

    +

    Call a procedure.

    +
    + procedure name  ( expression ,  expression , ...  expression )
     
    -
    -手続き名
    +
    + procedure name 
     
    -

    引数をもつ手続きでは実引数を与えて呼出します。 引数を持たない手続きを呼出す場合には丸括弧ごと省略した記法で呼出せますが、引数を持たない手続きを丸括弧を省略せずに記述した場合はエラーです。

    -
    -FOO() % このような呼び方はエラー
    +

    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

    -

    機械語サブルーチンを呼出します。

    -
    -CALL ( AH , AL , A , H , L )
    +

    CALL

    +

    Call a machine language subroutine.

    +
    + CALL  ( AH ,  AL ,  A ,  H ,  L )
     
    -
    -CALL ( AH , AL , A , H )
    +
    + CALL  ( AH ,  AL ,  A ,  H )
     
    -
    -CALL ( AH , AL , A )
    +
    + CALL  ( AH ,  AL ,  A )
     
    -
    -CALL ( AH , AL )
    +
    + CALL  ( AH ,  AL )
     
    -

    各パラメータは以下の意味を持ちます。

    +

    Each parameter has the following meaning.

    - - - - - + + + + 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
    AHアドレスの上位 8 ビット
    ALアドレスの下位 8 ビット
    Aアキュムレータに与える値
    H80 系 CPU では H レジスタに与える値、 6502 系 CPU では X レジスタに与える値
    L80 系 CPU では L レジスタに与える値、 6502 系 CPU では Y レジスタに与える値
    AH upper 8 bits of address
    AL lower 8 bits of address
    A value given to accumulator
    H
    L
    -

    A, H, L は省略した形式がありますが、省略した場合はそれぞれの値は不定となります。

    -

    この手続きは一部の処理系では利用できません。

    +

    A , H , L may be abbreviated However, if omitted, each value will be undefined.

    +

    This procedure can not be used on some implementations.

    -

    SENSE

    -

    PC では STOP キー、 APPLE では cont-C が押されているか否かを検出し、押されていればモニタモードに戻ります。

    +

    SENSE

    +

    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.

    -

    変数

    -

    変数はすべて 1 バイト長です。 以下の 4 種類があります。

    -

    単変数

    -

    VAR 宣言された英字で始まる英数字の列です。

    -

    大域、小域の区別があります。

    +

    Variables

    +

    Variables are all 1 byte long. There are 4 types below.

    +

    Single variable

    +

    VAR An alphanumeric string that begins with a declared letter.

    +

    There is a distinction between global and small areas.

    -

    配列変数

    -
    配列変数名 [  ]
    -

    ARRAY 宣言された配列の 番目の要素です。

    -

    大域、小域の区別があります。

    +

    Array variable

    +
      array variable name  [ expression ] 
    +

    ARRAY The expression 's element of a declared array.

    +

    There is a distinction between global and small areas.

    -

    MEM変数

    -
    MEM ( 式1 , 式2 )
    -

    式1 の値を上位、 式2 の値を下位のアドレスとするメモリ内の 1 バイト。

    +

    MEM variable

    +
      MEM  ( formula 1 ,  formula 2 ) 
    +

    1 byte in memory with the value of expression 2 as the lower address.

    -

    PORT

    -
    PORT  ( )
    -

    PC 版専用です。

    -

    N-BASIC の INP, OUT に相当します。 代入文の左辺にあれば OUT 、 右辺にあれば INP と同等の作用をします。

    +

    PORT

    +
      PORT  ( expression ) 
    +

    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.

    -

    -

    定数

    -

    数値の項で示した 4 種類のいずれかの形式で定数を表します。

    -

    関数呼出し

    -
    関数名 ( 式1 , 式2 , ... , 式k )
    -
    関数名
    -

    FUNC 宣言によって宣言された関数、または処理系が用意しているシステム関数 (後述) を呼出します。 引数のない関数を呼出す場合は関数名のみで呼出せます。 引数がない関数を括弧付きの書式で呼出そうとした場合はエラーです。

    -
    -FOO := BAR() % このような呼び方はエラー
    +

    expression

    +

    Constant

    +Represents a constant in one of the four formats shown in

    Numbers .

    +

    Function call

    +
      function name  ( formula 1 ,  formula 2 , ...,  expression k ) 
    +
      function name  
    +

    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
     
    -

    MHIGH

    -

    1 バイト同士の掛け算の結果は 2 バイトになり得ますが、式の中では下位 1 バイトしか表現されません。 上位 1 バイトは専用の場所に格納されており、 MHIGH 関数で取出すことが出来ます。

    -

    MOD

    -

    割り算すると商が返りますが、同時に余が計算されて専用の場所に格納されており、 MOD 関数で取出すことが出来ます。

    -

    RND

    -
    -RND (  )
    +

    MHIGH

    +

    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.

    +

    MOD

    +

    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

    +
    + RND  ( expression )
     
    -

    1 以上 以下の一様乱数を返します。

    -

    GET

    -
    -GET (  )
    +

    1 or more expression Returns a uniform random number below.

    + +

    GET

    +
    + GET  ( expression )
     
    -

    が表す入力装置から 1 文字を入力し、そのアスキーコードの値を返します。

    -

    数値と入力装置の対応付けは未定義ですが、一般に 0 はキーボードであるようです。

    -

    READ

    -
    -READ (  )
    +

    Enters one character from the input device represented by the expression 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

    +
    + READ  ( expression )
     
    -

    の値に対応する入力装置から十進数を 1 つ入力し、その値を返します。 RUBOUT コードは区切り記号とみなされます。

    -

    NOT

    -
    -NOT (  )
    +

    Enter a decimal number from the input device that corresponds to the value of the expression and return that value. The RUBOUT code is considered as a delimiter.

    +

    NOT

    +
    + NOT  ( expression )
     
    -

    1 の補数を返します。 後述の COM と同じです。

    -

    NEG

    -
    -NEG (  )
    +

    Returns 1's complement. Same as COM below.

    +

    NEG

    +
    + NEG  ( expression )
     
    -

    2 の補数を返します。

    -

    COM

    -
    -COM (  )
    +

    Returns 2's complement.

    +

    COM

    +
    + COM  ( expression )
     
    -

    1 の補数を返します。

    -

    LSR

    -
    -LSR (  )
    -
    -

    1 ビット右シフトします。 最上位ビットには 0 が入り、最下位ビットはキャリーに入ります。

    -

    ASR

    -
    -ASR (  )
    +

    Returns 1's complement.

    + +

    LSR

    +
    + LSR  ( expression )
     
    -

    1 ビット右シフトします。 最上位ビットは変化せず、最下位ビットはキャリーに入ります。

    -

    ASL

    -
    -ASL (  )
    +

    Shift right by 1 bit. The most significant bit contains 0 and the least significant bit enters the carry.

    +

    ASR

    +
    + ASR  ( expression )
    +
    +

    Shift right by 1 bit. The most significant bit does not change and the least significant bit goes into carry.

    +

    ASL

    +
    + ASL  ( expression )
     
    -

    1 ビット左シフトします。 最下位ビットには 0 が入り、最上位ビットはキャリーに入ります。

    -

    ROR

    -
    -ROR (  )
    +

    Shift left by 1 bit. The least significant bit contains 0 and the most significant bit enters the carry.

    +

    ROR

    +
    + ROR  ( expression )
     
    -

    1 ビット右シフトします。 キャリーは最上位ビットに入り、最下位ビットはキャリーに入ります。

    -

    ROL

    -
    -ROL (  )
    +

    Shift right by 1 bit. The carry is in the most significant bit and the least significant bit is in the carry.

    +

    ROL

    +
    + ROL  ( expression )
     
    -

    1 ビット左シフトします。 キャリーは最下位ビットに入り、最上位ビットはキャリーに入ります。

    -

    USR

    -
    USR ( AH , AL , A , AH , L )
    -
    USR ( AH , AL , A , AH )
    -
    USR ( AH , AL , A )
    -
    USR ( AH , AL )
    -

    CALL 文と機能は同じですが、機械語サブルーチン実行後のアキュムレータの値を返却値として返します。

    -

    処理系によっては使えません。

    -

    RDHEX

    -
    RDHEX ()
    -

    入力装置から十六進数1桁を入力します。

    -

    処理系によっては使えません。

    -

    RRC

    RRC ()
    -

    キャリーを経由せずに式の値を右に 1 ビットシフトします。 最下位ビットは最上位に入ります。

    -

    処理系によっては使えません。

    -

    RLC

    -
    RLC ()
    -

    キャリーを経由せずに式の値を左に 1 ビットシフトします。 最上位ビットは最下位ビットに入ります。

    -

    処理系によっては使えません。

    -

    二項演算子

    -

    左右に 2 個の項をとって計算する演算子です。

    -
    項1 演算子 項2
    -

    演算子の優先順位は表の通りです。 優先順位の同じ演算子は左結合します。

    +

    Shift left by 1 bit. The carry is in the least significant bit and the most significant bit is in the carry.

    + +

    USR

    +
      USR  ( AH ,  AL ,  A ,  AH ,  L ) 
    +
      USR  ( AH ,  AL ,  A ,  AH ) 
    +
      USR  ( AH ,  AL ,  A ) 
    +
      USR  ( AH ,  AL ) 
    +

    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

    +
      RDHEX  ( expression ) 
    +

    Enter one hexadecimal digit from the input device.

    +

    It can not be used depending on the processing system.

    +

    RRC

      RRC  ( expression ) 
    +

    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

    +
      RLC  ( expression ) 
    +

    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.

    + +

    Binary operator

    +

    This is an operator that calculates two terms on the left and right.

    +
      term 1   operator   term 2  
    +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
    -

    優先順位を変更したい場合は式括弧を使用します。 以下 3 種類の括弧が式括弧として使えますが標準的には丸括弧を用いることとします。

    -
    {  }
    -
    [  ]
    -
    (  )
    -

    記号ではなく識別子の演算子については空白文字と解釈されるピリオドを両側に置く習慣があります。 私見ですが、関数呼出しとの区別をしやすくする工夫だと考えられます。

    -
    .AND.
    +

    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.

    +
     { expression } 
    +
     [ expression ] 
    +
     ( expression ) 
    +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 division operator

    - - + +
    *乗算
    /除算の商
    * multiplication
    / quotient of division
    -

    加減算演算子

    +

    Addition-subtraction operator

    - - + +
    +加算
    -減算
    + addition
    - subtraction
    -

    関係演算子

    -

    2 つの値を比較して真偽値を返します。 GTLT は左右の数値を 2 の補数表現の符号付き二進数とみなして比較します。 その他の演算子は数を符号なし二進数と解釈します。

    +

    Relational operator

    +

    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.

    - - - - - - + + + + + +
    >大きい
    <小さい
    #等しくない
    =等しい
    GT大きい
    LT大きい
    > large
    < small
    # not equal
    = equal
    GT large
    LT large
    -

    論理演算子

    +

    Logical operator

    - - - + + +
    AND論理積
    OR論理和
    EOR排他的論理和
    AND logical product
    OR disjunction
    EOR exclusive OR
    -

    キャリー付き加減算演算子

    -

    二項を足した上でキャリーの値を足す、または二項を減算した上でキャリーの値を引く演算子です。

    +

    Carry with addition and subtraction operator

    +

    An operator that adds two terms and adds the carry value, or subtracts two terms and subtracts the carry value.

    - - + +
    ADCキャリー付き加算
    SBCボロー付き減算
    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.

    + diff -r 7dd634f92ffd -r ce695e5e38d8 TL1/tl1j.html --- a/TL1/tl1j.html Sun Apr 14 00:09:34 2019 +0900 +++ b/TL1/tl1j.html Sun Apr 14 11:19:27 2019 +0900 @@ -5,7 +5,51 @@ + +

    TL/1 とは

    + +

    TL/1 はPacal likeな 8 bit cpu 用の 1 pass コンパイラです。1980年に大西博氏によってMC6800用に設計実装されました。 +高速なコンパイルが特徴ですが変数と配列は8bitのみ。16bit アドレスのメモリ空間にはMEM変数を使ってアクセスします。 + +

    TL/1 のソースコード例

    + + t1.tl1 +
    +% 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 []]
    +END
    +
    + + t2.tl1 + + t3.tl1 +

    TL/1 言語仕様

    +

    概要

    この文章はプログラミング言語 TL/1 の言語仕様のまとめです。 雑誌やウェブ上にある説明などを元にして私の解釈や曖昧箇所の指摘を加えて仕様の体裁に再構成したものです。

    説明のために元資料にない用語を使う場合もあります。