590
回編集
-
差分
→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符号あり大なり
|-
|}
"."で始まるオペランドはスペースで区切る必要があります。label .and. 1 は有効ですがlabel.and.1は有効ではありません。
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内で定義されるラベルにははリロケータブルになり、これはアセンブル時には実際のメモリアドレスが定義されないということです。
== 擬似命令 ==