mirror of
https://github.com/foxsen/archbase.git
synced 2026-03-31 09:21:46 +08:00
initial import to public repository
This commit is contained in:
38
materials/chapter2/loop.S
Normal file
38
materials/chapter2/loop.S
Normal file
@@ -0,0 +1,38 @@
|
||||
test_for:
|
||||
or $t0,$r0,$r0
|
||||
or $t1,$r0,$r0
|
||||
.L2:
|
||||
blt $t0,$a0,.L3
|
||||
or $a0,$t1,$r0
|
||||
jr $ra
|
||||
.L3:
|
||||
add.w $t1,$t1,$t0
|
||||
addi.w $t0,$t0,1
|
||||
b .L2
|
||||
|
||||
|
||||
test_while:
|
||||
or $t0,$r0,$r0
|
||||
or $t1,$r0,$r0
|
||||
.L2:
|
||||
blt $t0,$a0,.L3
|
||||
or $a0,$t1,$r0
|
||||
jr $ra
|
||||
.L3:
|
||||
add.w $t1,$t1,$t0
|
||||
addi.w $t0,$t0,1
|
||||
b .L2
|
||||
|
||||
|
||||
test_dowhile:
|
||||
or $t0,$r0,$r0
|
||||
or $t3,$r0,$r0
|
||||
.L2:
|
||||
add.w $t1,$t3,$t0
|
||||
addi.w $t2,$t0,1
|
||||
or $t3,$t1,$r0
|
||||
or $t0,$t2,$r0
|
||||
blt $t2,$a0,.L2
|
||||
or $a0,$t1,$r0
|
||||
jr $ra
|
||||
|
||||
Reference in New Issue
Block a user