-

差分

移動先: 案内検索

Z80 Assembler Reference Manual

3,295 バイト除去, 2017年8月17日 (木) 10:09
Expressionsエクスプレッション
:これはCREFユーティリティを走らせる時に必要で、この情報が整形されたリスティングに変わります。
== The Assembly Language =Expressionsエクスプレッション As mentioned above, the assembly language accepted by zas is based on the Zilog mnemonics. You should have some reference book such as the "Z80 Assembly Language Handbook". Described below are those areas in which zas differs, or has extensions, compared to the standard Zilog assembly language. === Symbols === The symbols (labels) accepted by the assembler may beof any length, and all characters are significant. The characters used to form a symbol may be chosen from the upperand lower case alphabetics, the digits 0-9, and the specialsymbols underscore ('_'), dollar ('$') and question mark('?'). The first character may not be numeric. Upper andlower case are distinct. The following are all legal anddistinct symbols.  An_identifier an_identifier an_identifier1 $$$ ?$_123455 Note that the symbol $ is special (representing thecurrent location) and may not be used as a label. Nor mayany opcode or pseudo-op mnemonic, register name or conditioncode name. You should note the additional condition codenames described later. ==== Temporary Labels ==== The assembler implements a system of temporary labels,useful for use within a localized section of code. Thesehelp eliminate the need to generate names for labels whichare referenced only in the immediate vicinity of theirdefinition, for example where a loop is implemented. A temporary label takes the form of a digit string. Areference to such a label requires the same digit string,plus an appended b or f to signify a backward or forwardreference respectively. Here is an example of the use ofsuch labels.  entry_point: ;This is referenced from far away ld b,10 1: dec c jr nz,2f ;if zero, branch forward to 2: ld c,8 djnz 1b ;decrement and branch back to 1: jr 1f ;this does not branch to the ;same label as the djnz 2: call fred ;get here from the jr nz,2f 1: ret ;get here from the jr 1f  The digit string may be any positive decimal number 0to 65535. A temporary label value may be re-used any numberof times. Where a reference to e.g. 1b is made, this willreference the closest label 1: found by looking backwardsfrom the current point in the file. Similarly 23f willreference the first label 23: found by looking forwards fromthe current point in the file. === Constants === Constants may be entered in one of the radices 2, 8, 10or 16. The default is 10. Constants in the other radices maybe denoted by a trailing character drawn from the followingset: {|!Character!! Radix!! Nameエクスプレッションは「Z80アセンブリ言語ハンドブック」に記述されている内容で大部分が構成されます。
|-
|B<nowiki>-</nowiki>|| 2|| binary Subtraction減算
|-
|O.and.|| 8|| octal Bitwise ANDビット演算AND
|-
|Q|| 8.eq.|| octalEquality test同値か評価
|-
|o|| 8.gt.|| octalSigned greater than符号あり大なり
|-
|q.high.|| 8|| octal Hi byte of operandオペランドの高位バイト
|-
|H|| 16.low.|| hexadecimalLow byte of operandオペランドの低位バイト
|-
|h|| 16|| hexadecimal|} Hexadecimal constants may also be specified in C style,for example LD A,0x21. Note that a lower case b may not beused to indicate a binary number, since 1b is a backwardreference to a temporary label 1:lt==== Character Constants ==== A character constant is a single character enclosed insingle quotes ('). Multi character constants may be usedonly as an operand to a DEFM pseudo-op. ==== Floating Constants ==== A floating constant in the usual notation (e.g. 1.234or 1234e-3) may be used as the operand to a DEFF pseudo-op. ==== Opcode Constants ==== Any z80 opcode may be used as a constant in an expres-sion. The value of the opcode in this context will be thebyte that the opcode would have assembled to if used in thenormal way. If the opcode is a 2-byte opcode (CB or ED prefix byte) only the second byte of the opcode will be used.This is particularly useful when setting up jump vectors.For example:  ld a,jp ;a jump instruction ld (0),a ;0 is jump to warm boot ld hl,boot ;done here ld (1),hl  === Expressions === Expressions are constructed largely as described in the"Z80 Assembly Language Handbook". ==== Operators ==== The following operators may be used in expressions: {|!Operator!! Meaning| Signed less than符号あり小なり
|-
|&.mod.|| Bitwise AND Modulusモジュール
|-
|*.not.|| Multiplication Bitwise complementビット演算
|-
|<nowiki>+</nowiki>.or.|| Addition Bitwise orビット演算
|-
|<nowiki>-</nowiki>.shl.|| Subtraction Shift left左シフト
|-
|.andshr.|| Bitwise ANDShift right右シフト
|-
|.eqult.|| Equality test Unsigned less than符号なし小なり
|-
|.gtugt.|| Signed Unsigned greater thanthan符号なし大なり
|-
|.highxor.|| Hi byte of operand Exclusive orXOR
|-
|.low./|| Low byte of operand Divison除算
|-
|.lt.<|| Signed less thanthan符号あり小なり
|-
|.mod.=|| Modulus Equalityイコール
|-
|.not.>|| Bitwise complement Signed greater than符号あり大なり
|-
|.or.|| Bitwise or|-|.shl.|| Shift left|-|.shr.|| Shift right|-|.ult.|| Unsigned less than|-|.ugt.|| Unsigned greater than|-|.xor.|| Exclusive or|-|/|| Divison|-|<|| Signed less than|-|=|| Equality|-|>|| Signed greater than|-|^|| Bitwise ororビット演算
|}
"."で始まるオペランドはスペースで区切る必要があります。label .and. 1 は有効ですがlabel.and.1は有効ではありません。
Operators starting with a dot "." should be delimitedby spaces, thus label .and. 1 is valid but label.and.1 isnot.====再配置性====
==== Relocatability ====zasは再配置可能なオブジェクトコードを生成します。つまりこれは、メモリのどこに配置すべきかをアセンブル時に指定しなくて良い、ということを意味します。
Zas produces object code which is relocatable; thismeans that it is not necessary to specify assembly timewhere the code is to be located in memory. It is possible todo so, by use of the ORG pseudo-op, however the preferredapproach is to use program sections or psects. A psect is anamed section of the program, in which code or data may bedefined at assembly time. All parts of a psect will beloaded contiguously into memory, even if they were definedin separate files, or in the same file but separated by codefor another psect. For example, the following code will loadsome executable instructions into the psect named text, andsome data bytes into the data psect.これはORG擬似命令を使うことで可能ですが、より好ましいアプローチはプログラムセクションあるいはpsectをつかうことです。
psectはプログラムのセクションに名前を付けたもので、この中のコードやデータさアセンブル時に定義されます。psectの全てのパーツは、別々のファイルで定義されていても、また同じファイル内で、別のpsectで分断されていたとしても、メモリに連続して読み込まれます。
 
例えば、次のコードはtextと名付けられたpsectに実行可能なインストラクションを。またdata psectにデータバイトを読み込みます。
psect text, global
jr putit
2つのブロックのtext psectが、data psectによって分断されていますが、2つのtext psectブロックはリンカに呼び出される時に連続します。
 
"ld hl,anotherstring"というインストラクションは実行時に"putit:"というラベルに落ちます??
 
2つのpsectの実際のメモリ位置はリンカによって決められます。psectアドレスがどのように決められるかについては、リンカのマニュアルを参照してください。
 
psect内で定義されるラベルにははリロケータブルになり、これはアセンブル時には実際のメモリアドレスが定義されないということです。
Note that even though the two blocks of code in thetext psect are separated by a block in the data psect, thetwo text psect blocks will be contiguous when loaded by thelinker. The instruction "ld hl,anotherstring" will fallthrough to the label "putit:" during execution. The actuallocation in memory of the two psects will be determined bythe linker. See the linker manual for information on howpsect addresses are determined.ラベルがデフォルトの(名前のない)psectの場合、もしくは絶対定義(PSECT擬似命令の記述参照)した場合には適用されません。
A label defined in a psect is said to be relocatable,that is, its actual memory address is not determined atassembly time. Note that this does not apply if the label isin the default (unnamed) psect, or in a psect declared abso-lute (see the PSECT pseudo-op description below). Anylabels declared in an absolute psect will be absolute, thatis their address will be determined by the assembler.絶対psect内で定義されたラベルはアセンブラによってアドレスが決められ、絶対指定になります。
With the version of ZAS supplied with version 7 orlater of HI-TECH C, relocatable expressions may be combinedfreely in expressions. Older versions of ZAS allowed onlylimited arithmetic on relocatable expressions.Cのバージョン7もしくはそれ以降のバージョンと一緒に提供されるZASは、リロケータブルエクスプレッションが、エクスプレッション内で自由に結合します。古いバージョンのZASは、リロケータブルエクスプレッションが算術的に限られます??
== 擬似命令 ==

案内メニュー