疑似命令は、括弧に入れたそれらの変数を予期し、文字列か式のどちらかの結果を持っています。
.BANKBYTE
引数のバンクバイト(16〜23bit)を返します。
'^' 演算子と同一の働きをします。
.BLANK
組み込み(Built-in)関数
中括弧の中の引数を評価し、引数がブランクで無い場合(引数がある場合)"false"を、引数が無い場合は"true"を返します。
The token list that makes up the function (変数)argument may optionally be enclosed in 波括弧('{'と'}').
This allows the inclusion of tokens that would otherwise terminate the list (the closing right parenthesis(かっこ)).
The 波括弧('{'と'}') are not considered part of the list,
a list just consisting of 波括弧('{'と'}') is considered to be empty.
例として、.IFBLANK
ステートメントは、以下のように替える事ができます。
.if .blank({arg})
.CONCAT
Builtin string function.
カンマで分割されたコンスタント文字列のリストを連結します。
結果は、全ての引数の連結したコンスタント文字列です。
This function is most useful in macros and when used together with the .STRING
組み込み(Built-in)関数。
The function may be used in any case where a string constant is (推測)expected.
例:
.include .concat ("myheader", ".", "inc")
これは、以下のコマンドと同じです。
.include "myheader.inc"
.CONST
組み込み(Built-in)関数
中括弧の中の変数を評価し、
もし変数が不変の式(アセンブリ時に不変の値となる)の場合"true"、
それ以外の場合は"false"となります。
例として、.IFCONST ステートメントは、以下のように替える事ができます。
.if .const(a + 3)
.HIBYTE
引数の上位バイト(8〜15bit)を返します。
これは、'>'演算子と同じ働きをします。
.HIWORD
引数の上位ワード(16〜31bit)を返します。
参照:
.LOWORD
.IDENT
変数としての文字列を予期し、その変数をidentifierへ変換します。
もし、文字列が現在の.LOCALCHAR
で始まる場合、
簡易局所identifierへ変換し、それ以外の場合は通常のidentifierへ変換します。
例:
.macro makelabel arg1, arg2
.ident (.concat (arg1, arg2)):
.endmacro
makelabel "foo", "bar"
.word foobar ; Valid label
.LEFT
組み込み(Built-in)関数
トークンリストで与えられた左の部分を抽出します。
記法:
.LEFT (<int expr>, <token list>)
最初の整数式は、トークンリストから抽出するトークンの数値です。
二番目の引数は、トークンリストそのものです。
トークンリストは、任意に波括弧'{'と'}'で囲まれます。
This allows the inclusion of tokens that would otherwise terminate the list
(the closing right paren in the given case).
例:
To check in a macro if the given (変数)argument has a '#' as first token (immediate addressing mode), use something like this:
.macro ldax arg
...
.if (.match (.left (1, {arg}), #))
; ldax called with immediate operand
...
.endif
...
.endmacro
同様に、
.MID
と
.RIGHT
組み込み(Built-in)関数も参照。
.LOBYTE
引数の下位バイト(下位0〜7bit)を返します。
'<'演算子と同じ働きをします。
.LOWORD
引数の下位ワード(下位0〜15bit)を返します。
参照:
.HIWORD
.MATCH
組み込み(Built-in)関数
それぞれに対して、2つのトークンリストをマッチします。
これは最も実用的なマクロで、文字列として格納されてないマクロ用の疑似命令です。but as lists of tokens.
記法
.MATCH(<token list #1>, <token list #2>)
両方のトークンリストは、終結トークン(comma resp. 右括弧、及び以下)を除いて任意のトークンを含みます。
トークンリストは、任意に波括弧で閉じられます。
This allows the inclusion of tokens that would otherwise terminate the list
(the closing right paren in the given case).
Often a macro parameter is used for any of the token lists.
この関数はただの比較トークンであり、トークン属性でない事に注意して下さい。
そのように、何かの数値が他の数値と同じで、現実の値に注意しない。
(So any number is equal to any other number, regardless of the actual value.)
同じ事は、文字列に対するtrue。
もし、トークンとトークン属性の比較が必要な場合は、.XMATCH
関数を使ってください。
例:
マクロASR
を仮定し、これは、符号を保持しながらアキュムレータを一つ右シフトします
The builtin processor instructions will allow an optional "A" for accu addressing for instructions like ROL
and ROR
.
これと、不正な呼び出しをチェックするため、.MATCH
関数を使うことができます。
.macro asr arg
.if (.not .blank(arg)) .and (.not .match ({arg}, a))
.error "Syntax error"
.endif
cmp #$80 ; Bit 7 into carry
lsr a ; Shift carry into bit 7
.endmacro
このマクロは変数無しか、1つの変数(必ず予約語"A"でなければならない)を受取ります。
参照:
.XMATCH
.MID
組み込み(Built-in)関数
変数として、最初のインデックス、カウント及びトークンリストを与えます。
すると、トークンリストの1部分を返します。
記法:
.MID (<int expr>, <int expr>, <token list>)
最初の整数式は、リスト中の最初のトークンです(最初のトークンはインデックス0です)。
二番目の整数式は、トークンリストから抽出するトークンの数値を指定しています。
三番目の引数は、トークンリストそのものです。
トークンリストは、任意に波括弧'{'と'}'で囲まれます。
This allows the inclusion of tokens that would otherwise terminate the list (the closing
right paren in the given case).
例:
To check in a macro if the given (変数)argument has a '#
' as first token
(immediate addressing mode), use something like this:
.macro ldax arg
...
.if (.match (.mid (0, 1, {arg}), #))
; ldax called with immediate operand
...
.endif
...
.endmacro
同様に
.LEFT
と
.RIGHT
組み込み(Built-in)関数も参照。
.REF, .REFERENCED
組み込み(Built-in)関数
The function (推測)expects an identifier as (変数)argument in (中括弧)braces.
変数は評価され、if the identifier is a symbol that has already been referenced somewhere in the source file up to the current position の場合は"true"を返します。
それ以外の場合は、"false"を返します。
例として、.IFREF
ステートメントは、以下のように替える事ができます。
.if .referenced(a)
参照:
.DEFINED
.RIGHT
組み込み(Built-in)関数
トークンリストの左側の部分を抽出します。
記法:
.RIGHT (<int expr>, <token list>)
最初の整数式は、トークンリストから抽出するトークンの数値です。
二番目の引数は、トークンリストそのものです。
トークンリストは、任意に波括弧'{'と'}'で囲まれます。
This allows the inclusion of tokens that would otherwise terminate the list
(the closing right paren in the given case).
同様に
.LEFT
と
.MID
組み込み(Built-in)関数も参照。
.SIZEOF
.SIZEOF
は変数のサイズを返す疑似関数です。
引数には、構造体、共用体、構造体メンバー、プロシージャー、ラベルを指定できます。
プロシージャー、ラベルを指定した場合、そのサイズ is defined by the amount of data placed in the segment where the label is relative to.
If a line of code switches segments (for example in a macro)
data placed in other segments does not count for the size.
Please note that a symbol or scope must exist,
before it is used together with .SIZEOF
(this may get relaxed later, but will always be true for scopes).
A scope has preference over a symbol with the same name,
so if the last part of a name represents both,
a scope and a symbol, the scope is chosen over the symbol.
After the following code:
.struct Point ; Struct size = 4
xcoord .word
xcoord .word
.endstruct
P: .tag Point ; Declare a point
@P: .tag Point ; Declare another point
.code
.proc Code
nop
.proc Inner
nop
.endproc
nop
.endproc
.proc Data
.data ; Segment switch!!!
.res 4
.endproc
.sizeof(Point)
will have the value 4, because this is the size of struct Point
.
.sizeof(Point::xcoord)
will have the value 2, because this is the size of the member xcoord
in struct Point
.
.sizeof(P)
will have the value 4, this is the size of the data declared on the same
source line as the label P
, which is in the same segment that P
is relative to.
.sizeof(@P)
will have the value 4, see above. The example demonstrates that .SIZEOF
does also work for cheap local symbols.
.sizeof(Code)
will have the value 3, since this is amount of data emitted into the code
segment, the segment that was active when Code
was entered. Note that
this value includes the amount of data emitted in child scopes (in this
case Code::Inner
).
.sizeof(Code::Inner)
will have the value 1 as (推測)expected.
.sizeof(Data)
will have the value 0. Data is emitted within the scope Data
, but since
the segment is switched after entry, this data is emitted into another
segment.
.STRAT
組み込み(Built-in)関数
この関数は、文字列と、インデックスを指定でき、整数値として与えられた場所の文字の値を返します。
インデックスは、0ベースです。
例:
.macro M Arg
; Check if the (変数)argument string starts with '#'
.if (.strat (Arg, 0) = '#')
...
.endif
.endmacro
.SPRINTF
組み込み(Built-in)関数
It (推測)expects a format string as first (変数)argument. The number
and type of the following (変数)arguments depend on the format string. The format
string is similar to the one of the C printf
function. Missing things
are: Length modifiers, variable width.
The result of the function is a string.
例:
num = 3
; Generate an identifier:
.ident (.sprintf ("%s%03d", "label", num)):
.STRING
組み込み(Built-in)関数
The function accepts an (変数)argument in (中括弧)braces and converts
this (変数)argument into a string constant. The (変数)argument may be an identifier, or
a constant numeric value.
Since you can use a string in the first place, the use of the function may not be obvious. However, it is useful in macros, or more complex setups.
例:
; Emulate other assemblers:
.macro section name
.segment .string(name)
.endmacro
.STRLEN
組み込み(Built-in)関数
The function accepts a string (変数)argument in (中括弧)braces and (評価)evaluates to the length of the string.
例:
The following macro encodes a string as a pascal style string with a leading length byte.
.macro PString Arg
.byte .strlen(Arg), Arg
.endmacro
.TCOUNT
組み込み(Built-in)関数
The function accepts a token list in (中括弧)braces. The function
result is the number of tokens given as (変数)argument.
The token list may optionally be enclosed into 波括弧('{'と'}')
which are not considered part of the list and not counted.
Enclosement in 波括弧('{'と'}') allows the inclusion of tokens that would otherwise terminate the list
(the closing right paren in the given case).
例:
The ldax
macro accepts the '#' token to denote immediate addressing (as
with the normal 6502 instructions). To translate it into two separate 8 bit
load instructions, the '#' token has to get stripped from the (変数)argument:
.macro ldax arg
.if (.match (.mid (0, 1, {arg}), #))
; ldax called with immediate operand
lda #<(.right (.tcount ({arg})-1, {arg}))
ldx #>(.right (.tcount ({arg})-1, {arg}))
.else
...
.endif
.endmacro
.XMATCH
組み込み(Built-in)関数
Matches two token lists against each other. This is
most useful within macros, since macros are not stored as strings, but
as lists of tokens.
The syntax is
.XMATCH(<token list #1>, <token list #2>)
Both token list may contain arbitrary tokens with the exception of the terminator token (comma resp. right parenthesis(かっこ)) and
トークンリストは、任意に波括弧'{'と'}'で囲まれます。
This allows the inclusion of tokens that would otherwise terminate the list
(the closing right paren in the given case).
Often a macro parameter is used for any of the token lists.
The function compares tokens and token values. If you need a function
that just compares the type of tokens, have a look at the
.MATCH
function.
参照:
.MATCH