# HG changeset patch
# User Shinji KONO 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.
+
+ 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.TL/1 language specification
Introduction
+ 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
+
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.
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. p> -
Behavior is not defined if you add an extra 0 at the beginning (such as 02). p> +
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).
@@ -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.
Expressed by a single character between quotes. It is considered that the same numerical value as the one-letter ASCII code is written. p> -
'A' has the same meaning as 65. pre> +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 span> or FALSE span>. TRUE span> is equivalent to $FF and FALSE span> is equal to 0. p> +
-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. p> +
Programs are organized in the following order.
- Procedure name declaration
@@ -84,31 +124,31 @@Comma separated list of the procedure names to be used in the program following the reserved word PROC .
- PROC span>
+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 span>
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 span> , ,
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 span>. +
+to the end ( END , which represents the end of the function definition) +without passing RETURN statement in a functionCamma 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 h3> -
0 or more statements between BEGIN and END . p> +
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: p> +
A subprogram is a procedure or a function. It is organized in the following order:
-
- Sub-program name
- formal argument list
- Sub-area single variable name declaration
- Small-area array name / array size declaration
- Reserved words BEGIN
-- 0 or more executable statements li> +
- 0 or more statements
- Reserved words END
- ol> +This is repeated by the number of subprograms. p> +
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. p> +
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. p> +
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) p> +(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. p> +
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. p> +
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 span>
-{
- }[
- ](
- )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 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 executable statement in a compound statement. p> +
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 span> and END . -You can not use other parentheses. p> + 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 span> 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) p> +should not be used in a FOR loop)
The behavior when hit is undefined when it reached -to the end ( END span>, which represents the end of the function definition) -without passing RETURN span> statement in a functionFOR
-単変数の値を変化させながら繰返しする処理を表します。
--FOR := TO DO +FOR
+Repeats statements while changing the value of a single variable.
++ FOR : = TO DO--FOR := DOWNTO DO-カウント用の
- に式の値を代入し、 を 1 ずつ増加または減少させながら実行文を繰返します。TO を用いたとき +1 、 DOWNTO を用いたときは -1 です。 (一部の処理系では DOWNTO を使えません。)
+ の増分は、+ FOR : = DOWNTO DO> +Assign the value of the expression to forcounting, 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
-REPEAT UNTIL-+ の値が真値になるまで を繰返し実行します。 は 0 個以上の実行文を並べたものです。
REPEAT
+REPEAT UNTIL+ is repeated until the value of- becomes true. is a sequence of zero or more execution statements.
WHILE
-WHILE DO-- の値が偽ならば を実行せずに次の処理へ移ります。
式の値が真の場合は
+ を実行して再び の評価に戻ります。WHILE
+WHILE DO+If 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
-IF THEN-IF THEN ELSE-- の値が真なら を実行します。
ELSE 節が省略されていないならば を実行します。
- の値が偽であり式の値が偽であり ELSE 節が省略されているならば何もせずに次の処理へ移ります。 (一部の処理系では ELSE 節は使えません。)
+IF
+IF THEN+IF THEN ELSE+If 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
-+CASE
+-CASE OF - - ... - - ELSE + CASE OF + + ... + + ELSE-- の値を の値と比較して合致すれば を実行します。 その後は の次の処理に移ります。
合致しなければ、同様にして合致するまで次々と式と比較し、合致した式に対応した実行文を実行します。
-式の箇所に予約語 ELSE が有った場合は無条件に合致したものとみなして を実行します。
-CASE 文における ELSE 節は CASE 文の最後の条件であることを示すマーカーでもあるので省略することは出来ません。 ELSE 節に実行すべき実行文がない場合は空文を書いてください。
-WRITE
--WRITE ( : ) +If 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
++ WRITE ( : )-式の値が表す出力装置に対して出力リストの内容を出力します。 数値と出力装置との対応付けについては未定義ですが、一般的に 0 はコンソール画面であるとされています。
-出力リストは以下の出力要素からなり、ひとつ以上の場合はカンマで区切ります。
-式
-式を記述します。 十進数左詰めで出力します。
-右詰め
--# (, ) +Outputs the contents of the output list to the output device represented by the value ofexpression. 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
++# (- , )- の値を の桁数で十進右詰めで出力します。
文字列
--"" +Outputs the value of+ with the number of digits of with decimal right justification.
string
++"
- "ダブルクォーテーションで囲まれた文字列を出力します。
-アスキーコード
--ASCII ( ) +Output a string enclosed in double quotes.
+ASCII code
++ ASCII ( )-- で与えられたアスキーコードに相当する文字を出力します。
空白
--SPACE ( ) ++ + .
blank
++ SPACE ( )-- で与えられた個数分の空白を出力します。 の値が 0 の場合は何も出力しません。
改行
--CRLF ( ) ++ . If the value of is 0, nothing is output.
Line feed
++ CRLF ( )--CRLF ++ CRLF
-- で与えられた個数分の改行を出力します。 の値が 0 の場合は何も出力しません。
- を省略した形式の場合は 1 個の改行を出力します。
十六進数
--HEX ( ) ++ . If the value of is 0, nothing is output.
+ is omitted form 1 newline output.
Hex
++ HEX ( )-- で与えられた値を十六進数 2 桁で出力します。
一部の処理系では使えません。
++ in 2 hexadecimal digits.
Not available on some implementations.
-代入
-- :=- , , ... , :=- の値を に代入します。
変数がカンマで区切られたリストの場合は
- の値を左辺全ての変数に代入します。代入記号はコロンとイコールの 2 語から成っているのでコロンとイコールの間に空白文字が有っても代入記号として認識されますが、一般的には間を空けずに書きます。
+Assignment
++ : =+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.
-手続き呼出し
-手続きを呼出します。
--( , , ... ) +Procedure call
+Call a procedure.
++- ( , , ... )-++
-引数をもつ手続きでは実引数を与えて呼出します。 引数を持たない手続きを呼出す場合には丸括弧ごと省略した記法で呼出せますが、引数を持たない手続きを丸括弧を省略せずに記述した場合はエラーです。
--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 ( , , , , ) +CALL
+Call a machine language subroutine.
++ CALL ( , , , , )--CALL ( , , , ) ++ CALL ( , , , )--CALL ( , , ) ++ CALL ( , , )--CALL ( , ) ++ CALL ( , )-各パラメータは以下の意味を持ちます。
+Each parameter has the following meaning.
アドレスの上位 8 ビット | |
アドレスの下位 8 ビット | |
アキュムレータに与える値 | |
80 系 CPU では H レジスタに与える値、 6502 系 CPU では X レジスタに与える値 | |
80 系 CPU では L レジスタに与える値、 6502 系 CPU では Y レジスタに与える値 | +|
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.
-PC では STOP キー、 APPLE では cont-C が押されているか否かを検出し、押されていればモニタモードに戻ります。
+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 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 宣言された配列の 番目の要素です。
-大域、小域の区別があります。
++ [ ]
ARRAY The 's element of a declared array.
+There is a distinction between global and small areas.
-MEM ( , )-
+ の値を上位、 の値を下位のアドレスとするメモリ内の 1 バイト。
MEM ( , )+
-
PORT ( )-
PC 版専用です。
-N-BASIC の INP, OUT に相当します。 代入文の左辺にあれば OUT 、 右辺にあれば INP と同等の作用をします。
+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.
-数値の項で示した 4 種類のいずれかの形式で定数を表します。
-- ( , , ... , )
-FUNC 宣言によって宣言された関数、または処理系が用意しているシステム関数 (後述) を呼出します。 引数のない関数を呼出す場合は関数名のみで呼出せます。 引数がない関数を括弧付きの書式で呼出そうとした場合はエラーです。
--FOO := BAR() % このような呼び方はエラー +expression
+Constant
+Represents a constant in one of the four formats shown inNumbers .
+Function call
++ ( , , ..., )+
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 ( )-1 以上
- 以下の一様乱数を返します。GET
--GET ( ) +1 or more
+ + Returns a uniform random number below.GET
++ GET ( )-- が表す入力装置から 1 文字を入力し、そのアスキーコードの値を返します。
数値と入力装置の対応付けは未定義ですが、一般に 0 はキーボードであるようです。
-READ
--READ ( ) ++ 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 ( )-- の値に対応する入力装置から十進数を 1 つ入力し、その値を返します。 RUBOUT コードは区切り記号とみなされます。
NOT
--NOT ( ) ++ and return that value. The RUBOUT code is considered as a delimiter.
NOT
++ NOT ( )-1 の補数を返します。 後述の COM と同じです。
-NEG
--NEG ( ) +Returns 1's complement. Same as COM below.
+NEG
++ NEG ( )-2 の補数を返します。
-COM
--COM ( ) +Returns 2's complement.
+COM
++ COM ( )-1 の補数を返します。
-LSR
--LSR ( ) --1 ビット右シフトします。 最上位ビットには 0 が入り、最下位ビットはキャリーに入ります。
-ASR
--ASR ( ) +Returns 1's complement.
+ +LSR
++ LSR ( )-1 ビット右シフトします。 最上位ビットは変化せず、最下位ビットはキャリーに入ります。
-ASL
--ASL ( ) +Shift right by 1 bit. The most significant bit contains 0 and the least significant bit enters the carry.
+ASR
++ ASR ( ) ++Shift right by 1 bit. The most significant bit does not change and the least significant bit goes into carry.
+ASL
++ ASL ( )-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 ( )-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 ( )-1 ビット左シフトします。 キャリーは最下位ビットに入り、最上位ビットはキャリーに入ります。
-USR
-USR ( , , , , )-USR ( , , , )-USR ( , , )-USR ( , )-CALL 文と機能は同じですが、機械語サブルーチン実行後のアキュムレータの値を返却値として返します。
-処理系によっては使えません。
-RDHEX
-RDHEX ( )-入力装置から十六進数1桁を入力します。
-処理系によっては使えません。
-RRC
RRC ( )-キャリーを経由せずに式の値を右に 1 ビットシフトします。 最下位ビットは最上位に入ります。
-処理系によっては使えません。
-RLC
-RLC ( )-キャリーを経由せずに式の値を左に 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 ( , , , , )+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
+RDHEX ( )+Enter one hexadecimal digit from the input device.
+It can not be used depending on the processing system.
+RRC
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
+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.
+ +Binary operator
+This is an operator that calculates two terms on the left and right.
++The precedence ofoperators 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.
+ {
+ } [
+ ] (
+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 |
2 つの値を比較して真偽値を返します。 GT と LT は左右の数値を 2 の補数表現の符号付き二進数とみなして比較します。 その他の演算子は数を符号なし二進数と解釈します。
+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 |
AND | 論理積 |
OR | 論理和 |
EOR | 排他的論理和 |
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 | キャリー付き加算 |
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.
+