ループ継続判断用の変数、ループ継続用のラベル、条件分岐opcode、これらの組み合わせでループ処理をします。

すべてを展開すべてを収束
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 
-
!
 
 
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!
 //アセンブリマニフェスト
 .assembly x {
 }
 
 //関数
 .method static void main() {
     .entrypoint
     .locals ( int32 counter ) //カウント用変数の宣言。int counter;
 
       ldstr     "shouting"
     call      void class [mscorlib]System.Console::WriteLine(string)
 
 
 
       ldc.i4.0
     stloc     counter //カウント用変数の初期化。counter = 0;
   
   loop_start:
     // カウントアップ。counter++;
         ldloc     counter
         ldc.i4.1
       add // 2回popし、その内容を足し算し、結果をpushする。
     stloc     counter
 
     // 処理
       ldstr     "lager"
     call      void class [mscorlib]System.Console::WriteLine(string)
 
     // if( counter < 4 ) goto loop_start;
       ldloc     counter
       ldc.i4.4
     blt       loop_start
     
 
     ret
 }

実行結果:

shouting
lager
lager
lager
lager

C#では・・・

すべてを展開すべてを収束
  1
  2
  3
  4
-
|
|
!
 void main(){
     System.Console.WriteLine("shouting");
     for( int counter=0; counter<4; counter++) System.Console.WriteLine("lager");
 }

VB.NETでは・・・

  1
  2
  3
  4
  5
  6
  7
 public sub main()
     dim counter as integer
     System.Console.WriteLine("shouting")
     for counter = 0 to 3
         System.Console.WriteLine("lager")
     next counter
 end sub

トップ 編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード 新規 一覧 単語検索 最終更新 リンク元 ヘルプ 最終更新のRSS xenowire
Last-modified: Tue, 01 Sep 2009 06:11:08 JST