-

差分

移動先: 案内検索

Z80 Assembler Reference Manual

405 バイト追加, 2017年8月16日 (水) 08:57
MACRO
==== MACRO ====
:この擬似命令はマクロを定義します。マクロ名に前置する要素も後続する要素もあります。
カンマ区切りのフォーマルパラメータがオプション的に後続します。
:This pseudo-op defines a macro. It should be either preceded or followed by the macro name, then optionally followed by a comma-separated list of formal parameters. The lines of code following the MACRO pseudo-op up to the next ENDM pseudo-op will be stored as the body of the macro. The macro name may subsequently be used in the opcode part of an assembler statement, followed by actual parameters. The text of the body of the macro will be substituted at that point, with any use of the formal parameters substituted with the corresponding actual parameter. For exampleMACRO擬似命令に後続し、次のENDMまでのコードの行がマクロ本体として格納されます。 :マクロ名は後続するアセンブラステートメントのオプコード部分でも使われ、実際のパラメータが後続します。 :マクロの本体は、その部分で、対応する実際のパラメータを持つフォーマルパラメータと置き換えられます??:<nowiki>例:</nowiki>
print MACRO string
ENDM
:使用されると、このマクロはマクロの本体で、実際のパラメータの代用である関数と引数の3つのインストラクションに展開されます?? When used, this macro will expand to the 3 instructionsin the body of the macro, with the actual parameters substituted for func and arg. Thus print ':従って、print hello world' expands toは次のように展開されます。
psect data
call 5
:マクロの引数はかぎ括弧('<' と '>')で閉じてコンマなどのデリミタキャラクタを含む任意のテキストを渡すために使うことが可能です。
:例えば、キャリッジリターンとラインフィードを含む文字列を先ほど定義したprintマクロで使いたいとしましょう。Macro arguments can be enclosed in angle brackets ('<'and '>') to pass arbitrary text including delimiter characters like commas as a single argument. For example, supposeyou wanted to use the print macro defined above to print astring which includes the carriage return and linefeed characters. The macro invocation:その場合のマクロを以下のように発動させたとします。
print 'hello world',13,10
 would fail because 13 and 10 are treated as extra argumentsand ignored. In order to pass a string which includes commasas a single argument, you could write:しかしこれは失敗します。なぜなら13と10が追加の引数として扱われて、無視されるからです。コンマを含む文字列を単体の引数として渡すためには、次のように書きます。
print <'hello world',13,10>
 which would cause the text :これで 'hello world',13,10 to be passedthrough as a single argument. This would expand to the following code:10というテキストを単体の引数として渡すことができるでしょう。これは次のようなコードに展開されます。
psect data
call 5
:ZASは古いバージョンのZASや他のZ80アセンブラとの互換性のため、2種類のマクロ定義をサポートしています。
マクロ名はMACRO擬似命令の前のラベルフィールドでも、MACRO擬似命令の後のオペランドフィールドでも定義できます。
 ZAS supports two forms of macro declaration for compatibility with older versions of ZAS and other Z80 assemblers. The macro name may be declared either in the label field before the MACRO pseudo-op, or in the operand field after the MACRO pseudo-op. Thus these two MACRO declarations are equivalent:そのため、この2つのマクロ定義は等価です。
bdos MACRO func,arg
call 5
ENDM
 
and
MACRO bdos,func,arg
call 5
ENDM
 
 
==== LOCAL ====

案内メニュー