<?xml version="1.0" encoding="UTF-8" ?><rdf:RDF 
  xmlns="http://purl.org/rss/1.0/"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:atom="http://www.w3.org/2005/Atom"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xml:lang="ja">
  <channel rdf:about="http://w.atwiki.jp/makotof/">
    <title>makotof @ ウィキ</title>
    <link>http://w.atwiki.jp/makotof/</link>
    <atom:link href="https://w.atwiki.jp/makotof/rss10.xml" rel="self" type="application/rss+xml" />
    <atom:link rel="hub" href="https://pubsubhubbub.appspot.com" />
    <description>makotof @ ウィキ</description>

    <dc:language>ja</dc:language>
    <dc:date>2009-08-30T19:08:02+09:00</dc:date>
    <utime>1251626882</utime>

    <items>
      <rdf:Seq>
                <rdf:li rdf:resource="https://w.atwiki.jp/makotof/pages/47.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/makotof/pages/43.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/makotof/pages/46.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/makotof/pages/45.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/makotof/pages/44.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/makotof/pages/42.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/makotof/pages/1.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/makotof/pages/41.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/makotof/pages/33.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/makotof/pages/40.html" />
              </rdf:Seq>
    </items>
	
		
    
  </channel>
    <item rdf:about="https://w.atwiki.jp/makotof/pages/47.html">
    <title>入出力</title>
    <link>https://w.atwiki.jp/makotof/pages/47.html</link>
    <description>
      *システムコール
***文字の出力

例)
    mov ah, 02h
    mov dl, 31h
    int 21h

***文字列の出力

例）
    mov ah, 09h
    mov dx, msg  ;出力する文字列の先頭アドレスをDX[[レジスタ]]にセットする
    int 21h

***文字の入力

例)
    mov ah, 08h
    int 21h

[[sample&gt;http://makotof.unfuddle.com/svn/makotof_android/assembler/Assembler101/inpc.asm]]
[[sample&gt;http://makotof.unfuddle.com/svn/makotof_android/assembler/Assembler101/inpch.asm]]

***文字列の入力

例)
    mov ah, 0Ah         ;キーボードからの文字列入力
    mov dx, buf
    mov byte[buf], 20h  ;バッファの長さ
    int 21h

※入力された文字列はバッファの3バイト目以降に入る。バッファの2バイト目には入力された文字列が入る

[[sample&gt;http://makotof.unfuddle.com/svn/makotof_android/assembler/Assembler101/inps.asm]]

***ファイルからの読み込み

例)
    mov dx, sfile    ;DX=ファイル名文字列
    mov al, 0        ;モード(AL:0 = 読み出し, 1 = 書き込み, 2 = 読み書き)
    mov ah, 3Dh      ;ファイルオープンを指定
    int 21h

sfile db &quot;srcfile.txt&quot;, 0  ;ファイル名 (0で終わる文字列)
ファイルが開くとAXレジスタにファイルハンドルが入る

    mov [fh], ax      ;ファイルハンドル

データを読み込むためには、AHレジスタを3FhにしてINT21を実行する
    mov bx, [fh]    ;ファイルハンドル
    mov dx, buf     ;DX=バッファ
    mov cx, 1       ;読み込むバイト数
    mov ah, 3Fh     ;読み込む
    int 21h         ;読み込む (結果はCF:0=成功, 1=エラー)

読み込みが成功すると、読み込んだ文字がバッファに、読み込んだバイト数がAXレジスタに保存される

[[sample&gt;http://makotof.unfuddle.com/svn/makotof_android/assembler/Assembler101/sample.asm]]

***ファイルへの書き込み

例)
    dfile db  &quot;destfile.txt&quot;, 0        ;ファイル名 (0で終わる文字列)
    
    ;入力ファイルオープン
    mov dx, sfile
    mov al, 0          ;モード(AL:0=読み出し, 1=書き込み, 2=読み書き)
    mov ah, 3Dh        ;ファイルオープンを指定
    int 21h
    jc  endquit        ;結果は(CF:0=成功, 1=エラー)

    mov [ofh], ax

新しいファイルを作成するには、CXレジスタに0を設定し、AHレジスタを3ChにしてINT21を実行する

    ;出力ファイルを作成
    mov dx, dfile      ;DX=ファイル名文字列
    mov cx, 0          ;通常ファイルを指定
    mov ah, 3Ch        ;ファイル作成
    int 21h
    jc  endquit        ;結果は(CF:0=成功, 1=エラー)
    mov [ofh], ax

ファイルにデータを書き込む場合は、AHレジスタに40hを設定してINT21を実行する

    mov bx, [ofh]      ;出力ファイルハンドル
    mov dx, buf        ;DX=バッファ
    mov cx, 1          ;書き込むバイト数
    mov ah, 40h        ;書き込みを指定
    int 21h            ;結果は(CF:0=成功, 1=エラー)
                       ;AX=書き込んだバイト数
[[sample&gt;http://makotof.unfuddle.com/svn/makotof_android/assembler/Assembler101/bcopy.asm]]

***ポートからの入力

&amp;bold(){IN}

ポートからALレジスタ (またはAXレジスタ、EAXレジスタ)にバイト(またはワード、ダブルワード)のデータを入力する

&amp;bold(){INS}

ポートからストリングを入力する
INSB, INSW, INSDがある.メモリの伸び方はディレクションフラグに依存する
REPプリフィックスを使って、この命令をCX回繰り返す

***ポートからの出力

&amp;bold(){OUT}
OUTS, OUTW, OUTDがある。
[[sample&gt;http://makotof.unfuddle.com/svn/makotof_android/assembler/Assembler101/beeps.asm]]

***ストリング操作

SIレジスタのオフセットアドレスの内容をDIレジスタのオフセットアドレスにコピーする
その後、SIレジスタとDIレジスタの内容をインクリメント・デクリメントする

MOVSB = 
    1) MOV AL, [SI]
    2) MOV [DI], AL
    3) INC(DEC) SI
    4) INC(DEC) DI

DFフラグが0であればそれぞれのポインタをインクリメントし、 (CLD命令)
1であれば、デクリメントする (STD命令)

***MOVSD
    [DS:SI]の内容4バイトを[ES:DI]に転送し、DF=0のときは、SI,DIを4増やす

REPと組み合わせることで繰り返し回数を指定できる
例)
    mov cx 128
    rep movsd   ;128*4バイトコピーする    </description>
    <dc:date>2009-08-30T19:08:02+09:00</dc:date>
    <utime>1251626882</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/makotof/pages/43.html">
    <title>基本</title>
    <link>https://w.atwiki.jp/makotof/pages/43.html</link>
    <description>
      ニブル: 4ビット単位 16進数の1桁で表現できる数
バイト: 8ビット単位 16進数の2桁
ワード: 2バイト, 16ビット
ダブルワード: 4バイト, 32ビット

リトルエンディアン: 下位の桁からメモリに保存する
ビッグエンディアン: 上位の桁からメモリに保存する

[[レジスタ]]
[[移動命令]]
[[分岐とサブルーチン]]
[[入出力]]    </description>
    <dc:date>2009-08-26T22:32:48+09:00</dc:date>
    <utime>1251293568</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/makotof/pages/46.html">
    <title>分岐とサブルーチン</title>
    <link>https://w.atwiki.jp/makotof/pages/46.html</link>
    <description>
      &amp;bold(){ジャンプ}

[[sample&gt;http://makotof.unfuddle.com/svn/makotof_android/assembler/Assembler101/jmp.asm]]

|FAR|異なるコードセグメントの中のコードへジャンプ|
|NEAR|同じコードセグメントの中のコードへのジャンプ|
|SHORT|同じコードセグメントの中の相対オフセットで-128-127バイト以内のコードへのジャンプ|

**条件付きジャンプ (Jcc)

例) cmp dl, 5Bh
    jnz dispchr

[[sample&gt;http://makotof.unfuddle.com/svn/makotof_android/assembler/Assembler101/jnz.asm]]

**JCXZとJECXZ

|JCXZ|CX[[レジスタ]]の内容が0である場合にショートジャンプ|
|JECXZ|ECXレジスタの内容が0である場合にショートジャンプ|

例)
    mov cx, N;
doit:
    dec cx
    jcxz endquit
    jmp doit
endquit:

[[sample&gt;http://makotof.unfuddle.com/svn/makotof_android/assembler/Assembler101/jcxz.asm]]

*ループ

CXレジスタが0であるかどうかという条件のみ

例)
    mov cx, N
doit:
    loop    doit ;CXがゼロでなければdoitにジャンプする

32ビットの場合は、ECXが使われる

[[sample&gt;http://makotof.unfuddle.com/svn/makotof_android/assembler/Assembler101/loop.asm]]

**条件付きループ

|命令|概要|
|LOOPE|等しい(ZF=1)ならば繰り返す|
|LOOPNE|等しくない(ZF=0)ならば繰り返す|
|LOOPNZ|ゼロでない(ZF=0)ならば繰り返す|
|LOOPZ|ゼロ(ZF=1)ならば繰り返す|

例)
    mov dl, 41h
    mov cx, 20h
doit:
    int 21h
    inc dl
    cmp dl, 5Bh
    loopne doit

[[sample&gt;http://makotof.unfuddle.com/svn/makotof_android/assembler/Assembler101/loopdl.asm]]

*サブルーチン

&amp;bold(){CALL} -- 指定されたアドレスにジャンプしてサブルーチンを呼び出す
CALLが実行されると、現在のIP(Instruction Pointer)がスタックにプッシュされる。
呼び出しがfarコールのときは、IPとCSがプッシュされる
サブルーチンから戻る場合は、RET命令を使う

&amp;bold(){RET} --- スタックからIPかEIPをポップして新しいアドレスに制御を移す。
第2オペランドに数値を指定した場合は、リターンアドレスをポップしたあとでさらに指定したバイトだけスタックポインタをインクリメントする (スタックを減らす &#039;-&#039;-&gt;&#039;+&#039;)

*パラメータの受け渡し
- 特定のメモリアドレスを使う　[[sample&gt;http://makotof.unfuddle.com/svn/makotof_android/assembler/Assembler101/putch.asm]]
- レジスタを使う [[sample&gt;http://makotof.unfuddle.com/svn/makotof_android/assembler/Assembler101/subprint.asm]]
- スタックを使う [[sample&gt;http://makotof.unfuddle.com/svn/makotof_android/assembler/Assembler101/putchar.asm]]    </description>
    <dc:date>2009-08-26T00:39:01+09:00</dc:date>
    <utime>1251214741</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/makotof/pages/45.html">
    <title>移動命令</title>
    <link>https://w.atwiki.jp/makotof/pages/45.html</link>
    <description>
      &amp;bold(){MOV}
MOV {destinattion} {source}

[[sample&gt;http://makotof.unfuddle.com/svn/makotof_android/assembler/Assembler101/dispstr.asm]]


&amp;bold(){メモリ参照}
mov ax, [bar]     ;アドレスbarにある値をAXに移動する
mov ax, bar       ;値barをAXに移動する
mov eax, [ebp+8]  ;ebp+8にある値をeaxに移動する

※すぐに値が計算できる即値でなければならない

[[sample&gt;http://makotof.unfuddle.com/svn/makotof_android/assembler/Assembler101/ha.asm]]

メモリからメモリへは直接値をコピーできない
ダメな例
mov byte[x], [y]
良い例
mov dl, [y]
mov [x], dl
※通常はMOVSを使う。

また、destination operandにメモリを指定したとき、サイズ単位がわからないので、明示する
ダメな例
mov [x], 8
良い例
mov byte[x], 8
mov word[x], 8

&amp;bold(){XCHG}
source operand &lt;-&gt; destination operandの交換

例
xchg dl, [msg+1]    ;msg+1の内容とdlを交換する
xchg al, ah         ;alとahの内容を交換する

[[sample&gt;http://makotof.unfuddle.com/svn/makotof_android/assembler/Assembler101/xchg.asm]]

&amp;bold(){ポップとプッシュ}

POPで取り出されるデータは
16bitの場合は[SS:SP], 32ビットの値は[SS:ESP]の値

&amp;bold(){PUSHAとPOPA}
すべての汎用[[レジスタ]] AX,CX,DX,BX,SP,BP,SI,DIを連続してスタックにプッシュする
16bit環境では、スタックポインタは合計で16bitだけデクリメントされる2*8
32bit環境では、EAX,ECX,EDX,EBX,ESP,EBP,ESI,EDIで合計32bit(4*8bit)だけデクリメントされる
※スタックはマイナス方向に延びる

&amp;bold(){PUSHFとPOPF}
PUSHFはフラグレジスタ全体をプッシュする
範囲を明示的に示す場合は、PUSHFW,またはPUSHFDを使う

&amp;bold(){ロードとストア}
ロード: レジスタにデータを読み込む
ストア: レジスタのデータをほかの場所に保存する

&amp;bold(){LAHFとSAHF}

LAHF(Load AH from Flags)はフラグをAHにロード =&gt; フラグレジスタの内容をAHレジスタにセットする
SAHF(Store AH to Flags)はAHの値をフラグに保存する

例)
mov ah, 10010011b    ;AHレジスタにフラグを設定したい値をセットする
sahf                 ;フラグの値をAHレジスタから読み込む

lahf                 ;フラグをAHレジスタにロードする
push ah              ;ahレジスタの内容をプッシュする

(AHやフラグを使って何かする)

pop  ah              ;ahレジスタの内容をポップする
sahf                 ;フラグの内容をahレジスタから読み込む


&amp;bold(){LDSとLES}

LDS(Load far pointer to DS and register)
LES(Load far pointer to ES and register)
メモリから1回で16bitオフセットと16bitのセグメントをロードする
32bit環境では、
32bitオフセットと16bitのセグメントをロードする

LEA(Load Effective Address) 有効アドレスをロードする

例)
LEA (レジスタ), (メモリ)
source -&gt; memory
dest -&gt; register
※メモリの内容にはアクセスしない 第2オペランドで指定された有効アドレスを計算し、第1オペランドで指定したレジスタの中に、その計算されたアドレスを保存する    </description>
    <dc:date>2009-08-25T02:16:02+09:00</dc:date>
    <utime>1251134162</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/makotof/pages/44.html">
    <title>レジスタ</title>
    <link>https://w.atwiki.jp/makotof/pages/44.html</link>
    <description>
      &amp;bold(){汎用レジスタ}

|AX|accumulator register|データの一時記憶、各種演算|
|BX|base address register|特定のメモリを指定するポインタ|
|CX|count register|繰り返し処理命令の回数を数えるカウンタ|
|DX|data register|データの一時記憶。AXと組み合わせて剰余算|

AH-AL, BH-BL, CH-CL, DH-DL

&amp;bold(){セグメントレジスタ}
|CS|Code Segment|命令コードのあるセグメントアドレスを保存|
|DS|Data Segment|データのあるセグメントアドレスを保存|
|ES|Extra Segment|第2のデータセグメントアドレスを保存|
|SS|Stack Segment|スタックセグメントアドレスを保存|

※8ビット以下のCPUやセグメントを使わない設計のCPUには、セグメントレジスタはない

&amp;bold(){特殊目的}
|SI|Source Index|メモリを指すポインタ|
|DI|Destination Index|メモリを指すポインタ|
|BP|Base Pointer|プログラムスタックを管理するポインタ|
|SP|Stack Pointer| スタックセグメントで使うベースポインタ |
|IP|Instruction Pointer|次に実行する命令のオフセットアドレスを保存|

使用例:
BP, プロシージャの中で、パラメートとローカル変数にアクセス
SI, DI SIを転送元アドレス、DIを転送先アドレスとして、間接的にメモリにアクセスしたりする

&amp;bold(){フラグレジスタ}
|OF|Overflow Flag|符号付き演算で桁あふれが生じるとセットされる|
|DF|Direction Flag|ストリング操作命令でポインタの増減を表す|
|IF|Interrupt Flag|リセットすると外部割り込みを受け付けなくなる|
|TF|Trace Flag|トレースで実行するときのフラグ|
|SF|Sign Flag|演算結果が負になるとセットされる|
|ZF|Zero Flag|演算結果がゼロになるか、比較で一致するとセットされる|
|AF|Auxiliacy Carry Flag|補助キャリーフラグ(BCD演算で使用)|
|PF|Parity Flag|演算の結果、1となるビットが偶数個のときセット、奇数個ならリセット|
|CF|Carry Flag|演算の結果、桁上がりが生じるとセットされる|    </description>
    <dc:date>2009-08-25T01:33:32+09:00</dc:date>
    <utime>1251131612</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/makotof/pages/42.html">
    <title>Assembler</title>
    <link>https://w.atwiki.jp/makotof/pages/42.html</link>
    <description>
      [[基本]]    </description>
    <dc:date>2009-08-25T01:16:27+09:00</dc:date>
    <utime>1251130587</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/makotof/pages/1.html">
    <title>トップページ</title>
    <link>https://w.atwiki.jp/makotof/pages/1.html</link>
    <description>
      [[Android]]
[[Assembler]]    </description>
    <dc:date>2009-08-25T01:14:16+09:00</dc:date>
    <utime>1251130456</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/makotof/pages/41.html">
    <title>Android</title>
    <link>https://w.atwiki.jp/makotof/pages/41.html</link>
    <description>
      [[3D Animation]]    </description>
    <dc:date>2009-06-20T17:15:00+09:00</dc:date>
    <utime>1245485700</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/makotof/pages/33.html">
    <title>Microsoft Office SharePoint Server 2007 Best Practices</title>
    <link>https://w.atwiki.jp/makotof/pages/33.html</link>
    <description>
      Planning and Designing &gt; [[SharePoint]] Server 2007 Design Life Cycle
[[Major Milestone 1: Design Phase]]
[[Major Milestone 2: Build Readiness]]
[[Major Milestone 3: Operational Readiness]]
[[Major Milestone 4: Operation and Supporting]]
[[Summary]]

Planning and Designing &gt; Designing Business Requirements
[[Business Requirements]]

Planning and Designing &gt; Project Plans for a SharePoint Server 2007 Deployment
[[Understanding Microsoft&#039;s SharePoint Server 2007 Development Plan]]
[[The Envisioning State]]
[[The Planning Stage]]
[[Deployment, Implementation, and ConfigurationManagement]]
[[Post-Implementation Operations, Optimization, and Business Review]]

Building &gt; [[Document Management]]
Building &gt; [[Enterprise Content Management]]
Building &gt; [[Business Processes and Workflows]]
Building &gt; [[Branding and Customization]]
Building &gt; [[Web Parts, Features, and Solutions Management]]
Building &gt; [[Creating and Managing Publishing Sites]]
Building &gt; [[Understanding and Implementing Microsoft Search Server 2008]]    </description>
    <dc:date>2008-11-20T21:03:49+09:00</dc:date>
    <utime>1227182629</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/makotof/pages/40.html">
    <title>Understanding Microsoft&#039;s SharePoint Server 2007 Development Plan</title>
    <link>https://w.atwiki.jp/makotof/pages/40.html</link>
    <description>
      &amp;bold(){Plan Integration}

Business Data Catalog
Excel Services
Microsoft Office Forms Server
Microsoft Search Server
Microsoft ForeFront Security for [[SharePoint]]
Microsoft Office Groove Server 2007
Incoming e-mail

&amp;bold(){その他}

Microsoft Office ProjectServer 2007
Microsoft Office Project Portfolio Server
Microsoft Office Communications Server 2007
Microsoft Office PerformancePoint Server 2007    </description>
    <dc:date>2008-11-20T20:41:17+09:00</dc:date>
    <utime>1227181277</utime>
  </item>
  </rdf:RDF>
