ループ継続判断用の変数、ループ継続用のラベル、条件分岐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 )
ldstr "shouting"
call void class [mscorlib]System.Console::WriteLine(string)
ldc.i4.0
stloc counter
loop_start:
ldloc counter
ldc.i4.1
add stloc counter
ldstr "lager"
call void class [mscorlib]System.Console::WriteLine(string)
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
|